diff --git a/README.md b/README.md index 5ebcdbed7..bd235b79d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Agile Data is a framework for defining your "business layer" which is separate f - Agile Data is high-performance, capable of abstracting aggregation logic and shifting it into a capable database persistence (such as SQL) through advanced expressions. - Agile Data is extensible - field types, persistence types, relations and action types can be extended. -![Build](https://github.com/atk4/data/workflows/Unit%20Testing/badge.svg) +![Build](https://github.com/atk4/data/workflows/Unit/badge.svg) [![CodeCov](https://codecov.io/gh/atk4/data/branch/develop/graph/badge.svg)](https://codecov.io/gh/atk4/data) [![GitHub release](https://img.shields.io/github/release/atk4/data.svg)](CHANGELOG.md) [![Code Climate](https://codeclimate.com/github/atk4/data/badges/gpa.svg)](https://codeclimate.com/github/atk4/data) diff --git a/src/Persistence/Sql/Connection.php b/src/Persistence/Sql/Connection.php index aceb6b57e..29b8bd9d4 100644 --- a/src/Persistence/Sql/Connection.php +++ b/src/Persistence/Sql/Connection.php @@ -88,10 +88,10 @@ public static function normalizeDsn($dsn, $user = null, $password = null) $dsn['dsn'] = str_replace('-', '_', $parsed['scheme']) . ':'; unset($parsed['scheme']); foreach ($parsed as $k => $v) { - if ($k === 'pass') { // @phpstan-ignore-line phpstan bug + if ($k === 'pass') { unset($parsed[$k]); $k = 'password'; - } elseif ($k === 'path') { // @phpstan-ignore-line phpstan bug + } elseif ($k === 'path') { unset($parsed[$k]); $k = 'dbname'; $v = preg_replace('~^/~', '', $v); diff --git a/src/Schema/TestCase.php b/src/Schema/TestCase.php index a1abaec2d..a087ca254 100644 --- a/src/Schema/TestCase.php +++ b/src/Schema/TestCase.php @@ -209,7 +209,7 @@ private static function compareExportUnorderedValue($a, $b): int protected static function assertSameExportUnordered(array $expected, array $actual, string $message = ''): void { if (self::compareExportUnorderedValue($expected, $actual) === 0) { - static::assertTrue(true); + static::assertTrue(true); // @phpstan-ignore-line return; } diff --git a/tests/BusinessModelTest.php b/tests/BusinessModelTest.php index bd9106dd0..eb1bad2b9 100644 --- a/tests/BusinessModelTest.php +++ b/tests/BusinessModelTest.php @@ -130,8 +130,6 @@ public function testDefaultInit(): void $m = new Model($p); $m = $m->createEntity(); - static::assertNotNull($m->getField('id')); - $m->set('id', 20); static::assertSame(20, $m->getId()); } diff --git a/tests/ContainsManyTest.php b/tests/ContainsManyTest.php index 718ccf04c..e00303318 100644 --- a/tests/ContainsManyTest.php +++ b/tests/ContainsManyTest.php @@ -75,7 +75,6 @@ public function testContainsMany(): void // now let's add some lines $l = $i->lines; - static::assertNotNull($l); $rows = [ 1 => [ $l->fieldName()->id => 1, diff --git a/tests/ContainsOneTest.php b/tests/ContainsOneTest.php index c4879db65..97e66ada0 100644 --- a/tests/ContainsOneTest.php +++ b/tests/ContainsOneTest.php @@ -73,7 +73,7 @@ public function testContainsOne(): void static::assertSame(Address::class, get_class($i->getModel()->addr)); // check do we have address set - static::assertNull($i->addr); + static::assertNull($i->addr); // @phpstan-ignore-line $a = $i->getModel()->addr->createEntity(); $a->containedInEntity = $i; @@ -150,12 +150,12 @@ public function testContainsOne(): void // so far so good. now let's try to delete door_code $i->addr->door_code->delete(); static::assertNull($i->addr->get($i->addr->fieldName()->door_code)); - static::assertNull($i->addr->door_code); + static::assertNull($i->addr->door_code); // @phpstan-ignore-line // and now delete address $i->addr->delete(); static::assertNull($i->get($i->fieldName()->addr)); - static::assertNull($i->addr); + static::assertNull($i->addr); // @phpstan-ignore-line } /** @@ -167,7 +167,7 @@ public function testContainsOneWhenChangeModelFields(): void $i = $i->loadBy($i->fieldName()->ref_no, 'A1'); // with address - static::assertNull($i->addr); + static::assertNull($i->addr); // @phpstan-ignore-line $a = $i->getModel()->addr->createEntity(); $a->containedInEntity = $i; $a->setMulti($row = [ diff --git a/tests/Field/PasswordFieldTest.php b/tests/Field/PasswordFieldTest.php index 38284a348..3459cf8ca 100644 --- a/tests/Field/PasswordFieldTest.php +++ b/tests/Field/PasswordFieldTest.php @@ -111,11 +111,9 @@ public function testGeneratePassword(): void $field = new PasswordField(); $pwd = $field->generatePassword(); - static::assertIsString($pwd); static::assertSame(8, strlen($pwd)); $pwd = $field->generatePassword(50); - static::assertIsString($pwd); static::assertSame(50, strlen($pwd)); } } diff --git a/tests/Persistence/Sql/ConnectionTest.php b/tests/Persistence/Sql/ConnectionTest.php index 7bf663a61..42f939b9f 100644 --- a/tests/Persistence/Sql/ConnectionTest.php +++ b/tests/Persistence/Sql/ConnectionTest.php @@ -133,7 +133,7 @@ public function testConnectionRegistry(): void static::assertSame(DummyConnection::class, Connection::resolveConnectionClass('dummy')); try { Connection::resolveConnectionClass('dummy2'); - static::assertFalse(true); + static::assertFalse(true); // @phpstan-ignore-line } catch (\Exception $e) { } diff --git a/tests/UserActionTest.php b/tests/UserActionTest.php index b902f2960..25f75dd86 100644 --- a/tests/UserActionTest.php +++ b/tests/UserActionTest.php @@ -185,25 +185,17 @@ public function testDisabled2(): void $client = new UaClient($this->pers); $client = $client->load(1); - $client->getUserAction('sendReminder')->enabled = function (Model $m) { - return false; + $client->getUserAction('sendReminder')->enabled = function (UaClient $m) { + return true; }; - - $this->expectExceptionMessage('disabled'); $client->getUserAction('sendReminder')->execute(); - } - - public function testDisabled3(): void - { - $client = new UaClient($this->pers); - $client = $client->load(1); $client->getUserAction('sendReminder')->enabled = function (UaClient $m) { - return true; + return false; }; + $this->expectExceptionMessage('disabled'); $client->getUserAction('sendReminder')->execute(); - static::assertTrue(true); // no exception } public function testFields(): void diff --git a/tests/ValidationTest.php b/tests/ValidationTest.php index 913179a20..724992703 100644 --- a/tests/ValidationTest.php +++ b/tests/ValidationTest.php @@ -67,7 +67,7 @@ public function testValidate1(): void $m->set('name', 'john'); $m->set('domain', 'gmail.com'); $m->save(); - static::assertTrue(true); // no exception + static::assertSame('john', $m->get('name')); } public function testValidate2(): void