Reputation: 1674
My test looks like:
<?php
namespace backend\tests\unit;
use backend\modules\crm\models\CrmClient;
class ClientTest extends \Codeception\Test\Unit
{
/**
* @var \frontend\tests\UnitTester
*/
protected $tester;
public function testClientFields()
{
$client = new CrmClient();
$client->setCompany('12345');
$this->assertTrue($client->validate(['company']));
}
}
But by typing $this->
doesn't show list of methods like assertTrue, assertFalse
e.g. Is it normal and can I make it show them ? Thank you!
Upvotes: 0
Views: 169
Reputation: 40
You need to call codeception build command, eg. ./vendor/bin/codecept build
to generate base classes for all suites. This generate helper functions with documentation in folder /tests/_support/_generated/
(basic tests folder structure).
Second solution:
Pass UnitTester
variable into function and then use it instead of $this
, eg:
public function testClientFields(UnitTester $I)
{
$client = new CrmClient();
$client->setCompany('12345');
$I->assertTrue($client->validate(['company']));
}
Upvotes: 2