コミットメタ情報

リビジョン1f27e48df6c77321106dea8dee25607290e37a4b (tree)
日時2020-11-24 14:06:29
作者Dmitry Dobryshin <dimkainc@mail...>
コミッターDmitry Dobryshin

ログメッセージ

Изменён тест модели типов. Добавлен тест модели состояний.

変更サマリ

差分

--- /dev/null
+++ b/tests/unit/models/StatusTest.php
@@ -0,0 +1,58 @@
1+<?php
2+
3+namespace tests\unit\models;
4+
5+use app\models\Status;
6+
7+class StatusTest extends \Codeception\Test\Unit
8+{
9+ private $model;
10+ /**
11+ * @var \UnitTester
12+ */
13+ protected $tester;
14+
15+ protected function _before()
16+ {
17+
18+ }
19+
20+ protected function _after()
21+ {
22+ }
23+
24+ // tests
25+ public function testEnterNull()
26+ {
27+ $this->model = new Status();
28+
29+ // Пустое значение недопустимо
30+ $this->model->name = NULL;
31+ $this->assertFalse($this->model->validate([ 'name' ]));
32+ }
33+
34+ public function testEnterLong()
35+ {
36+ $this->model = new Status();
37+
38+ // Больше 100 символов недопустимо
39+ $this->model->name = '**** aaaaabbbbbcccccdddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooopppppqqqqqrrrrrsssss ****';
40+ $this->assertFalse($this->model->validate([ 'name' ]));
41+ }
42+
43+ public function testEnterData()
44+ {
45+ $this->model = new Status();
46+
47+ $validName = '--TEST STATUS--';
48+ // Допустимая комбинация
49+ $this->model->name = $validName;
50+ $this->assertTrue($this->model->validate([ 'name' ]));
51+
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);
57+ }
58+}
\ No newline at end of file
--- a/tests/unit/models/TypesTest.php
+++ b/tests/unit/models/TypesTest.php
@@ -2,7 +2,6 @@
22
33 namespace tests\unit\models;
44
5-use app\models\LoginForm;
65 use app\models\Types;
76
87 class TypesTest extends \Codeception\Test\Unit
@@ -20,21 +19,30 @@ class TypesTest extends \Codeception\Test\Unit
2019
2120 protected function _after()
2221 {
23- \Yii::$app->user->logout();
2422 }
2523
26- // tests
27- public function testEnterType()
24+ public function testEnterNull()
2825 {
2926 $this->types = new Types();
30-
27+
3128 // Пустое значение недопустимо
3229 $this->types->name = NULL;
3330 $this->assertFalse($this->types->validate([ 'name' ]));
34-
31+ }
32+
33+ public function testEnterLong()
34+ {
35+ $this->types = new Types();
36+
3537 // Больше 100 символов недопустимо
3638 $this->types->name = '**** aaaaabbbbbcccccdddddeeeeefffffggggghhhhhiiiiijjjjjkkkkklllllmmmmmnnnnnooooopppppqqqqqrrrrrsssss ****';
3739 $this->assertFalse($this->types->validate([ 'name' ]));
40+ }
41+
42+ // tests
43+ public function testEnterData()
44+ {
45+ $this->types = new Types();
3846
3947 $validName = '--TEST TYPE--';
4048 // Допустимая комбинация
旧リポジトリブラウザで表示