3 namespace tests\unit\models;
7 class StatusTest extends \Codeception\Test\Unit
15 protected function _before()
20 protected function _after()
25 public function testEnterNull()
27 $this->model = new Status();
29 // Пустое значение недопустимо
30 $this->model->name = NULL;
31 $this->assertFalse($this->model->validate([ 'name' ]));
34 public function testEnterLong()
36 $this->model = new Status();
38 // Больше 100 символов недопустимо
39 $this->model->name = '**** aaaaabbbbbcccccdddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooopppppqqqqqrrrrrsssss ****';
40 $this->assertFalse($this->model->validate([ 'name' ]));
43 public function testEnterData()
45 $this->model = new Status();
47 $validName = '--TEST STATUS--';
48 // Допустимая комбинация
49 $this->model->name = $validName;
50 $this->assertTrue($this->model->validate([ 'name' ]));
52 // Сохранение данных в базу
53 $this->assertTrue($this->model->save());
54 $count = count(Status::find()->where([ 'name' => $validName ])->all());
55 $this->assertGreaterThan(0, $count);
56 $this->assertEquals(1, $count);