3 namespace tests\unit\models;
7 class TypesTest extends \Codeception\Test\Unit
15 protected function _before()
17 $this->types = new Types();
20 protected function _after()
24 public function testEnterNull()
26 // Пустое значение недопустимо
27 $this->types->name = NULL;
28 $this->assertFalse($this->types->validate([ 'name' ]));
31 public function testEnterAbove100()
33 // Больше 100 символов недопустимо
34 $this->types->name = '**** ' . str_repeat('a', 100) . ' ****';
35 $this->assertFalse($this->types->validate([ 'name' ]));
39 public function testEnterData()
41 $validName = '--TEST TYPE--';
42 // Допустимая комбинация
43 $this->types->name = $validName;
44 $this->assertTrue($this->types->validate([ 'name' ]));
46 // Сохранение данных в базу
47 $this->assertTrue($this->types->save());
48 $count = count(Types::find()->where([ 'name' => $validName ])->all());
49 $this->assertGreaterThan(0, $count);
50 $this->assertEquals(1, $count);
51 # $this->tester->seeInDatabase('types', [ 'name' => $validName ]); // ищет в реальной базе данных, а не в тестовой.