Updating tests.

1.10.x
Julio Montoya 10 years ago
parent 8f1de50e79
commit aed5742dca
  1. 3
      app/config/routing.yml
  2. 1
      app/config/security.yml
  3. 8
      features/backend/course/CourseSessionRelationship.feature
  4. 8
      features/backend/course/CourseUserRelationship.feature
  5. 13
      features/backend/user/AdminLogin.feature
  6. 4
      features/backend/user/UserLogin.feature
  7. 610
      src/Chamilo/CoreBundle/Behat/CoreContext.php
  8. 46
      src/Chamilo/CoreBundle/Behat/CourseContext.php
  9. 64
      src/Chamilo/CoreBundle/Behat/DefaultContext.php
  10. 34
      src/Chamilo/CoreBundle/Behat/LoginContext.php
  11. 1
      src/Chamilo/CoreBundle/Behat/UserContext.php

@ -47,6 +47,9 @@ liip_theme:
home:
path: /
login:
path: /login
logout:
path: /logout

@ -59,6 +59,7 @@ security:
use_forward: false
check_path: /login_check
failure_path: null
default_target_path: /
success_handler: chamilo_core.listener.login_success_handler
logout:
path: /logout

@ -5,10 +5,10 @@ Feature: Course Session Relationship
I need a working relationship
Background:
# Given there are following users:
# | username | email | plain_password | enabled | group |
# | student | student@example.com | student | yes | students |
# | teacher | teacher@example.com | teacher | yes | teacher |
Given there are following users:
| username | email | plain_password | enabled | groups |
| student | student@example.com | student | yes | students |
| teacher | teacher@example.com | teacher | yes | teachers |
Given I have a course "My course"
Given I have a session "My session"

@ -5,10 +5,10 @@ Feature: Course user relationship
I need a working relationship
Background:
# Given there are following users:
# | username | email | plain_password | enabled |
# | student | student@example.com | student | yes |
# | teacher | teacher@example.com | teacher | yes |
Given there are following users:
| username | email | plain_password | enabled | groups |
| student | student@example.com | student | yes | students |
| teacher | teacher@example.com | teacher | yes | teachers |
Given I have a course "My course"
Scenario: A course contains a student

@ -5,8 +5,11 @@ Feature: Admin dashboard protection
I need to forbid access to admin from basic user
Scenario: Try to access admin with simple account
Given I am logged in as Student
When I fill in "_username" with "<username>"
And I fill in "_password" with "<password>"
And I press "_submit"
Then I should see "<message>"
Given I am logged in student
When I go to the administration page
Then I should see "Access denied"
Scenario: Try to access admin with admin account
Given I am logged in as administrator
When I go to the administration page
Then I should see "Admin Dashboard"

@ -6,7 +6,7 @@ Feature: User login
Background:
Given there are following users:
| username | email |plain_password| enabled | group |
| username | email |plain_password| enabled | groups |
| student_behat | student_behat@example.com |student_behat| yes | students |
@javascript
@ -19,5 +19,5 @@ Feature: User login
Examples:
| username | password | message |
| student_behat | student_behat | Logout |
| student_behat | student_behat | Hello, student_behat |
| pirate | pirate | Bad credentials |

@ -0,0 +1,610 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Behat;
use Behat\Gherkin\Node\TableNode;
//use Sylius\Bundle\ResourceBundle\Behat\DefaultContext;
use Chamilo\UserBundle\Entity\User;
use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Class CoreContext
* @package Chamilo\CoreBundle\Behat
*/
class CoreContext extends DefaultContext
{
/**
* @Given /^there are following orders:$/
* @Given /^the following orders exist:$/
* @Given /^there are orders:$/
* @Given /^the following orders were placed:$/
*/
public function thereAreOrders(TableNode $table)
{
$manager = $this->getEntityManager();
$finite = $this->getService('sm.factory');
$orderRepository = $this->getRepository('order');
$shipmentProcessor = $this->getService('sylius.processor.shipment_processor');
/** @var $paymentMethod PaymentMethodInterface */
$paymentMethod = $this->getRepository('payment_method')->createNew();
$paymentMethod->setName('Stripe');
$paymentMethod->setGateway('stripe');
$manager->persist($paymentMethod);
$currentOrderNumber = 1;
foreach ($table->getHash() as $data) {
$address = $this->createAddress($data['address']);
/* @var $order OrderInterface */
$order = $orderRepository->createNew();
$order->setShippingAddress($address);
$order->setBillingAddress($address);
$order->setUser($this->thereIsUser($data['user'], 'sylius'));
if (isset($data['shipment']) && '' !== trim($data['shipment'])) {
$order->addShipment($this->createShipment($data['shipment']));
}
$order->setNumber(str_pad($currentOrderNumber, 9, 0, STR_PAD_LEFT));
$finite->get($order, OrderTransitions::GRAPH)->apply(OrderTransitions::SYLIUS_CREATE);
$this->createPayment($order, $paymentMethod);
$order->setCurrency('EUR');
$order->complete();
$shipmentProcessor->updateShipmentStates($order->getShipments(), ShipmentTransitions::SYLIUS_PREPARE);
$manager->persist($order);
$this->orders[$order->getNumber()] = $order;
++$currentOrderNumber;
}
$manager->flush();
}
/**
* @Given /^order #(\d+) has following items:$/
*/
public function orderHasFollowingItems($number, TableNode $items)
{
$manager = $this->getEntityManager();
$orderItemRepository = $this->getRepository('order_item');
$order = $this->orders[$number];
foreach ($items->getHash() as $data) {
$product = $this->findOneByName('product', trim($data['product']));
/* @var $item OrderItemInterface */
$item = $orderItemRepository->createNew();
$item->setVariant($product->getMasterVariant());
$item->setUnitPrice($product->getMasterVariant()->getPrice());
$item->setQuantity($data['quantity']);
$order->addItem($item);
}
$order->calculateTotal();
$order->complete();
$this->getService('sylius.order_processing.payment_processor')->createPayment($order);
$this->getService('event_dispatcher')->dispatch(SyliusCartEvents::CART_CHANGE, new GenericEvent($order));
$manager->persist($order);
$manager->flush();
}
/**
* @Given /^there are groups:$/
* @Given /^there are following groups:$/
* @Given /^the following groups exist:$/
*/
public function thereAreGroups(TableNode $table)
{
$manager = $this->getEntityManager();
$repository = $this->getRepository('group');
foreach ($table->getHash() as $data) {
$group = $repository->createNew();
$group->setName(trim($data['name']));
$roles = explode(',', $data['roles']);
$roles = array_map('trim', $roles);
$group->setRoles($roles);
$manager->persist($group);
}
$manager->flush();
}
/**
* @Given /^the following addresses exist:$/
*/
public function theFollowingAddressesExist(TableNode $table)
{
$manager = $this->getEntityManager();
foreach ($table->getHash() as $data) {
$address = $this->createAddress($data['address']);
$user = $this->thereIsUser($data['user'], 'sylius', null, 'yes', null, array(), false);
$user->addAddress($address);
$manager->persist($address);
$manager->persist($user);
}
$manager->flush();
}
/**
* @Given /^product "([^""]*)" has the following volume based pricing:$/
*/
public function productHasTheFollowingVolumeBasedPricing($productName, TableNode $table)
{
/* @var $product ProductInterface */
$product = $this->findOneByName('product', $productName);
$masterVariant = $product->getMasterVariant();
/* @var $masterVariant ProductVariantInterface */
$masterVariant->setPricingCalculator(PriceCalculators::VOLUME_BASED);
$configuration = array();
foreach ($table->getHash() as $data) {
if (false !== strpos($data['range'], '+')) {
$min = null;
$max = (int) trim(str_replace('+', '', $data['range']));
} else {
list($min, $max) = array_map(function ($value) { return (int) trim($value); }, explode('-', $data['range']));
}
$configuration[] = array(
'min' => $min,
'max' => $max,
'price' => (int) $data['price'] * 100
);
}
$masterVariant->setPricingConfiguration($configuration);
$manager = $this->getEntityManager();
$manager->persist($product);
$manager->flush();
}
/**
* @Given /^product "([^""]*)" has the following group based pricing:$/
*/
public function productHasTheFollowingGroupBasedPricing($productName, TableNode $table)
{
$product = $this->findOneByName('product', $productName);
$masterVariant = $product->getMasterVariant();
/* @var $masterVariant ProductVariantInterface */
$masterVariant->setPricingCalculator(PriceCalculators::GROUP_BASED);
$configuration = array();
foreach ($table->getHash() as $data) {
$group = $this->findOneByName('group', trim($data['group']));
$configuration[$group->getId()] = (float) $data['price'] * 100;
}
$masterVariant->setPricingConfiguration($configuration);
$manager = $this->getEntityManager();
$manager->persist($product);
$manager->flush();
}
/**
* @Given /^there are following tax rates:$/
* @Given /^the following tax rates exist:$/
*/
public function thereAreTaxRates(TableNode $table)
{
foreach ($table->getHash() as $data) {
$this->thereIsTaxRate($data['amount'], $data['name'], $data['category'], $data['zone'], isset($data['included in price?']) ? $data['included in price?'] : false, false);
}
$this->getEntityManager()->flush();
}
/**
* @Given /^there is (\d+)% tax "([^""]*)" for category "([^""]*)" within zone "([^""]*)"$/
* @Given /^I created (\d+)% tax "([^""]*)" for category "([^""]*)" within zone "([^""]*)"$/
*/
public function thereIsTaxRate($amount, $name, $category, $zone, $includedInPrice = false, $flush = true)
{
/* @var $rate TaxRateInterface */
$rate = $this->getRepository('tax_rate')->createNew();
$rate->setName($name);
$rate->setAmount($amount / 100);
$rate->setIncludedInPrice($includedInPrice);
$rate->setCategory($this->findOneByName('tax_category', $category));
$rate->setZone($this->findOneByName('zone', $zone));
$rate->setCalculator('default');
$manager = $this->getEntityManager();
$manager->persist($rate);
if ($flush) {
$manager->flush();
}
return $rate;
}
/**
* @Given /^the following shipping methods are configured:$/
* @Given /^the following shipping methods exist:$/
* @Given /^there are shipping methods:$/
*/
public function thereAreShippingMethods(TableNode $table)
{
foreach ($table->getHash() as $data) {
$calculator = array_key_exists('calculator', $data) ? str_replace(' ', '_', strtolower($data['calculator'])) : DefaultCalculators::PER_ITEM_RATE;
$configuration = array_key_exists('configuration', $data) ? $this->getConfiguration($data['configuration']) : null;
if (!isset($data['enabled'])) {
$data['enabled'] = 'yes';
}
$this->thereIsShippingMethod($data['name'], $data['zone'], $calculator, $configuration, 'yes' === $data['enabled'], false);
}
$this->getEntityManager()->flush();
}
/**
* @Given /^I created shipping method "([^""]*)" within zone "([^""]*)"$/
* @Given /^There is shipping method "([^""]*)" within zone "([^""]*)"$/
*/
public function thereIsShippingMethod($name, $zoneName, $calculator = DefaultCalculators::PER_ITEM_RATE, array $configuration = null, $enabled = true, $flush = true)
{
/* @var $method ShippingMethodInterface */
$method = $this
->getRepository('shipping_method')
->createNew()
;
$method->setName($name);
$method->setZone($this->findOneByName('zone', $zoneName));
$method->setCalculator($calculator);
$method->setConfiguration($configuration ?: array('amount' => 2500));
$method->setEnabled($enabled);
$manager = $this->getEntityManager();
$manager->persist($method);
if ($flush) {
$manager->flush();
}
return $method;
}
/**
* @Given /^the following locales are defined:$/
* @Given /^there are following locales configured:$/
*/
public function thereAreLocales(TableNode $table)
{
$repository = $this->getRepository('locale');
$manager = $this->getEntityManager();
foreach ($table->getHash() as $data) {
$locale = $repository->createNew();
$locale->setCode($data['code']);
if (isset($data['enabled'])) {
$locale->setEnabled('yes' === $data['enabled']);
}
$manager->persist($locale);
}
$manager->flush();
}
/**
* @Given /^product "([^""]*)" is available in all variations$/
*/
public function productIsAvailableInAllVariations($productName)
{
$product = $this->findOneByName('product', $productName);
$this->getService('sylius.generator.product_variant')->generate($product);
/* @var $variant ProductVariantInterface */
foreach ($product->getVariants() as $variant) {
$variant->setPrice($product->getMasterVariant()->getPrice());
}
$manager = $this->getEntityManager();
$manager->persist($product);
$manager->flush();
}
/**
* Create an address instance from string.
*
* @param string $string
*
* @return AddressInterface
*/
private function createAddress($string)
{
$addressData = explode(',', $string);
$addressData = array_map('trim', $addressData);
list($firstname, $lastname) = explode(' ', $addressData[0]);
/* @var $address AddressInterface */
$address = $this->getRepository('address')->createNew();
$address->setFirstname(trim($firstname));
$address->setLastname(trim($lastname));
$address->setStreet($addressData[1]);
$address->setPostcode($addressData[2]);
$address->setCity($addressData[3]);
$address->setCountry($this->findOneByName('country', $addressData[4]));
return $address;
}
/**
* Create an payment instance.
*
* @param OrderInterface $order
* @param PaymentMethodInterface $method
*/
private function createPayment(OrderInterface $order, PaymentMethodInterface $method)
{
/** @var $payment PaymentInterface */
$payment = $this->getRepository('payment')->createNew();
$payment->setOrder($order);
$payment->setMethod($method);
$payment->setAmount($order->getTotal());
$payment->setCurrency($order->getCurrency() ?: 'EUR');
$payment->setState(PaymentInterface::STATE_COMPLETED);
$order->addPayment($payment);
}
/**
* Create an shipment instance from string.
*
* @param string $string
*
* @return ShipmentInterface
*/
private function createShipment($string)
{
$shipmentData = explode(',', $string);
$shipmentData = array_map('trim', $shipmentData);
/* @var $shippingMethod ShippingMethodInterface */
$shippingMethod = $this->getRepository('shipping_method')->findOneBy(array('name' => $shipmentData[0]));
/* @var $shipment ShipmentInterface */
$shipment = $this->getRepository('shipment')->createNew();
$shipment->setMethod($shippingMethod);
if (isset($shipmentData[1])) {
$shipment->setState($shipmentData[1]);
}
if (isset($shipmentData[2])) {
$shipment->setTracking($shipmentData[2]);
}
return $shipment;
}
/**
* @Given /^I am logged in as administrator$/
*/
public function iAmLoggedInAsAdministrator()
{
$this->iAmLoggedInAsRole('ROLE_ADMIN');
}
/**
* @Given /^I am logged in student/
* @Given /^I am logged in as student "([^""]*)"$/
*/
public function iAmLoggedInStudent($email = 'student@example.com')
{
$this->iAmLoggedInAsRole(
'ROLE_USER',
'student',
$email,
'student',
'yes',
null,
array('students')
);
}
/**
* @Given /^I am logged in teacher/
* @Given /^I am logged in as teacher "([^""]*)"$/
*/
public function iAmLoggedInTeacher($email = 'teacher@example.com')
{
$this->iAmLoggedInAsRole(
'ROLE_USER',
'teacher',
$email,
'teacher',
'yes',
null,
array('teachers')
);
}
/**
* @Given /^I am logged in user$/
* @Given /^I am logged in as user "([^""]*)"$/
*/
public function iAmLoggedInUser($email = 'user@example.com')
{
$this->iAmLoggedInAsRole('ROLE_USER', 'user', $email, 'user', 'yes');
}
/**
* @Given /^I am not logged in$/
*/
public function iAmNotLoggedIn()
{
$this->getSession()->visit($this->generatePageUrl('fos_user_security_logout'));
}
/**
* @Given /^there are following users:$/
*/
public function thereAreFollowingUsers(TableNode $table)
{
foreach ($table->getHash() as $data) {
$this->thereIsUser(
$data['username'],
$data['email'],
isset($data['plain_password']) ? $data['plain_password'] : $this->faker->word(),
'ROLE_USER',
isset($data['enabled']) ? $data['enabled'] : true,
isset($data['address']) && !empty($data['address']) ? $data['address'] : null,
isset($data['groups']) && !empty($data['groups']) ? explode(',', $data['groups']) : array(),
false
);
}
$this->getEntityManager()->flush();
}
/**
* Create user and login with given role.
*
* @param string $role
* @param string $username
* @param string $email
* @param string $password
* @param string $enabled
* @param string $address
* @param array $groups
*/
private function iAmLoggedInAsRole(
$role,
$username = 'chamilo',
$email = 'chamilo@example.com',
$password = 'chamilo',
$enabled = 'yes',
$address = null,
$groups = array()
) {
$this->thereIsUser($username, $email, $password, $role, $enabled, $address, $groups);
$this->getSession()->visit($this->generatePageUrl('fos_user_security_login'));
$this->fillField('_username', $email);
$this->fillField('_password', $password);
$this->pressButton('login');
}
/**
* @param string $username
* @param string $email
* @param string $password
* @param string $role
* @param string $enabled
* @param string $address
* @param array $groups
* @param bool $flush
* @return User|\FOS\UserBundle\Model\UserInterface|object
*/
public function thereIsUser(
$username,
$email,
$password,
$role = null,
$enabled = 'yes',
$address = null,
$groups = array(),
$flush = true
) {
$userManager = $this->getUserManager();
$groupManager = $this->getGroupManager();
if (null === $user = $userManager->findOneBy(array('email' => $email))) {
/** @var User $user */
$user = $userManager->createUser();
$user->setUsername($username);
$user->setFirstname($this->faker->firstName);
$user->setLastname($this->faker->lastName);
//$user->setFirstname(null === $address ? $this->faker->firstName : $addressData[0]);
//$user->setLastname(null === $address ? $this->faker->lastName : $addressData[1]);
$user->setEmail($email);
$user->setEnabled('yes' === $enabled);
$user->setPlainPassword($password);
$user->setLocked(false);
if (null !== $role) {
$user->addRole($role);
}
if (!empty($groups)) {
foreach ($groups as $groupName) {
if ($group = $groupManager->findGroupByName($groupName)) {
$user->addGroup($group);
}
}
}
$this->getEntityManager()->persist($user);
if ($flush) {
$this->getEntityManager()->flush();
}
}
return $user;
}
/**
* @Given I am a student
*/
public function iAmAStudent()
{
$this->thereIsUser(
'student',
'student@example.org',
'student',
'ROLE_USER',
'yes',
null,
array('students')
);
}
/**
* @Given I am an administrator
*/
public function iAmAnAdministrator()
{
$this->thereIsUser(
'admin',
'admin@example.org',
'admin',
'ROLE_ADMIN',
'yes',
null,
array('admins')
);
}
}

@ -39,26 +39,6 @@ class CourseContext extends DefaultContext implements Context, SnippetAcceptingC
{
}
/**
* @Given there are following users:
*/
public function thereAreFollowingUsers(TableNode $userTable)
{
$userManager = $this->getContainer()->get('fos_user.user_manager');
$em = $this->getEntityManager();
foreach ($userTable as $userHash) {
$user = $userManager->createUser();
$user->setUsername($userHash['username']);
$user->setEmail($userHash['email']);
$user->setPlainPassword($userHash['plain_password']);
$user->setEnabled(true);
$user->setLocked(false);
$em->persist($user);
}
$em->flush();
}
/**
* @Given I have a course :arg1
*/
@ -140,7 +120,7 @@ class CourseContext extends DefaultContext implements Context, SnippetAcceptingC
*/
public function iAddUserToCourse($username, $courseTitle)
{
$user = $this->getContainer()->get('fos_user.user_manager')->findUserByUsername($username);
$user = $this->getUserManager()->findUserByUsername($username);
/** @var Course $course */
$course = $this->getContainer()->get('chamilo_core.manager.course')->findOneByTitle($courseTitle);
@ -157,7 +137,7 @@ class CourseContext extends DefaultContext implements Context, SnippetAcceptingC
*/
public function iAddTeacherToCourse($username, $courseTitle)
{
$user = $this->getContainer()->get('fos_user.user_manager')->findUserByUsername($username);
$user = $this->getUserManager()->findUserByUsername($username);
/** @var Course $course */
$course = $this->getContainer()->get('chamilo_core.manager.course')->findOneByTitle($courseTitle);
@ -174,7 +154,7 @@ class CourseContext extends DefaultContext implements Context, SnippetAcceptingC
*/
public function iAddStudentToCourse($username, $courseTitle)
{
$user = $this->getContainer()->get('fos_user.user_manager')->findUserByUsername($username);
$user = $this->getUserManager()->findUserByUsername($username);
/** @var Course $course */
$course = $this->getContainer()->get('chamilo_core.manager.course')->findOneByTitle($courseTitle);
@ -242,24 +222,4 @@ class CourseContext extends DefaultContext implements Context, SnippetAcceptingC
PHPUnit_Framework_TestCase::assertTrue($found);
}
/**
* @return \Doctrine\Common\Persistence\ObjectManager|object
*/
public function getEntityManager()
{
return $this->getContainer()->get('doctrine')->getManager();
}
/**
* Returns the Doctrine repository manager for a given entity.
*
* @param string $entityName The name of the entity.
*
* @return EntityRepository
*/
protected function getRepository($entityName)
{
return $this->getEntityManager()->getRepository($entityName);
}
}

@ -15,11 +15,16 @@ use Doctrine\Common\Persistence\ObjectManager;
use Faker\Factory as FakerFactory;
use Faker\Generator;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\ConsoleOutput;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Sylius\Bundle\ResourceBundle\Behat\DefaultContext as BaseDefaultContext;
use Symfony\Bundle\FrameworkBundle\Console\Application;
/**
* Class DefaultContext
@ -70,18 +75,38 @@ abstract class DefaultContext extends BaseDefaultContext
*/
public function purgeDatabase(BeforeScenarioScope $scope)
{
$entityManager = $this->getService('doctrine.orm.entity_manager');
//$output = new ConsoleOutput();
/*$generator = $this->getContainer()->get('sonata.page.route.page.generator');
$siteManager = $this->getContainer()->get('sonata.page.manager.site');
$defaultSite = $siteManager->find(1);
$generator->update($defaultSite, $output);*/
/*$entityManager = $this->getService('doctrine.orm.entity_manager');
$entityManager->getConnection()->executeUpdate("SET foreign_key_checks = 0;");
$purger = new ORMPurger($entityManager);
$purger->purge();
$entityManager->getConnection()->executeUpdate("SET foreign_key_checks = 1;");
$entityManager->getConnection()->executeUpdate("SET foreign_key_checks = 1;");*/
}
/** @BeforeFeature */
/**
* @BeforeFeature
*/
public static function setupFeature(BeforeFeatureScope $event)
{
//
// $output = new ConsoleOutput();
//
// $generator = self::getContainer()->get('sonata.page.route.page.generator');
// $siteManager = self::getContainer()->get('sonata.page.manager.site');
//
// $defaultSite = $siteManager->find(1);
//
// $generator->update($defaultSite, $output);
}
@ -131,10 +156,10 @@ abstract class DefaultContext extends BaseDefaultContext
*
* @return RepositoryInterface
*/
protected function getRepository($resource)
/*protected function getRepository($resource)
{
return $this->getService('sylius.repository.'.$resource);
}
}*/
/**
* Get entity manager.
@ -324,4 +349,33 @@ abstract class DefaultContext extends BaseDefaultContext
{
return str_replace('\\"', '"', $argument);
}
/**
* @return \Sonata\UserBundle\Entity\UserManager
*/
public function getUserManager()
{
return $this->getContainer()->get('fos_user.user_manager');
}
/**
* @return \Sonata\UserBundle\Entity\GroupManager
*/
public function getGroupManager()
{
return $this->getContainer()->get('fos_user.group_manager');
}
/**
* Returns the Doctrine repository manager for a given entity.
*
* @param string $entityName The name of the entity.
*
* @return EntityRepository
*/
protected function getRepository($entityName)
{
return $this->getEntityManager()->getRepository($entityName);
}
}

@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CoreBundle\Behat;
use Behat\Mink\Exception\ExpectationException;
use Behat\MinkExtension\Context\MinkContext;
use Behat\Gherkin\Node\TableNode;
/**
* Class LoginContext
*/
class LoginContext extends MinkContext
{
/**
* First, force logout, then go to the login page, fill the informations and finally go to requested page
*
* @Given /^I am connected with "([^"]*)" and "([^"]*)" on "([^"]*)"$/
*
* @param string $login
* @param string $rawPassword
* @param string $url
*/
public function iAmConnectedWithOn($login, $rawPassword, $url)
{
$this->visit('logout');
$this->visit('login');
$this->fillField('_username', $login);
$this->fillField('_password', $rawPassword);
$this->pressButton('Login');
$this->visit($url);
}
}

@ -16,6 +16,7 @@ use Chamilo\CoreBundle\Entity\SessionRelCourse;
use Chamilo\UserBundle\Entity\User;
use Doctrine\ORM\EntityRepository;
use PHPUnit_Framework_TestCase;
use Chamilo\CoreBundle\Behat\DefaultContext;
/**

Loading…
Cancel
Save