Пытаюсь освоить codeception.
Есть у меня проект на Yii2.
Есть модуль modules\sh. Там такая структура:
modules
-- sh
---- Module.php
---- controllers
---- modules
---- views
---- entities
------ hobby
-------- Hobby.php
---- codeception.yml
---- tests
------ unit
-------- entities
---------- hobby
------------ HobbyTest.php
Содержимое класса HobbyTest.php:
PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- <?PHP
- namespace app\modules\sh\tests\unit\entities\hobby;
- use app\modules\sh\entities\hobby\Hobby;
- use Codeception\Test\Unit;
- class HobbyTest extends Unit {
- /**
- * @var \UnitTester
- */
- protected $tester;
- protected $id = 5;
- protected $title = 'test';
- protected $sex = 'male';
- protected $sort = 1;
- protected function _before() {
- }
- protected function _after() {
- }
- // tests
- public function testCreate() {
- $hobby = new \app\modules\sh\entities\hobby\Hobby(
- $this->id,
- $this->title,
- $this->sex,
- $this->sort
- );
- $this->assertEquals($this->id, $hobby->getId());
- $this->assertEquals($this->title, $hobby->getTitle());
- $this->assertEquals($this->sex, $hobby->getSex());
- $this->assertEquals($this->sort, $hobby->getSort());
- }
- }