Добрый день!
Изучаю Yii2 по книге “Web Application Development with Yii 2”.
“Codeception” не может найти класс.
Вот что я сделал:
- $ php composer.phar require “codeception/codeception:*”
- В конфиг прописал сайт
config:
PhpBrowser:
url: ‘http://site’
- $ php composer.phar require “fzaninotto/faker:*”
- $ cept generate:cept acceptance QueryCustomerByPhoneNumber
<?php $I = new \AcceptanceTester\CRMOperatorSteps($scenario); $I->wantTo('add two different customers to database');
$I->amInAddCustomerUi();
$first_customer = $I->imagineCustomer();
$I->fillCustomerDataForm($first_customer);
$I->submitCustomerDataForm();
$I->seeIAmInListCustomersUi();
$I->amInAddCustomerUi();
$second_customer = $I->imagineCustomer();
$I->fillCustomerDataForm($second_customer);
$I->submitCustomerDataForm();
$I->seeIAmInListCustomersUi();
//$I = new \AcceptanceTester\CRMUserSteps($scenario);
$I = new CRMUserSteps($scenario);
$I->wantTo(‘query the customer info using his phone number’);
$I->amInQueryCustomerUi();
$I->fillInPhoneFieldWithDataForm($first_customer);
$I->clickSearchButton();
$I->seeIAmInListCustomersUi();
$I->seeCustomerInList($first_customer);
$I->dontSeeCustomerInList($second_customer);
- $ cept generate:stepobject acceptance CRMOperatorSteps
<?php namespace Step\Acceptance;
class CRMOperatorSteps extends \AcceptanceTester
{
public function amInAddCustomerUi()
{
$I = $this;
$I->amOnPage(‘/customers/add’);
}
public function imagineCustomer()
{
$faker = \Faker\Factory::create();
return [
‘CustomerRecord[name]’ => $faker->name,
‘CustomerRecord[birth_date]’ => $faker->date(‘Y-m-d’),
‘CustomerRecord[notes]’ => $faker->sentence(8),
‘PhoneRecord[number]’ => $faker->phoneNumber
];
}
public function fillCustomerDataForm($fieldData)
{
$I = $this;
foreach ($fieldData as $key => $value) {
$I->fillField($key, $value);
}
}
public function submitCustomerDataForm()
{
$I = $this;
$I->click(‘Submit’);
}
public function seeIAmInListCustomersUi()
{
$I = $this;
$I->seeCurrentUrlMatches(‘/customers/’);
}
public function amInListCustomersUi()
{
$I = $this;
$I->amOnPage(‘/customers/’);
}
}
- $ cept generate:stepobject acceptance CRMUserSteps
<?php namespace Step\Acceptance;
class CRMUserSteps extends \AcceptanceTester
{
public function amInQueryCustomerUi()
{
$I = $this;
$I->amOnPage(‘/customers/query’);
}
public function fillInPhoneFieldWithDataFrom($customer_data)
{
$I = $this;
$I->fillField(‘PhoneRecord[number]’, $customer_data[‘PhoneRecord[number]’]);
}
public function clickSearchButton()
{
$I = $this;
$I->click(‘Search’);
}
public function seeIAmInListCustomersUi()
{
$I = $this;
$->seeCurrentUrlMatches(‘/customers/’);
}
public function seeCustomerInList($customer_data)
{
$I = $this;
$I->see($customer_data[‘CustomerRecord[name]’], ‘#search_results’);
}
public function dontSeeCustomerInList($customer_data)
{
$I = $this;
$I->dontSee($customer_date[‘CustomerRecord[name]’], ‘#search_results’);
}
}
- $ cept build
- $ cept run
Error:
Acceptance Tests (2) --------------------------------------------------------------------------------------------------------------------
Trying to add two different customers to database (QueryCustomerByPhoneNumberCept)… PHP Fatal error: Class ‘AcceptanceTester\CRMOperatorSteps’ not found in /home/m/magvan/crmapp/tests/acceptance/QueryCustomerByPhoneNumberCept.php on line 2
FATAL ERROR. TESTS NOT FINISHED.
Class ‘AcceptanceTester\CRMOperatorSteps’ not found
in /home/m/magvan/crmapp/tests/acceptance/QueryCustomerByPhoneNumberCept.php:2
При запуске теста выдает ошибку. Подскажите, пожалуйста, куда копать =)