From d53e2e0e4d08a063a0bed527ad1b8d2037aedbb8 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 11:16:10 +0400 Subject: [PATCH 01/14] test: wire cycle/testing and Testo Assisted-By: Claude Opus 5.5 --- composer.json | 13 ++++++++++++- testo.php | 12 ++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 testo.php diff --git a/composer.json b/composer.json index 378aadd..7a6b1d6 100644 --- a/composer.json +++ b/composer.json @@ -47,11 +47,13 @@ "bamarni/composer-bin-plugin": "^1.8", "buggregator/trap": "^1.20", "cycle/annotated": "^4.6", + "cycle/testing": "1.x-dev", "llm/skills": "^1.20", "phpunit/phpunit": "^11.5", "ramsey/uuid": "^4.9", "roxblnfk/unpoly": "^1.8", - "spiral/tokenizer": "^3.18" + "spiral/tokenizer": "^3.18", + "testo/testo": "^0.10.60" }, "autoload": { "psr-4": { @@ -63,6 +65,15 @@ "Cycle\\ORM\\Entity\\Behavior\\Tests\\": "tests/Behavior" } }, + "repositories": [ + { + "type": "path", + "url": "../../testing", + "options": { + "symlink": true + } + } + ], "config": { "sort-packages": true, "allow-plugins": { diff --git a/testo.php b/testo.php new file mode 100644 index 0000000..4a17e52 --- /dev/null +++ b/testo.php @@ -0,0 +1,12 @@ +unit('tests/Unit') + ->feature('tests/Feature', plugins: [new OrmPlugin()]) + ->regression('tests/Regression', plugins: [new OrmPlugin()]) + ->build(); From acff6ecf311f320d68387f352914a220c5bb22b3 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 11:54:10 +0400 Subject: [PATCH 02/14] test: drop the generated per-driver test stubs cycle/testing runs each Feature/Common class against every driver, so the generator of per-driver subclasses has nothing left to produce. Assisted-By: Claude Opus 5.5 --- tests/generate.php | 116 --------------------------------------------- 1 file changed, 116 deletions(-) delete mode 100644 tests/generate.php diff --git a/tests/generate.php b/tests/generate.php deleted file mode 100644 index a0e51a1..0000000 --- a/tests/generate.php +++ /dev/null @@ -1,116 +0,0 @@ - [__DIR__ . '/Behavior/Functional/Driver/Common'], - 'exclude' => [], -])); - -$databases = [ - 'sqlite' => [ - 'namespace' => 'Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\SQLite', - 'directory' => __DIR__ . '/Behavior/Functional/Driver/SQLite/', - ], - 'mysql' => [ - 'namespace' => 'Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\MySQL', - 'directory' => __DIR__ . '/Behavior/Functional/Driver/MySQL/', - ], - 'postgres' => [ - 'namespace' => 'Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Postgres', - 'directory' => __DIR__ . '/Behavior/Functional/Driver/Postgres/', - ], - 'sqlserver' => [ - 'namespace' => 'Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\SQLServer', - 'directory' => __DIR__ . '/Behavior/Functional/Driver/SQLServer/', - ], -]; - -echo "Generating test classes for all database types...\n"; - -$classes = $tokenizer - ->classLocator() - ->getClasses(\Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseTest::class); - -foreach ($classes as $class) { - foreach ($class->getMethods() as $method) { - if ($method->isAbstract()) { - echo "Skip class {$class->getName()} with abstract methods.\n"; - continue 2; - } - } - - if ( - !$class->isAbstract() - // Has abstract methods - || $class->getName() == \Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseTest::class - || $class->getName() == \Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseListenerTest::class - || $class->getName() == \Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseSchemaTest::class - ) { - continue; - } - - echo "Found {$class->getName()}\n"; - - $path = \str_replace( - [\str_replace('\\', '/', __DIR__), 'Behavior/Functional/Driver/Common/'], - '', - \str_replace('\\', '/', $class->getFileName()), - ); - - $path = \ltrim($path, '/'); - - foreach ($databases as $driver => $details) { - $filename = \sprintf('%s%s', $details['directory'], $path); - $dir = \pathinfo($filename, PATHINFO_DIRNAME); - - $namespace = \str_replace( - 'Cycle\\ORM\\Entity\\Behavior\\Tests\\Functional\\Driver\\Common', - $details['namespace'], - $class->getNamespaceName(), - ); - - if (!\is_dir($dir)) { - \mkdir($dir, recursive: true); - } - - \file_put_contents( - $filename, - \sprintf( - <<getName(), - $driver, - $class->getShortName(), - $driver, - ), - ); - } -} From 0bf1eca78e0d7f9b182bb436d37aca550617014e Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 11:54:11 +0400 Subject: [PATCH 03/14] test: convert the PHPUnit tests to Testo with Rector A mechanical pass kept apart from the harness move, so the hand-made changes review on their own. Assisted-By: Claude Opus 5.5 --- composer.json | 1 + .../Driver/Common/BaseListenerTest.php | 1 + .../Driver/Common/BaseSchemaTest.php | 1 + .../Functional/Driver/Common/BaseTest.php | 4 +- .../Driver/Common/CreatedAt/CreatedAtTest.php | 21 +-- .../Driver/Common/CreatedAt/ListenerTest.php | 13 +- .../EventListener/EventListenerTest.php | 19 +-- .../Common/EventListener/ListenerTest.php | 6 +- .../Driver/Common/Hook/HookTest.php | 28 ++-- .../Driver/Common/Hook/ListenerTest.php | 27 ++-- .../Driver/Common/Integration/BaseTest.php | 1 + .../Integration/CaseTemplate/CaseTest.php | 18 ++- .../OptimisticLock/InquiredRelationTest.php | 10 +- .../Common/OptimisticLock/ListenerTest.php | 43 +++--- .../OptimisticLock/OptimisticLockTest.php | 79 +++++------- .../Driver/Common/Schema/ErrorsTest.php | 8 +- .../Common/Schema/RegistryModifierTest.php | 95 +++++++------- .../Driver/Common/SoftDelete/ListenerTest.php | 12 +- .../Common/SoftDelete/SoftDeleteTest.php | 21 +-- .../Driver/Common/UpdatedAt/ListenerTest.php | 16 ++- .../Driver/Common/UpdatedAt/UpdatedAtTest.php | 27 ++-- .../Driver/MySQL/CreatedAt/CreatedAtTest.php | 17 --- .../Driver/MySQL/CreatedAt/ListenerTest.php | 17 --- .../MySQL/EventListener/EventListenerTest.php | 17 --- .../MySQL/EventListener/ListenerTest.php | 17 --- .../Functional/Driver/MySQL/Hook/HookTest.php | 17 --- .../Driver/MySQL/Hook/ListenerTest.php | 17 --- .../Integration/CaseTemplate/CaseTest.php | 17 --- .../OptimisticLock/InquiredRelationTest.php | 17 --- .../MySQL/OptimisticLock/ListenerTest.php | 17 --- .../OptimisticLock/OptimisticLockTest.php | 17 --- .../Driver/MySQL/Schema/ErrorsTest.php | 17 --- .../MySQL/Schema/RegistryModifierTest.php | 17 --- .../Driver/MySQL/SoftDelete/ListenerTest.php | 17 --- .../MySQL/SoftDelete/SoftDeleteTest.php | 17 --- .../Driver/MySQL/UpdatedAt/ListenerTest.php | 17 --- .../Driver/MySQL/UpdatedAt/UpdatedAtTest.php | 17 --- .../Postgres/CreatedAt/CreatedAtTest.php | 17 --- .../Postgres/CreatedAt/ListenerTest.php | 17 --- .../EventListener/EventListenerTest.php | 17 --- .../Postgres/EventListener/ListenerTest.php | 17 --- .../Driver/Postgres/Hook/HookTest.php | 17 --- .../Driver/Postgres/Hook/ListenerTest.php | 17 --- .../Integration/CaseTemplate/CaseTest.php | 17 --- .../OptimisticLock/InquiredRelationTest.php | 17 --- .../Postgres/OptimisticLock/ListenerTest.php | 17 --- .../OptimisticLock/OptimisticLockTest.php | 17 --- .../Driver/Postgres/Schema/ErrorsTest.php | 17 --- .../Postgres/Schema/RegistryModifierTest.php | 17 --- .../Postgres/SoftDelete/ListenerTest.php | 17 --- .../Postgres/SoftDelete/SoftDeleteTest.php | 17 --- .../Postgres/UpdatedAt/ListenerTest.php | 17 --- .../Postgres/UpdatedAt/UpdatedAtTest.php | 17 --- .../SQLServer/CreatedAt/CreatedAtTest.php | 17 --- .../SQLServer/CreatedAt/ListenerTest.php | 17 --- .../EventListener/EventListenerTest.php | 17 --- .../SQLServer/EventListener/ListenerTest.php | 17 --- .../Driver/SQLServer/Hook/HookTest.php | 17 --- .../Driver/SQLServer/Hook/ListenerTest.php | 17 --- .../Integration/CaseTemplate/CaseTest.php | 17 --- .../OptimisticLock/InquiredRelationTest.php | 17 --- .../SQLServer/OptimisticLock/ListenerTest.php | 17 --- .../OptimisticLock/OptimisticLockTest.php | 17 --- .../Driver/SQLServer/Schema/ErrorsTest.php | 17 --- .../SQLServer/Schema/RegistryModifierTest.php | 17 --- .../SQLServer/SoftDelete/ListenerTest.php | 17 --- .../SQLServer/SoftDelete/SoftDeleteTest.php | 17 --- .../SQLServer/UpdatedAt/ListenerTest.php | 17 --- .../SQLServer/UpdatedAt/UpdatedAtTest.php | 17 --- .../Driver/SQLite/CreatedAt/CreatedAtTest.php | 17 --- .../Driver/SQLite/CreatedAt/ListenerTest.php | 17 --- .../EventListener/EventListenerTest.php | 17 --- .../SQLite/EventListener/ListenerTest.php | 17 --- .../Driver/SQLite/Hook/HookTest.php | 17 --- .../Driver/SQLite/Hook/ListenerTest.php | 17 --- .../Integration/CaseTemplate/CaseTest.php | 17 --- .../OptimisticLock/InquiredRelationTest.php | 17 --- .../SQLite/OptimisticLock/ListenerTest.php | 17 --- .../OptimisticLock/OptimisticLockTest.php | 17 --- .../Driver/SQLite/Schema/ErrorsTest.php | 17 --- .../SQLite/Schema/RegistryModifierTest.php | 17 --- .../Driver/SQLite/SoftDelete/ListenerTest.php | 17 --- .../SQLite/SoftDelete/SoftDeleteTest.php | 17 --- .../Driver/SQLite/UpdatedAt/ListenerTest.php | 17 --- .../Driver/SQLite/UpdatedAt/UpdatedAtTest.php | 17 --- .../Unit/Schema/RegistryModifierTest.php | 122 ++++++++---------- 86 files changed, 296 insertions(+), 1365 deletions(-) delete mode 100644 tests/Behavior/Functional/Driver/MySQL/CreatedAt/CreatedAtTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/CreatedAt/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/EventListener/EventListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/EventListener/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/Hook/HookTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/Hook/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/Integration/CaseTemplate/CaseTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/OptimisticLock/InquiredRelationTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/OptimisticLock/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/OptimisticLock/OptimisticLockTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/Schema/ErrorsTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/Schema/RegistryModifierTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/SoftDelete/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/SoftDelete/SoftDeleteTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/UpdatedAt/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/MySQL/UpdatedAt/UpdatedAtTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/CreatedAt/CreatedAtTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/CreatedAt/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/EventListener/EventListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/EventListener/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/Hook/HookTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/Hook/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/Integration/CaseTemplate/CaseTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/OptimisticLock/InquiredRelationTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/OptimisticLock/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/OptimisticLock/OptimisticLockTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/Schema/ErrorsTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/Schema/RegistryModifierTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/SoftDelete/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/SoftDelete/SoftDeleteTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/UpdatedAt/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/Postgres/UpdatedAt/UpdatedAtTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/CreatedAt/CreatedAtTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/CreatedAt/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/EventListener/EventListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/EventListener/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/Hook/HookTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/Hook/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/Integration/CaseTemplate/CaseTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/OptimisticLock/InquiredRelationTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/OptimisticLock/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/OptimisticLock/OptimisticLockTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/Schema/ErrorsTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/Schema/RegistryModifierTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/SoftDelete/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/SoftDelete/SoftDeleteTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/UpdatedAt/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLServer/UpdatedAt/UpdatedAtTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/CreatedAt/CreatedAtTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/CreatedAt/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/EventListener/EventListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/EventListener/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/Hook/HookTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/Hook/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/Integration/CaseTemplate/CaseTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/OptimisticLock/InquiredRelationTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/OptimisticLock/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/OptimisticLock/OptimisticLockTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/Schema/ErrorsTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/Schema/RegistryModifierTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/SoftDelete/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/SoftDelete/SoftDeleteTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/UpdatedAt/ListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/SQLite/UpdatedAt/UpdatedAtTest.php diff --git a/composer.json b/composer.json index 7a6b1d6..09f37f6 100644 --- a/composer.json +++ b/composer.json @@ -53,6 +53,7 @@ "ramsey/uuid": "^4.9", "roxblnfk/unpoly": "^1.8", "spiral/tokenizer": "^3.18", + "testo/bridge-rector": "^0.3.6", "testo/testo": "^0.10.60" }, "autoload": { diff --git a/tests/Behavior/Functional/Driver/Common/BaseListenerTest.php b/tests/Behavior/Functional/Driver/Common/BaseListenerTest.php index 7f2aad7..d97c454 100644 --- a/tests/Behavior/Functional/Driver/Common/BaseListenerTest.php +++ b/tests/Behavior/Functional/Driver/Common/BaseListenerTest.php @@ -33,6 +33,7 @@ public function withSchema(SchemaInterface $schema): ORM return $this->orm; } + #[\Testo\Lifecycle\AfterTest] public function tearDown(): void { parent::tearDown(); diff --git a/tests/Behavior/Functional/Driver/Common/BaseSchemaTest.php b/tests/Behavior/Functional/Driver/Common/BaseSchemaTest.php index ebf7cf3..a3ff2f6 100644 --- a/tests/Behavior/Functional/Driver/Common/BaseSchemaTest.php +++ b/tests/Behavior/Functional/Driver/Common/BaseSchemaTest.php @@ -52,6 +52,7 @@ public function compileWithTokenizer(Tokenizer $tokenizer): void ])); } + #[\Testo\Lifecycle\AfterTest] public function tearDown(): void { parent::tearDown(); diff --git a/tests/Behavior/Functional/Driver/Common/BaseTest.php b/tests/Behavior/Functional/Driver/Common/BaseTest.php index 87de2cc..4448441 100644 --- a/tests/Behavior/Functional/Driver/Common/BaseTest.php +++ b/tests/Behavior/Functional/Driver/Common/BaseTest.php @@ -12,7 +12,7 @@ use Cycle\ORM\Entity\Behavior\Tests\Traits\Loggable; use PHPUnit\Framework\TestCase; -abstract class BaseTest extends TestCase +abstract class BaseTest { use Loggable; @@ -37,6 +37,7 @@ public function getDriver(): DriverInterface return static::$driverCache[static::DRIVER] = $this->driver; } + #[\Testo\Lifecycle\BeforeTest] protected function setUp(): void { $this->setUpLogger($this->getDriver()); @@ -56,6 +57,7 @@ protected function setUp(): void ); } + #[\Testo\Lifecycle\AfterTest] public function tearDown(): void { $this->dropDatabase($this->dbal->database('default')); diff --git a/tests/Behavior/Functional/Driver/Common/CreatedAt/CreatedAtTest.php b/tests/Behavior/Functional/Driver/Common/CreatedAt/CreatedAtTest.php index 0e8ef3f..718ae28 100644 --- a/tests/Behavior/Functional/Driver/Common/CreatedAt/CreatedAtTest.php +++ b/tests/Behavior/Functional/Driver/Common/CreatedAt/CreatedAtTest.php @@ -12,29 +12,32 @@ abstract class CreatedAtTest extends BaseSchemaTest { + #[\Testo\Test] public function testExistenceColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - $this->assertTrue($fields->has('createdAt')); - $this->assertTrue($fields->hasColumn('created_at')); - $this->assertSame('datetime', $fields->get('createdAt')->getType()); - $this->assertSame(GeneratedField::BEFORE_INSERT, $fields->get('createdAt')->getGenerated()); + \Testo\Assert::true($fields->has('createdAt')); + \Testo\Assert::true($fields->hasColumn('created_at')); + \Testo\Assert::same($fields->get('createdAt')->getType(), 'datetime'); + \Testo\Assert::same($fields->get('createdAt')->getGenerated(), GeneratedField::BEFORE_INSERT); // No new fields added - $this->assertSame(3, $fields->count()); + \Testo\Assert::same($fields->count(), 3); } + #[\Testo\Test] public function testAddedColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - $this->assertTrue($fields->has('newField')); - $this->assertTrue($fields->hasColumn('new_field')); - $this->assertSame('datetime', $fields->get('newField')->getType()); - $this->assertSame(GeneratedField::BEFORE_INSERT, $fields->get('newField')->getGenerated()); + \Testo\Assert::true($fields->has('newField')); + \Testo\Assert::true($fields->hasColumn('new_field')); + \Testo\Assert::same($fields->get('newField')->getType(), 'datetime'); + \Testo\Assert::same($fields->get('newField')->getGenerated(), GeneratedField::BEFORE_INSERT); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/CreatedAt/ListenerTest.php b/tests/Behavior/Functional/Driver/Common/CreatedAt/ListenerTest.php index b423edc..564c5f0 100644 --- a/tests/Behavior/Functional/Driver/Common/CreatedAt/ListenerTest.php +++ b/tests/Behavior/Functional/Driver/Common/CreatedAt/ListenerTest.php @@ -17,6 +17,7 @@ abstract class ListenerTest extends BaseListenerTest { use TableTrait; + #[\Testo\Test] public function testCreate(): void { $post = new Post(); @@ -25,10 +26,11 @@ public function testCreate(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - $this->assertNotNull($data->createdAt); - $this->assertNotNull($data->customCreatedAt); + \Testo\Assert::notNull($data->createdAt); + \Testo\Assert::notNull($data->customCreatedAt); } + #[\Testo\Test] public function testUpdate(): void { $post = new Post(); @@ -48,11 +50,12 @@ public function testUpdate(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - $this->assertSame(0, $data->createdAt <=> $createdAt); - $this->assertSame(0, $data->customCreatedAt <=> $customCreatedAt); - $this->assertSame('test', $data->content); + \Testo\Assert::same($data->createdAt <=> $createdAt, 0); + \Testo\Assert::same($data->customCreatedAt <=> $customCreatedAt, 0); + \Testo\Assert::same($data->content, 'test'); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/EventListener/EventListenerTest.php b/tests/Behavior/Functional/Driver/Common/EventListener/EventListenerTest.php index b250ec7..b8cd7ec 100644 --- a/tests/Behavior/Functional/Driver/Common/EventListener/EventListenerTest.php +++ b/tests/Behavior/Functional/Driver/Common/EventListener/EventListenerTest.php @@ -15,25 +15,28 @@ abstract class EventListenerTest extends BaseSchemaTest { + #[\Testo\Test] public function testSchemaWithArgs(): void { $listeners = $this->schema->define(Post::class, SchemaInterface::LISTENERS); - $this->assertIsArray($listeners); - $this->assertIsArray($listeners[0]); - $this->assertSame(PostService::class, $listeners[0][0]); - $this->assertSame(['foo' => 'modified by EventListener', 'bar' => ['baz']], $listeners[0][1]); - $this->assertCount(2, $listeners[0]); + \Testo\Assert::array($listeners); + \Testo\Assert::array($listeners[0]); + \Testo\Assert::same($listeners[0][0], PostService::class); + \Testo\Assert::same($listeners[0][1], ['foo' => 'modified by EventListener', 'bar' => ['baz']]); + \Testo\Assert::count($listeners[0], 2); } + #[\Testo\Test] public function testSchema(): void { $listeners = $this->schema->define(Comment::class, SchemaInterface::LISTENERS); - $this->assertIsArray($listeners); - $this->assertSame(CommentService::class, $listeners[0]); - $this->assertCount(1, $listeners); + \Testo\Assert::array($listeners); + \Testo\Assert::same($listeners[0], CommentService::class); + \Testo\Assert::count($listeners, 1); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/EventListener/ListenerTest.php b/tests/Behavior/Functional/Driver/Common/EventListener/ListenerTest.php index 5898203..7cd3050 100644 --- a/tests/Behavior/Functional/Driver/Common/EventListener/ListenerTest.php +++ b/tests/Behavior/Functional/Driver/Common/EventListener/ListenerTest.php @@ -17,6 +17,7 @@ abstract class ListenerTest extends BaseListenerTest { use TableTrait; + #[\Testo\Test] public function testApply(): void { $post = new Post(); @@ -26,10 +27,11 @@ public function testApply(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - $this->assertSame('modified by EventListener', $data->title); - $this->assertSame('baz', $data->content); + \Testo\Assert::same($data->title, 'modified by EventListener'); + \Testo\Assert::same($data->content, 'baz'); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/Hook/HookTest.php b/tests/Behavior/Functional/Driver/Common/Hook/HookTest.php index cfe7d10..94291fe 100644 --- a/tests/Behavior/Functional/Driver/Common/Hook/HookTest.php +++ b/tests/Behavior/Functional/Driver/Common/Hook/HookTest.php @@ -16,28 +16,24 @@ abstract class HookTest extends BaseSchemaTest { + #[\Testo\Test] public function testAddListener(): void { $listeners = $this->schema->define(Post::class, SchemaInterface::LISTENERS); - $this->assertIsArray($listeners); - $this->assertCount(2, $listeners); - $this->assertIsArray($listeners[0]); - $this->assertIsArray($listeners[1]); - - $this->assertSame(Hook::class, $listeners[0][0]); - $this->assertSame( - ['callable' => [PostService::class, 'update'], 'events' => [OnUpdate::class]], - $listeners[0][1], - ); - - $this->assertSame(Hook::class, $listeners[1][0]); - $this->assertSame( - ['callable' => [Post::class, 'touch'], 'events' => [OnCreate::class, OnUpdate::class]], - $listeners[1][1], - ); + \Testo\Assert::array($listeners); + \Testo\Assert::count($listeners, 2); + \Testo\Assert::array($listeners[0]); + \Testo\Assert::array($listeners[1]); + + \Testo\Assert::same($listeners[0][0], Hook::class); + \Testo\Assert::same($listeners[0][1], ['callable' => [PostService::class, 'update'], 'events' => [OnUpdate::class]]); + + \Testo\Assert::same($listeners[1][0], Hook::class); + \Testo\Assert::same($listeners[1][1], ['callable' => [Post::class, 'touch'], 'events' => [OnCreate::class, OnUpdate::class]]); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/Hook/ListenerTest.php b/tests/Behavior/Functional/Driver/Common/Hook/ListenerTest.php index 5c7ab3c..8f9eba1 100644 --- a/tests/Behavior/Functional/Driver/Common/Hook/ListenerTest.php +++ b/tests/Behavior/Functional/Driver/Common/Hook/ListenerTest.php @@ -20,6 +20,7 @@ abstract class ListenerTest extends BaseListenerTest { use TableTrait; + #[\Testo\Test] public function testCreate(): void { $post = $this->createPost(); @@ -27,13 +28,14 @@ public function testCreate(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - $this->assertNotNull($data->createdAt); - $this->assertNotNull($data->updatedAt); - $this->assertNull($data->content); - $this->assertSame('test', $post->slug); - $this->assertSame(OnCreate::class, $data->lastEvent); + \Testo\Assert::notNull($data->createdAt); + \Testo\Assert::notNull($data->updatedAt); + \Testo\Assert::null($data->content); + \Testo\Assert::same($post->slug, 'test'); + \Testo\Assert::same($data->lastEvent, OnCreate::class); } + #[\Testo\Test] public function testUpdate(): void { $this->createPost(); @@ -50,19 +52,20 @@ public function testUpdate(): void $data = $select->fetchOne(); // Triggered OnUpdate event - $this->assertNull($content); - $this->assertSame('modified by service', $data->content); + \Testo\Assert::null($content); + \Testo\Assert::same($data->content, 'modified by service'); // Not triggered OnCreate event, slug NOT changed. - $this->assertSame('test', $data->slug); - $this->assertSame('TEST 2', $data->title); + \Testo\Assert::same($data->slug, 'test'); + \Testo\Assert::same($data->title, 'TEST 2'); // Triggered union type event OnCreate|OnUpdate - $this->assertNotNull($data->updatedAt); - $this->assertNotNull($data->createdAt); - $this->assertSame(OnUpdate::class, $data->lastEvent); + \Testo\Assert::notNull($data->updatedAt); + \Testo\Assert::notNull($data->createdAt); + \Testo\Assert::same($data->lastEvent, OnUpdate::class); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/Integration/BaseTest.php b/tests/Behavior/Functional/Driver/Common/Integration/BaseTest.php index 8b84e24..2f69390 100644 --- a/tests/Behavior/Functional/Driver/Common/Integration/BaseTest.php +++ b/tests/Behavior/Functional/Driver/Common/Integration/BaseTest.php @@ -42,6 +42,7 @@ abstract class BaseTest extends \Cycle\ORM\Entity\Behavior\Tests\Functional\Driv protected SchemaInterface $schema; protected ORMInterface $orm; + #[\Testo\Lifecycle\AfterTest] public function tearDown(): void { $this->disableProfiling(); diff --git a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/CaseTest.php b/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/CaseTest.php index 9f33e2c..7e79390 100644 --- a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/CaseTest.php +++ b/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/CaseTest.php @@ -12,6 +12,7 @@ abstract class CaseTest extends BaseTest { use TableTrait; + #[\Testo\Test] public function testPreparedData(): void { // Get entity @@ -22,20 +23,21 @@ public function testPreparedData(): void \assert($user instanceof Entity\User); // Check results - self::assertNotNull($user->createdAt); - self::assertNotNull($user->updatedAt); - self::assertSame(0, $user->createdAt <=> $user->updatedAt); + \Testo\Assert::notNull($user->createdAt); + \Testo\Assert::notNull($user->updatedAt); + \Testo\Assert::same($user->createdAt <=> $user->updatedAt, 0); } + #[\Testo\Test] public function testCreatedAt(): void { // Get entity $user = $this->orm->make(Entity\User::class, ['login' => 'new-user', 'passwordHash' => '123456789']); - self::assertFalse(isset($user->createdAt)); + \Testo\Assert::false(isset($user->createdAt)); $this->save($user); - self::assertNotNull($user->createdAt); + \Testo\Assert::notNull($user->createdAt); // Reload entity $id = $user->id; @@ -43,9 +45,10 @@ public function testCreatedAt(): void $user = (new Select($this->orm, Entity\User::class)) ->wherePK($id) ->fetchOne(); - self::assertNotNull($user->createdAt); + \Testo\Assert::notNull($user->createdAt); } + #[\Testo\Test] public function testUpdatedAt(): void { // Get entity @@ -60,9 +63,10 @@ public function testUpdatedAt(): void $this->save($user); // Check results - self::assertSame(1, $user->updatedAt <=> $updatedAt); + \Testo\Assert::same($user->updatedAt <=> $updatedAt, 1); } + #[\Testo\Lifecycle\BeforeTest] protected function setUp(): void { // Init DB diff --git a/tests/Behavior/Functional/Driver/Common/OptimisticLock/InquiredRelationTest.php b/tests/Behavior/Functional/Driver/Common/OptimisticLock/InquiredRelationTest.php index dda09a4..19e6200 100644 --- a/tests/Behavior/Functional/Driver/Common/OptimisticLock/InquiredRelationTest.php +++ b/tests/Behavior/Functional/Driver/Common/OptimisticLock/InquiredRelationTest.php @@ -41,6 +41,7 @@ abstract class InquiredRelationTest extends BaseListenerTest { use TableTrait; + #[\Testo\Test] public function testUpdateWithSelectCollection(): void { $repo = $this->orm->getRepository(Product::class); @@ -66,22 +67,23 @@ public function testUpdateWithSelectCollection(): void $this->save($product1, $product2); // Persist 2 with Fetch all products - $this->assertSame(1, $product1->revision); - $this->assertSame(1, $product2->revision); + \Testo\Assert::same($product1->revision, 1); + \Testo\Assert::same($product2->revision, 1); $product1->name = '222'; // Persist 2 $this->save($product1); - $this->assertSame(2, $product1->revision); + \Testo\Assert::same($product1->revision, 2); // Persist 3 with Fetch all products $product1->name = '333'; $products = $repo->findAll(); $this->save($product1); - $this->assertEquals(3, $product1->revision); + \Testo\Assert::equals($product1->revision, 3); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/OptimisticLock/ListenerTest.php b/tests/Behavior/Functional/Driver/Common/OptimisticLock/ListenerTest.php index 70b81fe..4d3277f 100644 --- a/tests/Behavior/Functional/Driver/Common/OptimisticLock/ListenerTest.php +++ b/tests/Behavior/Functional/Driver/Common/OptimisticLock/ListenerTest.php @@ -22,6 +22,7 @@ abstract class ListenerTest extends BaseListenerTest { use TableTrait; + #[\Testo\Test] public function testAddVersionOnCreate(): void { $comment = new Comment(); @@ -34,12 +35,13 @@ public function testAddVersionOnCreate(): void $comment = $select->fetchOne(); - $this->assertSame(1, $comment->versionInt); - $this->assertInstanceOf(\DateTimeImmutable::class, $comment->versionDatetime); - $this->assertIsString($comment->versionMicrotime); - $this->assertIsString($comment->versionStr); + \Testo\Assert::same($comment->versionInt, 1); + \Testo\Assert::instanceOf($comment->versionDatetime, \DateTimeImmutable::class); + \Testo\Assert::string($comment->versionMicrotime); + \Testo\Assert::string($comment->versionStr); } + #[\Testo\Test] public function testManualAddVersionOnCreate(): void { $comment = new Comment(); @@ -56,12 +58,13 @@ public function testManualAddVersionOnCreate(): void $comment = $select->fetchOne(); - $this->assertSame(3, $comment->versionInt); - $this->assertSame(1638275394, $comment->versionDatetime->getTimestamp()); - $this->assertSame('1638275263.792011', $comment->versionMicrotime); - $this->assertSame('b0b55bb7237bb75611f7df8175e926d1', $comment->versionStr); + \Testo\Assert::same($comment->versionInt, 3); + \Testo\Assert::same($comment->versionDatetime->getTimestamp(), 1638275394); + \Testo\Assert::same($comment->versionMicrotime, '1638275263.792011'); + \Testo\Assert::same($comment->versionStr, 'b0b55bb7237bb75611f7df8175e926d1'); } + #[\Testo\Test] public function testManualVersionControl(): void { $comment = new Comment(); @@ -74,14 +77,15 @@ public function testManualVersionControl(): void $select = new Select($this->orm, Comment::class); $comment = $select->fetchOne(); - $this->assertSame(1, $comment->versionCustom); + \Testo\Assert::same($comment->versionCustom, 1); $comment->versionCustom = 2; $this->save($comment); - $this->assertSame(2, $comment->versionCustom); + \Testo\Assert::same($comment->versionCustom, 2); } + #[\Testo\Test] public function testExceptionOnChangeVersion(): void { $comment = new Comment(); @@ -93,15 +97,15 @@ public function testExceptionOnChangeVersion(): void $select = new Select($this->orm, Comment::class); $comment = $select->fetchOne(); - $this->assertSame(1, $comment->versionInt); + \Testo\Assert::same($comment->versionInt, 1); $comment->versionInt = 2; - $this->expectException(ChangedVersionException::class); - $this->expectExceptionMessage('Record version change detected. Old value `1`, a new value `2`'); + \Testo\Expect::exception(ChangedVersionException::class)->withMessageContaining('Record version change detected. Old value `1`, a new value `2`'); $this->save($comment); } + #[\Testo\Test] public function testUpdate(): void { $comment = new Comment(); @@ -114,8 +118,8 @@ public function testUpdate(): void $comment = $select->fetchOne(); - $this->assertSame(1, $comment->versionInt); - $this->assertSame('test', $comment->content); + \Testo\Assert::same($comment->versionInt, 1); + \Testo\Assert::same($comment->content, 'test'); $comment->content = 'changed'; @@ -124,10 +128,11 @@ public function testUpdate(): void $select = new Select($this->orm->with(heap: new Heap()), Comment::class); $data = $select->fetchOne(); - $this->assertSame('changed', $data->content); - $this->assertSame(2, $data->versionInt); + \Testo\Assert::same($data->content, 'changed'); + \Testo\Assert::same($data->versionInt, 2); } + #[\Testo\Test] public function testLock(): void { $comment = new Comment(); @@ -146,11 +151,11 @@ public function testLock(): void (new Transaction($orm))->persist($data1)->run(); - $this->expectException(RecordIsLockedException::class); - $this->expectExceptionMessage('The `comment` record is locked.'); + \Testo\Expect::exception(RecordIsLockedException::class)->withMessageContaining('The `comment` record is locked.'); (new Transaction($orm2))->persist($data2)->run(); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/OptimisticLock/OptimisticLockTest.php b/tests/Behavior/Functional/Driver/Common/OptimisticLock/OptimisticLockTest.php index a0e4053..e848288 100644 --- a/tests/Behavior/Functional/Driver/Common/OptimisticLock/OptimisticLockTest.php +++ b/tests/Behavior/Functional/Driver/Common/OptimisticLock/OptimisticLockTest.php @@ -18,92 +18,81 @@ abstract class OptimisticLockTest extends BaseSchemaTest { + #[\Testo\Test] public function testAddIntColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - $this->assertTrue($fields->has('version')); - $this->assertTrue($fields->hasColumn('version')); - $this->assertSame('integer', $fields->get('version')->getType()); - $this->assertSame( - GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE, - $fields->get('version')->getGenerated(), - ); + \Testo\Assert::true($fields->has('version')); + \Testo\Assert::true($fields->hasColumn('version')); + \Testo\Assert::same($fields->get('version')->getType(), 'integer'); + \Testo\Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); } + #[\Testo\Test] public function testAddStringColumn(): void { $fields = $this->registry->getEntity(Comment::class)->getFields(); - $this->assertTrue($fields->has('version')); - $this->assertTrue($fields->hasColumn('version')); - $this->assertSame(ColumnInterface::STRING, $fields->get('version')->getType()); - $this->assertSame( - GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE, - $fields->get('version')->getGenerated(), - ); + \Testo\Assert::true($fields->has('version')); + \Testo\Assert::true($fields->hasColumn('version')); + \Testo\Assert::same($fields->get('version')->getType(), ColumnInterface::STRING); + \Testo\Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); } + #[\Testo\Test] public function testAddDatetimeColumn(): void { $fields = $this->registry->getEntity(Page::class)->getFields(); - $this->assertTrue($fields->has('version')); - $this->assertTrue($fields->hasColumn('version')); - $this->assertSame('datetime', $fields->get('version')->getType()); - $this->assertSame( - GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE, - $fields->get('version')->getGenerated(), - ); + \Testo\Assert::true($fields->has('version')); + \Testo\Assert::true($fields->hasColumn('version')); + \Testo\Assert::same($fields->get('version')->getType(), 'datetime'); + \Testo\Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); } + #[\Testo\Test] public function testExistColumn(): void { $fields = $this->registry->getEntity(Item::class)->getFields(); - $this->assertTrue($fields->has('revision')); - $this->assertTrue($fields->hasColumn('revision_field')); - $this->assertSame('integer', $fields->get('revision')->getType()); - $this->assertSame( - GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE, - $fields->get('revision')->getGenerated(), - ); + \Testo\Assert::true($fields->has('revision')); + \Testo\Assert::true($fields->hasColumn('revision_field')); + \Testo\Assert::same($fields->get('revision')->getType(), 'integer'); + \Testo\Assert::same($fields->get('revision')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); // not added new columns - $this->assertSame(2, $fields->count()); + \Testo\Assert::same($fields->count(), 2); } + #[\Testo\Test] public function testExistColumnAndAllOptimisticLockParameters(): void { $fields = $this->registry->getEntity(WithAllParameters::class)->getFields(); - $this->assertTrue($fields->has('revision')); - $this->assertTrue($fields->hasColumn('revision_field')); - $this->assertSame('integer', $fields->get('revision')->getType()); - $this->assertSame( - GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE, - $fields->get('revision')->getGenerated(), - ); + \Testo\Assert::true($fields->has('revision')); + \Testo\Assert::true($fields->hasColumn('revision_field')); + \Testo\Assert::same($fields->get('revision')->getType(), 'integer'); + \Testo\Assert::same($fields->get('revision')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); // not added new columns - $this->assertSame(2, $fields->count()); + \Testo\Assert::same($fields->count(), 2); } + #[\Testo\Test] public function testAddDefaultColumAndRule(): void { $fields = $this->registry->getEntity(News::class)->getFields(); - $this->assertTrue($fields->has('version')); - $this->assertTrue($fields->hasColumn('version')); - $this->assertSame('integer', $fields->get('version')->getType()); - $this->assertSame( - GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE, - $fields->get('version')->getGenerated(), - ); + \Testo\Assert::true($fields->has('version')); + \Testo\Assert::true($fields->hasColumn('version')); + \Testo\Assert::same($fields->get('version')->getType(), 'integer'); + \Testo\Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); - $this->assertSame(2, $fields->count()); + \Testo\Assert::same($fields->count(), 2); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/Schema/ErrorsTest.php b/tests/Behavior/Functional/Driver/Common/Schema/ErrorsTest.php index 02d850f..921f20a 100644 --- a/tests/Behavior/Functional/Driver/Common/Schema/ErrorsTest.php +++ b/tests/Behavior/Functional/Driver/Common/Schema/ErrorsTest.php @@ -31,13 +31,11 @@ public static function errorsProvider(): array ]; } - /** - * @dataProvider errorsProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('errorsProvider')] public function testErrors(Tokenizer $tokenizer, string $message): void { - $this->expectException(BehaviorCompilationException::class); - $this->expectExceptionMessageMatches(\sprintf('/%s/', $message)); + \Testo\Expect::exception(BehaviorCompilationException::class)->withMessageMatchingRegex(\sprintf('/%s/', $message)); $this->compileWithTokenizer($tokenizer); } diff --git a/tests/Behavior/Functional/Driver/Common/Schema/RegistryModifierTest.php b/tests/Behavior/Functional/Driver/Common/Schema/RegistryModifierTest.php index 0f8f1f4..670ed0c 100644 --- a/tests/Behavior/Functional/Driver/Common/Schema/RegistryModifierTest.php +++ b/tests/Behavior/Functional/Driver/Common/Schema/RegistryModifierTest.php @@ -22,6 +22,7 @@ abstract class RegistryModifierTest extends BaseTest protected RegistryModifier $modifier; protected Registry $registry; + #[\Testo\Test] public function testAddDatetimeField(): void { $this->modifier->addDatetimeColumn('created_at', 'createdAt'); @@ -29,11 +30,12 @@ public function testAddDatetimeField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - $this->assertTrue($fields->has('createdAt')); - $this->assertSame('datetime', $fields->get('createdAt')->getType()); - $this->assertSame('created_at', $fields->get('createdAt')->getColumn()); + \Testo\Assert::true($fields->has('createdAt')); + \Testo\Assert::same($fields->get('createdAt')->getType(), 'datetime'); + \Testo\Assert::same($fields->get('createdAt')->getColumn(), 'created_at'); } + #[\Testo\Test] public function testAddStringField(): void { $this->modifier->addStringColumn('version_str', 'version'); @@ -41,11 +43,12 @@ public function testAddStringField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - $this->assertTrue($fields->has('version')); - $this->assertSame(ColumnInterface::STRING, $fields->get('version')->getType()); - $this->assertSame('version_str', $fields->get('version')->getColumn()); + \Testo\Assert::true($fields->has('version')); + \Testo\Assert::same($fields->get('version')->getType(), ColumnInterface::STRING); + \Testo\Assert::same($fields->get('version')->getColumn(), 'version_str'); } + #[\Testo\Test] public function testAddIntegerField(): void { $this->modifier->addIntegerColumn('version_int', 'version'); @@ -53,11 +56,12 @@ public function testAddIntegerField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - $this->assertTrue($fields->has('version')); - $this->assertSame('integer', $fields->get('version')->getType()); - $this->assertSame('version_int', $fields->get('version')->getColumn()); + \Testo\Assert::true($fields->has('version')); + \Testo\Assert::same($fields->get('version')->getType(), 'integer'); + \Testo\Assert::same($fields->get('version')->getColumn(), 'version_int'); } + #[\Testo\Test] public function testAddBigIntegerField(): void { $this->modifier->addBigIntegerColumn('snowflake_column', 'snowflake'); @@ -65,21 +69,22 @@ public function testAddBigIntegerField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - $this->assertTrue($fields->has('snowflake')); - $this->assertSame('bigInteger', $fields->get('snowflake')->getType()); - $this->assertSame('snowflake_column', $fields->get('snowflake')->getColumn()); + \Testo\Assert::true($fields->has('snowflake')); + \Testo\Assert::same($fields->get('snowflake')->getType(), 'bigInteger'); + \Testo\Assert::same($fields->get('snowflake')->getColumn(), 'snowflake_column'); } + #[\Testo\Test] public function testAddBigIntegerFieldThrowsException(): void { $this->modifier->addIntegerColumn('snowflake_column', 'snowflake'); - $this->expectException(BehaviorCompilationException::class); - $this->expectExceptionMessage('Field snowflake must be of type big integer.'); + \Testo\Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field snowflake must be of type big integer.'); $this->modifier->addBigIntegerColumn('snowflake_column', 'snowflake'); } + #[\Testo\Test] public function testAddSnowflakeField(): void { $this->modifier->addSnowflakeColumn('snowflake_column', 'snowflake'); @@ -87,21 +92,22 @@ public function testAddSnowflakeField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - $this->assertTrue($fields->has('snowflake')); - $this->assertSame('snowflake', $fields->get('snowflake')->getType()); - $this->assertSame('snowflake_column', $fields->get('snowflake')->getColumn()); + \Testo\Assert::true($fields->has('snowflake')); + \Testo\Assert::same($fields->get('snowflake')->getType(), 'snowflake'); + \Testo\Assert::same($fields->get('snowflake')->getColumn(), 'snowflake_column'); } + #[\Testo\Test] public function testAddSnowflakeFieldThrowsException(): void { $this->modifier->addStringColumn('snowflake_column', 'snowflake'); - $this->expectException(BehaviorCompilationException::class); - $this->expectExceptionMessage('Field snowflake must be of type snowflake.'); + \Testo\Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field snowflake must be of type snowflake.'); $this->modifier->addSnowflakeColumn('snowflake_column', 'snowflake'); } + #[\Testo\Test] public function testAddUlidField(): void { $this->modifier->addUlidColumn('ulid_column', 'ulid'); @@ -109,21 +115,22 @@ public function testAddUlidField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - $this->assertTrue($fields->has('ulid')); - $this->assertSame('ulid', $fields->get('ulid')->getType()); - $this->assertSame('ulid_column', $fields->get('ulid')->getColumn()); + \Testo\Assert::true($fields->has('ulid')); + \Testo\Assert::same($fields->get('ulid')->getType(), 'ulid'); + \Testo\Assert::same($fields->get('ulid')->getColumn(), 'ulid_column'); } + #[\Testo\Test] public function testAddUlidFieldThrowsException(): void { $this->modifier->addIntegerColumn('ulid_column', 'ulid'); - $this->expectException(BehaviorCompilationException::class); - $this->expectExceptionMessage('Field ulid must be of type ulid.'); + \Testo\Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field ulid must be of type ulid.'); $this->modifier->addUlidColumn('ulid_column', 'ulid'); } + #[\Testo\Test] public function testAddUuidField(): void { $this->modifier->addUuidColumn('uuid_column', 'uuid'); @@ -131,21 +138,22 @@ public function testAddUuidField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - $this->assertTrue($fields->has('uuid')); - $this->assertSame('uuid', $fields->get('uuid')->getType()); - $this->assertSame('uuid_column', $fields->get('uuid')->getColumn()); + \Testo\Assert::true($fields->has('uuid')); + \Testo\Assert::same($fields->get('uuid')->getType(), 'uuid'); + \Testo\Assert::same($fields->get('uuid')->getColumn(), 'uuid_column'); } + #[\Testo\Test] public function testAddUuidFieldThrowsException(): void { $this->modifier->addIntegerColumn('uuid_column', 'uuid'); - $this->expectException(BehaviorCompilationException::class); - $this->expectExceptionMessage('Field uuid must be of type uuid.'); + \Testo\Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field uuid must be of type uuid.'); $this->modifier->addUuidColumn('uuid_column', 'uuid'); } + #[\Testo\Test] public function testAddTypecast(): void { $this->modifier->addUuidColumn('uuid_column', 'uuid'); @@ -160,17 +168,15 @@ public function testAddTypecast(): void $this->modifier->setTypecast($field3, 'int', CustomTypecast::class); // field has custom UUID typecast - $this->assertSame([Uuid::class, 'fromString'], $field1->getTypecast()); - $this->assertSame('int', $field2->getTypecast()); - $this->assertSame('int', $field3->getTypecast()); + \Testo\Assert::same($field1->getTypecast(), [Uuid::class, 'fromString']); + \Testo\Assert::same($field2->getTypecast(), 'int'); + \Testo\Assert::same($field3->getTypecast(), 'int'); // entity has default typecast - $this->assertSame( - [Typecast::class, CustomTypecast::class], - $this->registry->getEntity(self::ROLE_TEST)->getTypecast(), - ); + \Testo\Assert::same($this->registry->getEntity(self::ROLE_TEST)->getTypecast(), [Typecast::class, CustomTypecast::class]); } + #[\Testo\Test] public function testAddTypecastEntityWithTypecast(): void { $this->registry->getEntity(self::ROLE_TEST)->setTypecast(CustomTypecast::class); @@ -181,15 +187,13 @@ public function testAddTypecastEntityWithTypecast(): void $this->modifier->setTypecast($field, [Uuid::class, 'fromString']); // field has custom UUID typecast - $this->assertSame([Uuid::class, 'fromString'], $field->getTypecast()); + \Testo\Assert::same($field->getTypecast(), [Uuid::class, 'fromString']); // entity has default typecast and custom typecast - $this->assertSame( - [CustomTypecast::class, Typecast::class], - $this->registry->getEntity(self::ROLE_TEST)->getTypecast(), - ); + \Testo\Assert::same($this->registry->getEntity(self::ROLE_TEST)->getTypecast(), [CustomTypecast::class, Typecast::class]); } + #[\Testo\Test] public function testAddTypecastShouldBeSkipped(): void { $this->registry->getEntity(self::ROLE_TEST); @@ -197,18 +201,20 @@ public function testAddTypecastShouldBeSkipped(): void $this->modifier->addUuidColumn('uuid_column', 'uuid'); $this->registry->getDefaults()->offsetSet(SchemaInterface::TYPECAST_HANDLER, Typecast::class); - $this->assertNull($this->registry->getEntity(self::ROLE_TEST)->getTypecast()); + \Testo\Assert::null($this->registry->getEntity(self::ROLE_TEST)->getTypecast()); } + #[\Testo\Test] public function testAddTypecastShouldBeDuplicated(): void { $this->registry->getEntity(self::ROLE_TEST)->setTypecast(CustomTypecast::class); $this->modifier->addUuidColumn('uuid_column', 'uuid'); - $this->assertSame(CustomTypecast::class, $this->registry->getEntity(self::ROLE_TEST)->getTypecast()); + \Testo\Assert::same($this->registry->getEntity(self::ROLE_TEST)->getTypecast(), CustomTypecast::class); } + #[\Testo\Test] public function testCustomTypecastNotOverridden(): void { $this->modifier->addUuidColumn('uuid_column', 'uuid'); @@ -218,9 +224,10 @@ public function testCustomTypecastNotOverridden(): void $this->modifier->setTypecast($field, [Uuid::class, 'fromString']); - $this->assertSame(['foo', 'bar'], $field->getTypecast()); + \Testo\Assert::same($field->getTypecast(), ['foo', 'bar']); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/SoftDelete/ListenerTest.php b/tests/Behavior/Functional/Driver/Common/SoftDelete/ListenerTest.php index 09affe9..ec11e03 100644 --- a/tests/Behavior/Functional/Driver/Common/SoftDelete/ListenerTest.php +++ b/tests/Behavior/Functional/Driver/Common/SoftDelete/ListenerTest.php @@ -18,6 +18,7 @@ abstract class ListenerTest extends BaseListenerTest { use TableTrait; + #[\Testo\Test] public function testDelete(): void { $this->save(new Post()); @@ -25,8 +26,8 @@ public function testDelete(): void $select = new Select($this->orm, Post::class); $post = $select->fetchOne(); - $this->assertNull($post->deletedAt); - $this->assertNull($post->customDeletedAt); + \Testo\Assert::null($post->deletedAt); + \Testo\Assert::null($post->customDeletedAt); $tr = new Transaction($this->orm); $tr->delete($post); @@ -35,11 +36,12 @@ public function testDelete(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - $this->assertInstanceOf(Post::class, $data); - $this->assertNotNull($data->deletedAt); - $this->assertNotNull($data->customDeletedAt); + \Testo\Assert::instanceOf($data, Post::class); + \Testo\Assert::notNull($data->deletedAt); + \Testo\Assert::notNull($data->customDeletedAt); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/SoftDelete/SoftDeleteTest.php b/tests/Behavior/Functional/Driver/Common/SoftDelete/SoftDeleteTest.php index 0f8764c..974ac84 100644 --- a/tests/Behavior/Functional/Driver/Common/SoftDelete/SoftDeleteTest.php +++ b/tests/Behavior/Functional/Driver/Common/SoftDelete/SoftDeleteTest.php @@ -12,29 +12,32 @@ abstract class SoftDeleteTest extends BaseSchemaTest { + #[\Testo\Test] public function testExistenceColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - $this->assertTrue($fields->has('deletedAt')); - $this->assertTrue($fields->hasColumn('deleted_at')); - $this->assertSame('datetime', $fields->get('deletedAt')->getType()); - $this->assertSame(GeneratedField::BEFORE_UPDATE, $fields->get('deletedAt')->getGenerated()); + \Testo\Assert::true($fields->has('deletedAt')); + \Testo\Assert::true($fields->hasColumn('deleted_at')); + \Testo\Assert::same($fields->get('deletedAt')->getType(), 'datetime'); + \Testo\Assert::same($fields->get('deletedAt')->getGenerated(), GeneratedField::BEFORE_UPDATE); // No new fields added - $this->assertSame(3, $fields->count()); + \Testo\Assert::same($fields->count(), 3); } + #[\Testo\Test] public function testAddedColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - $this->assertTrue($fields->has('newField')); - $this->assertTrue($fields->hasColumn('new_field')); - $this->assertSame('datetime', $fields->get('newField')->getType()); - $this->assertSame(GeneratedField::BEFORE_UPDATE, $fields->get('newField')->getGenerated()); + \Testo\Assert::true($fields->has('newField')); + \Testo\Assert::true($fields->hasColumn('new_field')); + \Testo\Assert::same($fields->get('newField')->getType(), 'datetime'); + \Testo\Assert::same($fields->get('newField')->getGenerated(), GeneratedField::BEFORE_UPDATE); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/UpdatedAt/ListenerTest.php b/tests/Behavior/Functional/Driver/Common/UpdatedAt/ListenerTest.php index fae6ce0..22f94f7 100644 --- a/tests/Behavior/Functional/Driver/Common/UpdatedAt/ListenerTest.php +++ b/tests/Behavior/Functional/Driver/Common/UpdatedAt/ListenerTest.php @@ -17,6 +17,7 @@ abstract class ListenerTest extends BaseListenerTest { use TableTrait; + #[\Testo\Test] public function testCreate(): void { $post = new Post(); @@ -25,10 +26,11 @@ public function testCreate(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - $this->assertNull($data->updatedAt); - $this->assertNull($data->customUpdatedAt); + \Testo\Assert::null($data->updatedAt); + \Testo\Assert::null($data->customUpdatedAt); } + #[\Testo\Test] public function testCreateNotNullable(): void { $post = new Post(); @@ -39,9 +41,10 @@ public function testCreateNotNullable(): void $select = new Select($this->orm, Post::class); $data = $select->fetchOne(); - $this->assertInstanceOf(\DateTimeImmutable::class, $data->notNullableUpdatedAt); + \Testo\Assert::instanceOf($data->notNullableUpdatedAt, \DateTimeImmutable::class); } + #[\Testo\Test] public function testUpdate(): void { $post = new Post(); @@ -60,11 +63,12 @@ public function testUpdate(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - $this->assertGreaterThan(0, $data->updatedAt <=> $updatedAt); - $this->assertGreaterThan(0, $data->customUpdatedAt <=> $customUpdatedAt); - $this->assertSame('test', $data->content); + \Testo\Assert::numeric($data->updatedAt <=> $updatedAt)->greaterThan(0); + \Testo\Assert::numeric($data->customUpdatedAt <=> $customUpdatedAt)->greaterThan(0); + \Testo\Assert::same($data->content, 'test'); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/Common/UpdatedAt/UpdatedAtTest.php b/tests/Behavior/Functional/Driver/Common/UpdatedAt/UpdatedAtTest.php index 7611859..9778b04 100644 --- a/tests/Behavior/Functional/Driver/Common/UpdatedAt/UpdatedAtTest.php +++ b/tests/Behavior/Functional/Driver/Common/UpdatedAt/UpdatedAtTest.php @@ -12,35 +12,32 @@ abstract class UpdatedAtTest extends BaseSchemaTest { + #[\Testo\Test] public function testExistenceColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - $this->assertTrue($fields->has('updatedAt')); - $this->assertTrue($fields->hasColumn('updated_at')); - $this->assertSame('datetime', $fields->get('updatedAt')->getType()); - $this->assertSame( - GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE, - $fields->get('updatedAt')->getGenerated(), - ); + \Testo\Assert::true($fields->has('updatedAt')); + \Testo\Assert::true($fields->hasColumn('updated_at')); + \Testo\Assert::same($fields->get('updatedAt')->getType(), 'datetime'); + \Testo\Assert::same($fields->get('updatedAt')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); // No new fields added - $this->assertSame(3, $fields->count()); + \Testo\Assert::same($fields->count(), 3); } + #[\Testo\Test] public function testAddedColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - $this->assertTrue($fields->has('newField')); - $this->assertTrue($fields->hasColumn('new_field')); - $this->assertSame('datetime', $fields->get('newField')->getType()); - $this->assertSame( - GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE, - $fields->get('newField')->getGenerated(), - ); + \Testo\Assert::true($fields->has('newField')); + \Testo\Assert::true($fields->hasColumn('new_field')); + \Testo\Assert::same($fields->get('newField')->getType(), 'datetime'); + \Testo\Assert::same($fields->get('newField')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Behavior/Functional/Driver/MySQL/CreatedAt/CreatedAtTest.php b/tests/Behavior/Functional/Driver/MySQL/CreatedAt/CreatedAtTest.php deleted file mode 100644 index cf93805..0000000 --- a/tests/Behavior/Functional/Driver/MySQL/CreatedAt/CreatedAtTest.php +++ /dev/null @@ -1,17 +0,0 @@ -assertTrue(RegistryModifier::isIntegerType($type)); + \Testo\Assert::true(RegistryModifier::isIntegerType($type)); } - /** - * @dataProvider datetimeDataProvider - * @dataProvider stringDataProvider - * @dataProvider invalidDataProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('datetimeDataProvider')] + #[\Testo\Data\DataProvider('stringDataProvider')] + #[\Testo\Data\DataProvider('invalidDataProvider')] public function testIsIntegerTypeFalse(mixed $type): void { - $this->assertFalse(RegistryModifier::isIntegerType($type)); + \Testo\Assert::false(RegistryModifier::isIntegerType($type)); } - /** - * @dataProvider bigIntegerDataProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('bigIntegerDataProvider')] public function testIsBigIntegerTypeTrue(mixed $type): void { - $this->assertTrue(RegistryModifier::isBigIntegerType($type)); + \Testo\Assert::true(RegistryModifier::isBigIntegerType($type)); } - /** - * @dataProvider datetimeDataProvider - * @dataProvider stringDataProvider - * @dataProvider invalidDataProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('datetimeDataProvider')] + #[\Testo\Data\DataProvider('stringDataProvider')] + #[\Testo\Data\DataProvider('invalidDataProvider')] public function testIsBigIntegerTypeFalse(mixed $type): void { - $this->assertFalse(RegistryModifier::isBigIntegerType($type)); + \Testo\Assert::false(RegistryModifier::isBigIntegerType($type)); } - /** - * @dataProvider datetimeDataProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('datetimeDataProvider')] public function testIsDatetimeTypeTrue(mixed $type): void { - $this->assertTrue(RegistryModifier::isDatetimeType($type)); + \Testo\Assert::true(RegistryModifier::isDatetimeType($type)); } - /** - * @dataProvider integerDataProvider - * @dataProvider stringDataProvider - * @dataProvider invalidDataProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('integerDataProvider')] + #[\Testo\Data\DataProvider('stringDataProvider')] + #[\Testo\Data\DataProvider('invalidDataProvider')] public function testIsDatetimeTypeFalse(mixed $type): void { - $this->assertFalse(RegistryModifier::isDatetimeType($type)); + \Testo\Assert::false(RegistryModifier::isDatetimeType($type)); } - /** - * @dataProvider stringDataProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('stringDataProvider')] public function testIsStringTypeTrue(mixed $type): void { - $this->assertTrue(RegistryModifier::isStringType($type)); + \Testo\Assert::true(RegistryModifier::isStringType($type)); } - /** - * @dataProvider integerDataProvider - * @dataProvider datetimeDataProvider - * @dataProvider invalidDataProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('integerDataProvider')] + #[\Testo\Data\DataProvider('datetimeDataProvider')] + #[\Testo\Data\DataProvider('invalidDataProvider')] public function testIsStringTypeFalse(mixed $type): void { - $this->assertFalse(RegistryModifier::isStringType($type)); + \Testo\Assert::false(RegistryModifier::isStringType($type)); } + #[\Testo\Test] public function testIsSnowflakeTypeTrue(): void { - $this->assertTrue(RegistryModifier::isSnowflakeType('snowflake')); + \Testo\Assert::true(RegistryModifier::isSnowflakeType('snowflake')); } - /** - * @dataProvider integerDataProvider - * @dataProvider datetimeDataProvider - * @dataProvider invalidDataProvider - * @dataProvider stringDataProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('integerDataProvider')] + #[\Testo\Data\DataProvider('datetimeDataProvider')] + #[\Testo\Data\DataProvider('invalidDataProvider')] + #[\Testo\Data\DataProvider('stringDataProvider')] public function testIsSnowflakeTypeFalse(mixed $type): void { - $this->assertFalse(RegistryModifier::isSnowflakeType($type)); + \Testo\Assert::false(RegistryModifier::isSnowflakeType($type)); } + #[\Testo\Test] public function testIsUlidTypeTrue(): void { - $this->assertTrue(RegistryModifier::isUlidType('ulid')); + \Testo\Assert::true(RegistryModifier::isUlidType('ulid')); } - /** - * @dataProvider integerDataProvider - * @dataProvider datetimeDataProvider - * @dataProvider invalidDataProvider - * @dataProvider stringDataProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('integerDataProvider')] + #[\Testo\Data\DataProvider('datetimeDataProvider')] + #[\Testo\Data\DataProvider('invalidDataProvider')] + #[\Testo\Data\DataProvider('stringDataProvider')] public function testIsUlidTypeFalse(mixed $type): void { - $this->assertFalse(RegistryModifier::isUlidType($type)); + \Testo\Assert::false(RegistryModifier::isUlidType($type)); } + #[\Testo\Test] public function testIsUuidTypeTrue(): void { - $this->assertTrue(RegistryModifier::isUuidType('uuid')); + \Testo\Assert::true(RegistryModifier::isUuidType('uuid')); } - /** - * @dataProvider integerDataProvider - * @dataProvider datetimeDataProvider - * @dataProvider invalidDataProvider - * @dataProvider stringDataProvider - */ + #[\Testo\Test] + #[\Testo\Data\DataProvider('integerDataProvider')] + #[\Testo\Data\DataProvider('datetimeDataProvider')] + #[\Testo\Data\DataProvider('invalidDataProvider')] + #[\Testo\Data\DataProvider('stringDataProvider')] public function testIsUuidTypeFalse(mixed $type): void { - $this->assertFalse(RegistryModifier::isUuidType($type)); + \Testo\Assert::false(RegistryModifier::isUuidType($type)); } } From 86f117a787bb7ca2432c5a07bb843b176f70448d Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 11:58:55 +0400 Subject: [PATCH 04/14] test: move the tests onto the cycle/testing harness DatabaseTestCase and OrmTestCase of cycle/testing replace the copied BaseTest, TableTrait, Loggable, TableRenderer and TestLogger; ListenerTestCase, SchemaTestCase and IntegrationTestCase stay in tests/Support as helpers specific to this package. Assisted-By: Claude Opus 5.5 --- composer.json | 2 +- .../Driver/Common/BaseListenerTest.php | 52 ----- .../Functional/Driver/Common/BaseTest.php | 99 --------- tests/Behavior/Traits/Loggable.php | 36 ---- tests/Behavior/Traits/TableTrait.php | 80 -------- tests/Behavior/Utils/TableRenderer.php | 193 ------------------ tests/Behavior/Utils/TestLogger.php | 45 ---- .../Common/CreatedAt/CreatedAtTest.php | 12 +- .../Common/CreatedAt/ListenerTest.php | 13 +- .../EventListener/EventListenerTest.php | 12 +- .../Common/EventListener/ListenerTest.php | 13 +- .../Common/Hook/HookTest.php | 12 +- .../Common/Hook/ListenerTest.php | 13 +- .../OptimisticLock/InquiredRelationTest.php | 32 +-- .../Common/OptimisticLock/ListenerTest.php | 13 +- .../OptimisticLock/OptimisticLockTest.php | 12 +- .../Common/Schema/ErrorsTest.php | 10 +- .../Common/Schema/RegistryModifierTest.php | 10 +- .../Common/SoftDelete/ListenerTest.php | 13 +- .../Common/SoftDelete/SoftDeleteTest.php | 12 +- .../Common/UpdatedAt/ListenerTest.php | 13 +- .../Common/UpdatedAt/UpdatedAtTest.php | 12 +- .../Fixtures/CommentService.php | 0 .../Fixtures/CreatedAt/Post.php | 0 .../Fixtures/CustomTypecast.php | 0 .../Fixtures/EventListener/Comment.php | 0 .../Fixtures/EventListener/Post.php | 0 tests/{Behavior => }/Fixtures/Hook/Post.php | 0 .../Fixtures/OptimisticLock/Author.php | 0 .../Fixtures/OptimisticLock/Comment.php | 0 .../InquiredRelations/Product.php | 0 .../InquiredRelations/ProductBox.php | 0 .../Fixtures/OptimisticLock/Item.php | 0 .../Fixtures/OptimisticLock/News.php | 0 .../Fixtures/OptimisticLock/Page.php | 0 .../Fixtures/OptimisticLock/Post.php | 0 .../OptimisticLock/WithAllParameters.php | 0 tests/{Behavior => }/Fixtures/PostService.php | 0 .../Fixtures/SoftDelete/Post.php | 0 .../Fixtures/UpdatedAt/Post.php | 0 .../Fixtures/Wrong/ColumnName/User.php | 0 .../Fixtures/Wrong/FieldType/User.php | 0 .../CaseTemplate/CaseTest.php | 11 +- .../CaseTemplate/Entity/Comment.php | 2 +- .../CaseTemplate/Entity/Post.php | 2 +- .../CaseTemplate/Entity/PostTag.php | 2 +- .../CaseTemplate/Entity/Tag.php | 2 +- .../CaseTemplate/Entity/User.php | 2 +- .../IntegrationTestCase.php} | 41 +--- tests/Support/ListenerTestCase.php | 32 +++ .../SchemaTestCase.php} | 23 +-- .../Utils => Support}/SimpleContainer.php | 2 +- .../Unit/Schema/RegistryModifierTest.php | 0 tests/bootstrap.php | 74 ------- tests/docker-compose.yml | 27 --- tests/generate-case.php | 8 +- 56 files changed, 130 insertions(+), 807 deletions(-) delete mode 100644 tests/Behavior/Functional/Driver/Common/BaseListenerTest.php delete mode 100644 tests/Behavior/Functional/Driver/Common/BaseTest.php delete mode 100644 tests/Behavior/Traits/Loggable.php delete mode 100644 tests/Behavior/Traits/TableTrait.php delete mode 100644 tests/Behavior/Utils/TableRenderer.php delete mode 100644 tests/Behavior/Utils/TestLogger.php rename tests/{Behavior/Functional/Driver => Feature}/Common/CreatedAt/CreatedAtTest.php (80%) rename tests/{Behavior/Functional/Driver => Feature}/Common/CreatedAt/ListenerTest.php (88%) rename tests/{Behavior/Functional/Driver => Feature}/Common/EventListener/EventListenerTest.php (80%) rename tests/{Behavior/Functional/Driver => Feature}/Common/EventListener/ListenerTest.php (82%) rename tests/{Behavior/Functional/Driver => Feature}/Common/Hook/HookTest.php (80%) rename tests/{Behavior/Functional/Driver => Feature}/Common/Hook/ListenerTest.php (92%) rename tests/{Behavior/Functional/Driver => Feature}/Common/OptimisticLock/InquiredRelationTest.php (77%) rename tests/{Behavior/Functional/Driver => Feature}/Common/OptimisticLock/ListenerTest.php (95%) rename tests/{Behavior/Functional/Driver => Feature}/Common/OptimisticLock/OptimisticLockTest.php (92%) rename tests/{Behavior/Functional/Driver => Feature}/Common/Schema/ErrorsTest.php (77%) rename tests/{Behavior/Functional/Driver => Feature}/Common/Schema/RegistryModifierTest.php (97%) rename tests/{Behavior/Functional/Driver => Feature}/Common/SoftDelete/ListenerTest.php (87%) rename tests/{Behavior/Functional/Driver => Feature}/Common/SoftDelete/SoftDeleteTest.php (80%) rename tests/{Behavior/Functional/Driver => Feature}/Common/UpdatedAt/ListenerTest.php (91%) rename tests/{Behavior/Functional/Driver => Feature}/Common/UpdatedAt/UpdatedAtTest.php (81%) rename tests/{Behavior => }/Fixtures/CommentService.php (100%) rename tests/{Behavior => }/Fixtures/CreatedAt/Post.php (100%) rename tests/{Behavior => }/Fixtures/CustomTypecast.php (100%) rename tests/{Behavior => }/Fixtures/EventListener/Comment.php (100%) rename tests/{Behavior => }/Fixtures/EventListener/Post.php (100%) rename tests/{Behavior => }/Fixtures/Hook/Post.php (100%) rename tests/{Behavior => }/Fixtures/OptimisticLock/Author.php (100%) rename tests/{Behavior => }/Fixtures/OptimisticLock/Comment.php (100%) rename tests/{Behavior => }/Fixtures/OptimisticLock/InquiredRelations/Product.php (100%) rename tests/{Behavior => }/Fixtures/OptimisticLock/InquiredRelations/ProductBox.php (100%) rename tests/{Behavior => }/Fixtures/OptimisticLock/Item.php (100%) rename tests/{Behavior => }/Fixtures/OptimisticLock/News.php (100%) rename tests/{Behavior => }/Fixtures/OptimisticLock/Page.php (100%) rename tests/{Behavior => }/Fixtures/OptimisticLock/Post.php (100%) rename tests/{Behavior => }/Fixtures/OptimisticLock/WithAllParameters.php (100%) rename tests/{Behavior => }/Fixtures/PostService.php (100%) rename tests/{Behavior => }/Fixtures/SoftDelete/Post.php (100%) rename tests/{Behavior => }/Fixtures/UpdatedAt/Post.php (100%) rename tests/{Behavior => }/Fixtures/Wrong/ColumnName/User.php (100%) rename tests/{Behavior => }/Fixtures/Wrong/FieldType/User.php (100%) rename tests/{Behavior/Functional/Driver/Common/Integration => Regression}/CaseTemplate/CaseTest.php (93%) rename tests/{Behavior/Functional/Driver/Common/Integration => Regression}/CaseTemplate/Entity/Comment.php (93%) rename tests/{Behavior/Functional/Driver/Common/Integration => Regression}/CaseTemplate/Entity/Post.php (95%) rename tests/{Behavior/Functional/Driver/Common/Integration => Regression}/CaseTemplate/Entity/PostTag.php (80%) rename tests/{Behavior/Functional/Driver/Common/Integration => Regression}/CaseTemplate/Entity/Tag.php (88%) rename tests/{Behavior/Functional/Driver/Common/Integration => Regression}/CaseTemplate/Entity/User.php (91%) rename tests/{Behavior/Functional/Driver/Common/Integration/BaseTest.php => Support/IntegrationTestCase.php} (67%) create mode 100644 tests/Support/ListenerTestCase.php rename tests/{Behavior/Functional/Driver/Common/BaseSchemaTest.php => Support/SchemaTestCase.php} (77%) rename tests/{Behavior/Utils => Support}/SimpleContainer.php (96%) rename tests/{Behavior => }/Unit/Schema/RegistryModifierTest.php (100%) delete mode 100644 tests/bootstrap.php delete mode 100644 tests/docker-compose.yml diff --git a/composer.json b/composer.json index 09f37f6..845ddf2 100644 --- a/composer.json +++ b/composer.json @@ -63,7 +63,7 @@ }, "autoload-dev": { "psr-4": { - "Cycle\\ORM\\Entity\\Behavior\\Tests\\": "tests/Behavior" + "Cycle\\ORM\\Entity\\Behavior\\Tests\\": "tests/" } }, "repositories": [ diff --git a/tests/Behavior/Functional/Driver/Common/BaseListenerTest.php b/tests/Behavior/Functional/Driver/Common/BaseListenerTest.php deleted file mode 100644 index d97c454..0000000 --- a/tests/Behavior/Functional/Driver/Common/BaseListenerTest.php +++ /dev/null @@ -1,52 +0,0 @@ -orm = new ORM( - new Factory( - $this->dbal, - RelationConfig::getDefault(), - null, - new ArrayCollectionFactory(), - ), - $schema, - new EventDrivenCommandGenerator($schema, new SimpleContainer()), - ); - - return $this->orm; - } - - #[\Testo\Lifecycle\AfterTest] - public function tearDown(): void - { - parent::tearDown(); - - $this->orm = null; - } - - protected function save(object ...$entities): void - { - $tr = new Transaction($this->orm); - foreach ($entities as $entity) { - $tr->persist($entity); - } - $tr->run(); - } -} diff --git a/tests/Behavior/Functional/Driver/Common/BaseTest.php b/tests/Behavior/Functional/Driver/Common/BaseTest.php deleted file mode 100644 index 4448441..0000000 --- a/tests/Behavior/Functional/Driver/Common/BaseTest.php +++ /dev/null @@ -1,99 +0,0 @@ -driver)) { - $this->driver = $config->driver::create($config); - } - - return static::$driverCache[static::DRIVER] = $this->driver; - } - - #[\Testo\Lifecycle\BeforeTest] - protected function setUp(): void - { - $this->setUpLogger($this->getDriver()); - if (self::$config['debug'] ?? false) { - $this->enableProfiling(); - } else { - $this->disableProfiling(); - } - - $this->dbal = new DatabaseManager(new DatabaseConfig()); - $this->dbal->addDatabase( - new Database( - 'default', - '', - $this->getDriver(), - ), - ); - } - - #[\Testo\Lifecycle\AfterTest] - public function tearDown(): void - { - $this->dropDatabase($this->dbal->database('default')); - - $this->dbal = null; - - if (\function_exists('gc_collect_cycles')) { - \gc_collect_cycles(); - } - } - - protected function dropDatabase(?Database $database = null): void - { - if ($database === null) { - return; - } - - foreach ($database->getTables() as $table) { - $schema = $table->getSchema(); - - foreach ($schema->getForeignKeys() as $foreign) { - $schema->dropForeignKey($foreign->getColumns()); - } - - $schema->save(Handler::DROP_FOREIGN_KEYS); - } - - foreach ($database->getTables() as $table) { - $schema = $table->getSchema(); - $schema->declareDropped(); - $schema->save(); - } - } - - protected function getDatabase(): Database - { - return $this->dbal->database('default'); - } -} diff --git a/tests/Behavior/Traits/Loggable.php b/tests/Behavior/Traits/Loggable.php deleted file mode 100644 index 3e72f2e..0000000 --- a/tests/Behavior/Traits/Loggable.php +++ /dev/null @@ -1,36 +0,0 @@ -setLogger(static::$logger); - } - - return $this; - } - - protected function enableProfiling(): void - { - static::$logger->enable(); - } - - protected function disableProfiling(): void - { - static::$logger->disable(); - } -} diff --git a/tests/Behavior/Traits/TableTrait.php b/tests/Behavior/Traits/TableTrait.php deleted file mode 100644 index c33c142..0000000 --- a/tests/Behavior/Traits/TableTrait.php +++ /dev/null @@ -1,80 +0,0 @@ -getDatabase()->table($table)->getSchema(); - $renderer = new TableRenderer(); - $renderer->renderColumns($schema, $columns, $defaults); - - foreach ($fk as $column => $options) { - if (isset($options['from'])) { - $column = $options['from']; - } - $fkState = $schema->foreignKey((array) $column)->references($options['table'], (array) $options['column']); - $fkState->onUpdate($options['onUpdate'] ?? ForeignKeyInterface::CASCADE); - $fkState->onDelete($options['onDelete'] ?? ForeignKeyInterface::CASCADE); - } - - if (!empty($pk)) { - $schema->setPrimaryKeys($pk); - } - - $schema->save(); - } - - public function makeFK( - string $from, - string|array $fromKey, - string $to, - string|array $toColumn, - string $onDelete = ForeignKeyInterface::CASCADE, - string $onUpdate = ForeignKeyInterface::CASCADE, - ): void { - $schema = $this->getDatabase()->table($from)->getSchema(); - $schema->foreignKey((array) $fromKey) - ->references($to, (array) $toColumn) - ->onDelete($onDelete) - ->onUpdate($onUpdate); - $schema->save(); - } - - public function makeCompositeFK( - string $from, - array $fromKeys, - string $to, - array $toColumns, - string $onDelete = ForeignKeyInterface::CASCADE, - string $onUpdate = ForeignKeyInterface::CASCADE, - ): void { - $schema = $this->getDatabase()->table($from)->getSchema(); - $schema->foreignKey($fromKeys)->references($to, $toColumns)->onDelete($onDelete)->onUpdate($onUpdate); - $schema->save(); - } - - public function makeIndex( - string $table, - array $columns, - bool $unique, - ): void { - $schema = $this->getDatabase()->table($table)->getSchema(); - $schema->index($columns)->unique($unique); - $schema->save(); - } - - abstract protected function getDatabase(): Database; -} diff --git a/tests/Behavior/Utils/TableRenderer.php b/tests/Behavior/Utils/TableRenderer.php deleted file mode 100644 index 1ec383b..0000000 --- a/tests/Behavior/Utils/TableRenderer.php +++ /dev/null @@ -1,193 +0,0 @@ - 'primary', - * 'time' => 'datetime, nullable', - * 'status' => 'enum(active, disabled)' - * ], - * [ - * 'status' => 'active', - * 'time' => null, - * ] - * ); - * - * @throws SchemaException - */ - public function renderColumns(AbstractTable $table, array $columns, array $defaults): void - { - $primaryKeys = []; - foreach ($columns as $name => $definition) { - $type = $this->parse($table->getName(), $name, $definition); - - if ($this->hasFlag($type, 'primary')) { - $primaryKeys[] = $name; - } - - $this->renderColumn( - $table->column($name), - $type, - \array_key_exists($name, $defaults), - $defaults[$name] ?? null, - ); - } - - if (\count($primaryKeys)) { - $table->setPrimaryKeys($primaryKeys); - } - } - - /** - * Cast (specify) column schema based on provided column definition and default value. - * Spiral will force default values (internally) for every NOT NULL column except primary keys! - * - * Column definition are compatible with database Migrations and AbstractColumn types. - * - * Column definition examples (by default all columns has flag NOT NULL): - * const SCHEMA = [ - * 'id' => 'primary', - * 'name' => 'string', //Default length is 255 characters. - * 'email' => 'string(255), nullable', //Can be NULL - * 'status' => 'enum(active, pending, disabled)', //Enum values, trimmed - * 'balance' => 'decimal(10, 2)', - * 'message' => 'text, null', //Alias for nullable - * 'time_expired' => 'timestamp' - * ]; - * - * Attention, column state will be affected! - * - * @param bool $hasDefault Must be set to true if default value was set by user. - * @param mixed $default Default value declared by record schema. - * - * @throws SchemaException - * - * @see AbstractColumn - */ - protected function renderColumn(AbstractColumn $column, array $type, bool $hasDefault, $default = null): void - { - // ORM force EVERY column to NOT NULL state unless different is said - $column->nullable(false); - - if ($this->hasFlag($type, 'null') || $this->hasFlag($type, 'nullable')) { - // indication that column is nullable - $column->nullable(true); - } - - try { - // bypassing call to AbstractColumn->__call method (or specialized column method) - \call_user_func_array([$column, $type['type']], $type['options']); - } catch (\Throwable $e) { - throw new SchemaException( - "Invalid column type definition in '{$column->getTable()}'.'{$column->getName()}'", - $e->getCode(), - $e, - ); - } - - if (\in_array($column->getAbstractType(), ['primary', 'bigPrimary'])) { - // no default value can be set of primary keys - return; - } - - if (!$hasDefault && !$column->isNullable()) { - if (!$this->hasFlag($type, 'required') && !$this->hasFlag($type, 'primary')) { - // we have to come up with some default value - $column->defaultValue($this->castDefault($column)); - } - - return; - } - - if ($default === null) { - // default value is stated and NULL, clear what to do - $column->nullable(true); - } - - $column->defaultValue($default); - } - - protected function parse(string $table, string $column, string $definition): array - { - if ( - !\preg_match( - '/(?P[a-z]+)(?: *\((?P[^\)]+)\))?(?: *, *(?P.+))?/i', - $definition, - $type, - ) - ) { - throw new SchemaException("Invalid column type definition in '{$table}'.'{$column}'"); - } - - if (empty($type['options'])) { - $type['options'] = []; - } else { - $type['options'] = \array_map('trim', \explode(',', $type['options'] ?? '')); - } - - if (empty($type['flags'])) { - $type['flags'] = []; - } else { - $type['flags'] = \array_map('trim', \explode(',', $type['flags'] ?? '')); - } - - unset($type[0], $type[1], $type[2], $type[3]); - - return $type; - } - - protected function hasFlag(array $type, string $flag): bool - { - return \in_array($flag, $type['flags'], true); - } - - /** - * Cast default value based on column type. Required to prevent conflicts when not nullable - * column added to existed table with data in. - * - * @return mixed - */ - protected function castDefault(AbstractColumn $column) - { - if (\in_array($column->getAbstractType(), ['timestamp', 'datetime', 'time', 'date'])) { - return 0; - } - - if ($column->getAbstractType() === 'enum') { - // we can use first enum value as default - return $column->getEnumValues()[0]; - } - - switch ($column->getType()) { - case 'int': - return 0; - case 'float': - return 0.0; - case 'bool': - return false; - } - - return ''; - } -} diff --git a/tests/Behavior/Utils/TestLogger.php b/tests/Behavior/Utils/TestLogger.php deleted file mode 100644 index d0bcd03..0000000 --- a/tests/Behavior/Utils/TestLogger.php +++ /dev/null @@ -1,45 +0,0 @@ -enabled = true; - } - - public function disable(): void - { - $this->enabled = false; - } - - public function log(mixed $level, mixed $message, array $context = []): void - { - if (!$this->enabled) { - return; - } - - if ($level === LogLevel::ERROR) { - echo " \n! \033[31m" . $message . "\033[0m"; - } elseif ($level === LogLevel::ALERT) { - echo " \n! \033[35m" . $message . "\033[0m"; - } elseif (\strpos($message, 'SHOW') === 0) { - echo " \n> \033[34m" . $message . "\033[0m"; - } elseif (\strpos($message, 'SELECT') === 0) { - echo " \n> \033[32m" . $message . "\033[0m"; - } else { - echo " \n> \033[33m" . $message . "\033[0m"; - } - } -} diff --git a/tests/Behavior/Functional/Driver/Common/CreatedAt/CreatedAtTest.php b/tests/Feature/Common/CreatedAt/CreatedAtTest.php similarity index 80% rename from tests/Behavior/Functional/Driver/Common/CreatedAt/CreatedAtTest.php rename to tests/Feature/Common/CreatedAt/CreatedAtTest.php index 718ae28..2a13a7e 100644 --- a/tests/Behavior/Functional/Driver/Common/CreatedAt/CreatedAtTest.php +++ b/tests/Feature/Common/CreatedAt/CreatedAtTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\CreatedAt; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\CreatedAt; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\CreatedAt\Post; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseSchemaTest; +use Cycle\ORM\Entity\Behavior\Tests\Support\SchemaTestCase; use Cycle\ORM\Schema\GeneratedField; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -abstract class CreatedAtTest extends BaseSchemaTest +final class CreatedAtTest extends SchemaTestCase { #[\Testo\Test] public function testExistenceColumn(): void @@ -38,12 +38,10 @@ public function testAddedColumn(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ - 'directories' => [\dirname(__DIR__, 4) . '/Fixtures/CreatedAt'], + 'directories' => [\dirname(__DIR__, 3) . '/Fixtures/CreatedAt'], 'exclude' => [], ]))); } diff --git a/tests/Behavior/Functional/Driver/Common/CreatedAt/ListenerTest.php b/tests/Feature/Common/CreatedAt/ListenerTest.php similarity index 88% rename from tests/Behavior/Functional/Driver/Common/CreatedAt/ListenerTest.php rename to tests/Feature/Common/CreatedAt/ListenerTest.php index 564c5f0..b703228 100644 --- a/tests/Behavior/Functional/Driver/Common/CreatedAt/ListenerTest.php +++ b/tests/Feature/Common/CreatedAt/ListenerTest.php @@ -2,21 +2,18 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\CreatedAt; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\CreatedAt; use Cycle\ORM\Entity\Behavior\Listener\CreatedAt; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\CreatedAt\Post; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseListenerTest; -use Cycle\ORM\Entity\Behavior\Tests\Traits\TableTrait; +use Cycle\ORM\Entity\Behavior\Tests\Support\ListenerTestCase; use Cycle\ORM\Heap\Heap; use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; -abstract class ListenerTest extends BaseListenerTest +final class ListenerTest extends ListenerTestCase { - use TableTrait; - #[\Testo\Test] public function testCreate(): void { @@ -56,10 +53,8 @@ public function testUpdate(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->makeTable( 'posts', [ diff --git a/tests/Behavior/Functional/Driver/Common/EventListener/EventListenerTest.php b/tests/Feature/Common/EventListener/EventListenerTest.php similarity index 80% rename from tests/Behavior/Functional/Driver/Common/EventListener/EventListenerTest.php rename to tests/Feature/Common/EventListener/EventListenerTest.php index b8cd7ec..0a57e57 100644 --- a/tests/Behavior/Functional/Driver/Common/EventListener/EventListenerTest.php +++ b/tests/Feature/Common/EventListener/EventListenerTest.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\EventListener; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\EventListener; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\CommentService; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\EventListener\Comment; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\EventListener\Post; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\PostService; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseSchemaTest; +use Cycle\ORM\Entity\Behavior\Tests\Support\SchemaTestCase; use Cycle\ORM\SchemaInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -abstract class EventListenerTest extends BaseSchemaTest +final class EventListenerTest extends SchemaTestCase { #[\Testo\Test] public function testSchemaWithArgs(): void @@ -37,12 +37,10 @@ public function testSchema(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ - 'directories' => [\dirname(__DIR__, 4) . '/Fixtures/EventListener'], + 'directories' => [\dirname(__DIR__, 3) . '/Fixtures/EventListener'], 'exclude' => [], ]))); } diff --git a/tests/Behavior/Functional/Driver/Common/EventListener/ListenerTest.php b/tests/Feature/Common/EventListener/ListenerTest.php similarity index 82% rename from tests/Behavior/Functional/Driver/Common/EventListener/ListenerTest.php rename to tests/Feature/Common/EventListener/ListenerTest.php index 7cd3050..4bc5d99 100644 --- a/tests/Behavior/Functional/Driver/Common/EventListener/ListenerTest.php +++ b/tests/Feature/Common/EventListener/ListenerTest.php @@ -2,21 +2,18 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\EventListener; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\EventListener; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\EventListener\Post; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\PostService; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseListenerTest; -use Cycle\ORM\Entity\Behavior\Tests\Traits\TableTrait; +use Cycle\ORM\Entity\Behavior\Tests\Support\ListenerTestCase; use Cycle\ORM\Heap\Heap; use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; -abstract class ListenerTest extends BaseListenerTest +final class ListenerTest extends ListenerTestCase { - use TableTrait; - #[\Testo\Test] public function testApply(): void { @@ -32,10 +29,8 @@ public function testApply(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->makeTable( 'posts', [ diff --git a/tests/Behavior/Functional/Driver/Common/Hook/HookTest.php b/tests/Feature/Common/Hook/HookTest.php similarity index 80% rename from tests/Behavior/Functional/Driver/Common/Hook/HookTest.php rename to tests/Feature/Common/Hook/HookTest.php index 94291fe..78c3ebc 100644 --- a/tests/Behavior/Functional/Driver/Common/Hook/HookTest.php +++ b/tests/Feature/Common/Hook/HookTest.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Hook; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\Hook; use Cycle\ORM\Entity\Behavior\Event\Mapper\Command\OnCreate; use Cycle\ORM\Entity\Behavior\Event\Mapper\Command\OnUpdate; use Cycle\ORM\Entity\Behavior\Listener\Hook; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\Hook\Post; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\PostService; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseSchemaTest; +use Cycle\ORM\Entity\Behavior\Tests\Support\SchemaTestCase; use Cycle\ORM\SchemaInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -abstract class HookTest extends BaseSchemaTest +final class HookTest extends SchemaTestCase { #[\Testo\Test] public function testAddListener(): void @@ -34,12 +34,10 @@ public function testAddListener(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ - 'directories' => [\dirname(__DIR__, 4) . '/Fixtures/Hook'], + 'directories' => [\dirname(__DIR__, 3) . '/Fixtures/Hook'], 'exclude' => [], ]))); } diff --git a/tests/Behavior/Functional/Driver/Common/Hook/ListenerTest.php b/tests/Feature/Common/Hook/ListenerTest.php similarity index 92% rename from tests/Behavior/Functional/Driver/Common/Hook/ListenerTest.php rename to tests/Feature/Common/Hook/ListenerTest.php index 8f9eba1..02ad83e 100644 --- a/tests/Behavior/Functional/Driver/Common/Hook/ListenerTest.php +++ b/tests/Feature/Common/Hook/ListenerTest.php @@ -2,24 +2,21 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Hook; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\Hook; use Cycle\ORM\Entity\Behavior\Event\Mapper\Command\OnCreate; use Cycle\ORM\Entity\Behavior\Event\Mapper\Command\OnUpdate; use Cycle\ORM\Entity\Behavior\Listener\Hook; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\Hook\Post; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\PostService; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseListenerTest; -use Cycle\ORM\Entity\Behavior\Tests\Traits\TableTrait; +use Cycle\ORM\Entity\Behavior\Tests\Support\ListenerTestCase; use Cycle\ORM\Heap\Heap; use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; -abstract class ListenerTest extends BaseListenerTest +final class ListenerTest extends ListenerTestCase { - use TableTrait; - #[\Testo\Test] public function testCreate(): void { @@ -66,10 +63,8 @@ public function testUpdate(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->makeTable( 'posts', [ diff --git a/tests/Behavior/Functional/Driver/Common/OptimisticLock/InquiredRelationTest.php b/tests/Feature/Common/OptimisticLock/InquiredRelationTest.php similarity index 77% rename from tests/Behavior/Functional/Driver/Common/OptimisticLock/InquiredRelationTest.php rename to tests/Feature/Common/OptimisticLock/InquiredRelationTest.php index 19e6200..e8cef50 100644 --- a/tests/Behavior/Functional/Driver/Common/OptimisticLock/InquiredRelationTest.php +++ b/tests/Feature/Common/OptimisticLock/InquiredRelationTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\OptimisticLock; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\OptimisticLock; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -10,16 +10,9 @@ use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; -use Cycle\ORM\Collection\ArrayCollectionFactory; -use Cycle\ORM\Config\RelationConfig; -use Cycle\ORM\Entity\Behavior\EventDrivenCommandGenerator; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\OptimisticLock\InquiredRelations\Product; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\OptimisticLock\InquiredRelations\ProductBox; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseListenerTest; -use Cycle\ORM\Entity\Behavior\Tests\Traits\TableTrait; -use Cycle\ORM\Entity\Behavior\Tests\Utils\SimpleContainer; -use Cycle\ORM\Factory; -use Cycle\ORM\ORM; +use Cycle\ORM\Entity\Behavior\Tests\Support\ListenerTestCase; use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; use Cycle\Schema\Compiler; @@ -37,10 +30,8 @@ use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -abstract class InquiredRelationTest extends BaseListenerTest +final class InquiredRelationTest extends ListenerTestCase { - use TableTrait; - #[\Testo\Test] public function testUpdateWithSelectCollection(): void { @@ -84,25 +75,14 @@ public function testUpdateWithSelectCollection(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $schema = $this->compileSchema(new Tokenizer(new TokenizerConfig([ - 'directories' => [\dirname(__DIR__, 4) . '/Fixtures/OptimisticLock/InquiredRelations'], + 'directories' => [\dirname(__DIR__, 3) . '/Fixtures/OptimisticLock/InquiredRelations'], 'exclude' => [], ]))); - $this->orm = new ORM( - new Factory( - $this->dbal, - RelationConfig::getDefault(), - null, - new ArrayCollectionFactory(), - ), - $schema, - new EventDrivenCommandGenerator($schema, new SimpleContainer()), - ); + $this->withSchema($schema); } private function compileSchema(Tokenizer $tokenizer): SchemaInterface diff --git a/tests/Behavior/Functional/Driver/Common/OptimisticLock/ListenerTest.php b/tests/Feature/Common/OptimisticLock/ListenerTest.php similarity index 95% rename from tests/Behavior/Functional/Driver/Common/OptimisticLock/ListenerTest.php rename to tests/Feature/Common/OptimisticLock/ListenerTest.php index 4d3277f..c4636b9 100644 --- a/tests/Behavior/Functional/Driver/Common/OptimisticLock/ListenerTest.php +++ b/tests/Feature/Common/OptimisticLock/ListenerTest.php @@ -2,15 +2,14 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\OptimisticLock; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\OptimisticLock; use Cycle\ORM\Entity\Behavior\Exception\OptimisticLock\ChangedVersionException; use Cycle\ORM\Entity\Behavior\Exception\OptimisticLock\RecordIsLockedException; use Cycle\ORM\Entity\Behavior\Listener\OptimisticLock; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\OptimisticLock\Author; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\OptimisticLock\Comment; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseListenerTest; -use Cycle\ORM\Entity\Behavior\Tests\Traits\TableTrait; +use Cycle\ORM\Entity\Behavior\Tests\Support\ListenerTestCase; use Cycle\ORM\Heap\Heap; use Cycle\ORM\Relation; use Cycle\ORM\Schema; @@ -18,10 +17,8 @@ use Cycle\ORM\Select; use Cycle\ORM\Transaction; -abstract class ListenerTest extends BaseListenerTest +final class ListenerTest extends ListenerTestCase { - use TableTrait; - #[\Testo\Test] public function testAddVersionOnCreate(): void { @@ -156,10 +153,8 @@ public function testLock(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->makeTable( 'comments', [ diff --git a/tests/Behavior/Functional/Driver/Common/OptimisticLock/OptimisticLockTest.php b/tests/Feature/Common/OptimisticLock/OptimisticLockTest.php similarity index 92% rename from tests/Behavior/Functional/Driver/Common/OptimisticLock/OptimisticLockTest.php rename to tests/Feature/Common/OptimisticLock/OptimisticLockTest.php index e848288..fbc9d58 100644 --- a/tests/Behavior/Functional/Driver/Common/OptimisticLock/OptimisticLockTest.php +++ b/tests/Feature/Common/OptimisticLock/OptimisticLockTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\OptimisticLock; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\OptimisticLock; use Cycle\Database\ColumnInterface; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\OptimisticLock\Comment; @@ -11,12 +11,12 @@ use Cycle\ORM\Entity\Behavior\Tests\Fixtures\OptimisticLock\Page; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\OptimisticLock\Post; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\OptimisticLock\WithAllParameters; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseSchemaTest; +use Cycle\ORM\Entity\Behavior\Tests\Support\SchemaTestCase; use Cycle\ORM\Schema\GeneratedField; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -abstract class OptimisticLockTest extends BaseSchemaTest +final class OptimisticLockTest extends SchemaTestCase { #[\Testo\Test] public function testAddIntColumn(): void @@ -93,12 +93,10 @@ public function testAddDefaultColumAndRule(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ - 'directories' => [\dirname(__DIR__, 4) . '/Fixtures/OptimisticLock'], + 'directories' => [\dirname(__DIR__, 3) . '/Fixtures/OptimisticLock'], 'exclude' => [], ]))); } diff --git a/tests/Behavior/Functional/Driver/Common/Schema/ErrorsTest.php b/tests/Feature/Common/Schema/ErrorsTest.php similarity index 77% rename from tests/Behavior/Functional/Driver/Common/Schema/ErrorsTest.php rename to tests/Feature/Common/Schema/ErrorsTest.php index 921f20a..66f1c59 100644 --- a/tests/Behavior/Functional/Driver/Common/Schema/ErrorsTest.php +++ b/tests/Feature/Common/Schema/ErrorsTest.php @@ -2,28 +2,28 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Schema; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\Schema; use Cycle\ORM\Entity\Behavior\Exception\BehaviorCompilationException; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseSchemaTest; +use Cycle\ORM\Entity\Behavior\Tests\Support\SchemaTestCase; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -abstract class ErrorsTest extends BaseSchemaTest +final class ErrorsTest extends SchemaTestCase { public static function errorsProvider(): array { return [ 'Field type' => [ new Tokenizer(new TokenizerConfig([ - 'directories' => [\dirname(__DIR__, 4) . '/Fixtures/Wrong/FieldType'], + 'directories' => [\dirname(__DIR__, 3) . '/Fixtures/Wrong/FieldType'], 'exclude' => [], ])), 'Field wrongCreatedAt must be of type datetime.', ], 'Column name' => [ new Tokenizer(new TokenizerConfig([ - 'directories' => [\dirname(__DIR__, 4) . '/Fixtures/Wrong/ColumnName'], + 'directories' => [\dirname(__DIR__, 3) . '/Fixtures/Wrong/ColumnName'], 'exclude' => [], ])), 'Ambiguous column name definition. The `updatedAt` field already linked with the `custom_updated_at`', diff --git a/tests/Behavior/Functional/Driver/Common/Schema/RegistryModifierTest.php b/tests/Feature/Common/Schema/RegistryModifierTest.php similarity index 97% rename from tests/Behavior/Functional/Driver/Common/Schema/RegistryModifierTest.php rename to tests/Feature/Common/Schema/RegistryModifierTest.php index 670ed0c..e97017c 100644 --- a/tests/Behavior/Functional/Driver/Common/Schema/RegistryModifierTest.php +++ b/tests/Feature/Common/Schema/RegistryModifierTest.php @@ -2,20 +2,20 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Schema; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\Schema; use Cycle\Database\ColumnInterface; use Cycle\ORM\Entity\Behavior\Exception\BehaviorCompilationException; use Cycle\ORM\Entity\Behavior\Schema\RegistryModifier; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\CustomTypecast; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseTest; +use Cycle\Testing\Database\DatabaseTestCase; use Cycle\ORM\Parser\Typecast; use Cycle\ORM\SchemaInterface; use Cycle\Schema\Definition\Entity; use Cycle\Schema\Registry; use Ramsey\Uuid\Uuid; -abstract class RegistryModifierTest extends BaseTest +final class RegistryModifierTest extends DatabaseTestCase { private const ROLE_TEST = 'test'; @@ -228,10 +228,8 @@ public function testCustomTypecastNotOverridden(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->registry = new Registry($this->dbal); $entity = (new Entity())->setRole(self::ROLE_TEST); diff --git a/tests/Behavior/Functional/Driver/Common/SoftDelete/ListenerTest.php b/tests/Feature/Common/SoftDelete/ListenerTest.php similarity index 87% rename from tests/Behavior/Functional/Driver/Common/SoftDelete/ListenerTest.php rename to tests/Feature/Common/SoftDelete/ListenerTest.php index ec11e03..e01ddaf 100644 --- a/tests/Behavior/Functional/Driver/Common/SoftDelete/ListenerTest.php +++ b/tests/Feature/Common/SoftDelete/ListenerTest.php @@ -2,22 +2,19 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\SoftDelete; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\SoftDelete; use Cycle\ORM\Entity\Behavior\Listener\SoftDelete; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\SoftDelete\Post; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseListenerTest; -use Cycle\ORM\Entity\Behavior\Tests\Traits\TableTrait; +use Cycle\ORM\Entity\Behavior\Tests\Support\ListenerTestCase; use Cycle\ORM\Heap\Heap; use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; use Cycle\ORM\Transaction; -abstract class ListenerTest extends BaseListenerTest +final class ListenerTest extends ListenerTestCase { - use TableTrait; - #[\Testo\Test] public function testDelete(): void { @@ -42,10 +39,8 @@ public function testDelete(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->makeTable( 'posts', [ diff --git a/tests/Behavior/Functional/Driver/Common/SoftDelete/SoftDeleteTest.php b/tests/Feature/Common/SoftDelete/SoftDeleteTest.php similarity index 80% rename from tests/Behavior/Functional/Driver/Common/SoftDelete/SoftDeleteTest.php rename to tests/Feature/Common/SoftDelete/SoftDeleteTest.php index 974ac84..794b004 100644 --- a/tests/Behavior/Functional/Driver/Common/SoftDelete/SoftDeleteTest.php +++ b/tests/Feature/Common/SoftDelete/SoftDeleteTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\SoftDelete; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\SoftDelete; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\SoftDelete\Post; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseSchemaTest; +use Cycle\ORM\Entity\Behavior\Tests\Support\SchemaTestCase; use Cycle\ORM\Schema\GeneratedField; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -abstract class SoftDeleteTest extends BaseSchemaTest +final class SoftDeleteTest extends SchemaTestCase { #[\Testo\Test] public function testExistenceColumn(): void @@ -38,12 +38,10 @@ public function testAddedColumn(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ - 'directories' => [\dirname(__DIR__, 4) . '/Fixtures/SoftDelete'], + 'directories' => [\dirname(__DIR__, 3) . '/Fixtures/SoftDelete'], 'exclude' => [], ]))); } diff --git a/tests/Behavior/Functional/Driver/Common/UpdatedAt/ListenerTest.php b/tests/Feature/Common/UpdatedAt/ListenerTest.php similarity index 91% rename from tests/Behavior/Functional/Driver/Common/UpdatedAt/ListenerTest.php rename to tests/Feature/Common/UpdatedAt/ListenerTest.php index 22f94f7..2156e3b 100644 --- a/tests/Behavior/Functional/Driver/Common/UpdatedAt/ListenerTest.php +++ b/tests/Feature/Common/UpdatedAt/ListenerTest.php @@ -2,21 +2,18 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\UpdatedAt; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\UpdatedAt; use Cycle\ORM\Entity\Behavior\Listener\UpdatedAt; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\UpdatedAt\Post; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseListenerTest; -use Cycle\ORM\Entity\Behavior\Tests\Traits\TableTrait; +use Cycle\ORM\Entity\Behavior\Tests\Support\ListenerTestCase; use Cycle\ORM\Heap\Heap; use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; -abstract class ListenerTest extends BaseListenerTest +final class ListenerTest extends ListenerTestCase { - use TableTrait; - #[\Testo\Test] public function testCreate(): void { @@ -69,10 +66,8 @@ public function testUpdate(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->makeTable( 'posts', [ diff --git a/tests/Behavior/Functional/Driver/Common/UpdatedAt/UpdatedAtTest.php b/tests/Feature/Common/UpdatedAt/UpdatedAtTest.php similarity index 81% rename from tests/Behavior/Functional/Driver/Common/UpdatedAt/UpdatedAtTest.php rename to tests/Feature/Common/UpdatedAt/UpdatedAtTest.php index 9778b04..ebf16c6 100644 --- a/tests/Behavior/Functional/Driver/Common/UpdatedAt/UpdatedAtTest.php +++ b/tests/Feature/Common/UpdatedAt/UpdatedAtTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\UpdatedAt; +namespace Cycle\ORM\Entity\Behavior\Tests\Feature\Common\UpdatedAt; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\UpdatedAt\Post; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseSchemaTest; +use Cycle\ORM\Entity\Behavior\Tests\Support\SchemaTestCase; use Cycle\ORM\Schema\GeneratedField; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -abstract class UpdatedAtTest extends BaseSchemaTest +final class UpdatedAtTest extends SchemaTestCase { #[\Testo\Test] public function testExistenceColumn(): void @@ -38,12 +38,10 @@ public function testAddedColumn(): void } #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + protected function setUp(): void { - parent::setUp(); - $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ - 'directories' => [\dirname(__DIR__, 4) . '/Fixtures/UpdatedAt'], + 'directories' => [\dirname(__DIR__, 3) . '/Fixtures/UpdatedAt'], 'exclude' => [], ]))); } diff --git a/tests/Behavior/Fixtures/CommentService.php b/tests/Fixtures/CommentService.php similarity index 100% rename from tests/Behavior/Fixtures/CommentService.php rename to tests/Fixtures/CommentService.php diff --git a/tests/Behavior/Fixtures/CreatedAt/Post.php b/tests/Fixtures/CreatedAt/Post.php similarity index 100% rename from tests/Behavior/Fixtures/CreatedAt/Post.php rename to tests/Fixtures/CreatedAt/Post.php diff --git a/tests/Behavior/Fixtures/CustomTypecast.php b/tests/Fixtures/CustomTypecast.php similarity index 100% rename from tests/Behavior/Fixtures/CustomTypecast.php rename to tests/Fixtures/CustomTypecast.php diff --git a/tests/Behavior/Fixtures/EventListener/Comment.php b/tests/Fixtures/EventListener/Comment.php similarity index 100% rename from tests/Behavior/Fixtures/EventListener/Comment.php rename to tests/Fixtures/EventListener/Comment.php diff --git a/tests/Behavior/Fixtures/EventListener/Post.php b/tests/Fixtures/EventListener/Post.php similarity index 100% rename from tests/Behavior/Fixtures/EventListener/Post.php rename to tests/Fixtures/EventListener/Post.php diff --git a/tests/Behavior/Fixtures/Hook/Post.php b/tests/Fixtures/Hook/Post.php similarity index 100% rename from tests/Behavior/Fixtures/Hook/Post.php rename to tests/Fixtures/Hook/Post.php diff --git a/tests/Behavior/Fixtures/OptimisticLock/Author.php b/tests/Fixtures/OptimisticLock/Author.php similarity index 100% rename from tests/Behavior/Fixtures/OptimisticLock/Author.php rename to tests/Fixtures/OptimisticLock/Author.php diff --git a/tests/Behavior/Fixtures/OptimisticLock/Comment.php b/tests/Fixtures/OptimisticLock/Comment.php similarity index 100% rename from tests/Behavior/Fixtures/OptimisticLock/Comment.php rename to tests/Fixtures/OptimisticLock/Comment.php diff --git a/tests/Behavior/Fixtures/OptimisticLock/InquiredRelations/Product.php b/tests/Fixtures/OptimisticLock/InquiredRelations/Product.php similarity index 100% rename from tests/Behavior/Fixtures/OptimisticLock/InquiredRelations/Product.php rename to tests/Fixtures/OptimisticLock/InquiredRelations/Product.php diff --git a/tests/Behavior/Fixtures/OptimisticLock/InquiredRelations/ProductBox.php b/tests/Fixtures/OptimisticLock/InquiredRelations/ProductBox.php similarity index 100% rename from tests/Behavior/Fixtures/OptimisticLock/InquiredRelations/ProductBox.php rename to tests/Fixtures/OptimisticLock/InquiredRelations/ProductBox.php diff --git a/tests/Behavior/Fixtures/OptimisticLock/Item.php b/tests/Fixtures/OptimisticLock/Item.php similarity index 100% rename from tests/Behavior/Fixtures/OptimisticLock/Item.php rename to tests/Fixtures/OptimisticLock/Item.php diff --git a/tests/Behavior/Fixtures/OptimisticLock/News.php b/tests/Fixtures/OptimisticLock/News.php similarity index 100% rename from tests/Behavior/Fixtures/OptimisticLock/News.php rename to tests/Fixtures/OptimisticLock/News.php diff --git a/tests/Behavior/Fixtures/OptimisticLock/Page.php b/tests/Fixtures/OptimisticLock/Page.php similarity index 100% rename from tests/Behavior/Fixtures/OptimisticLock/Page.php rename to tests/Fixtures/OptimisticLock/Page.php diff --git a/tests/Behavior/Fixtures/OptimisticLock/Post.php b/tests/Fixtures/OptimisticLock/Post.php similarity index 100% rename from tests/Behavior/Fixtures/OptimisticLock/Post.php rename to tests/Fixtures/OptimisticLock/Post.php diff --git a/tests/Behavior/Fixtures/OptimisticLock/WithAllParameters.php b/tests/Fixtures/OptimisticLock/WithAllParameters.php similarity index 100% rename from tests/Behavior/Fixtures/OptimisticLock/WithAllParameters.php rename to tests/Fixtures/OptimisticLock/WithAllParameters.php diff --git a/tests/Behavior/Fixtures/PostService.php b/tests/Fixtures/PostService.php similarity index 100% rename from tests/Behavior/Fixtures/PostService.php rename to tests/Fixtures/PostService.php diff --git a/tests/Behavior/Fixtures/SoftDelete/Post.php b/tests/Fixtures/SoftDelete/Post.php similarity index 100% rename from tests/Behavior/Fixtures/SoftDelete/Post.php rename to tests/Fixtures/SoftDelete/Post.php diff --git a/tests/Behavior/Fixtures/UpdatedAt/Post.php b/tests/Fixtures/UpdatedAt/Post.php similarity index 100% rename from tests/Behavior/Fixtures/UpdatedAt/Post.php rename to tests/Fixtures/UpdatedAt/Post.php diff --git a/tests/Behavior/Fixtures/Wrong/ColumnName/User.php b/tests/Fixtures/Wrong/ColumnName/User.php similarity index 100% rename from tests/Behavior/Fixtures/Wrong/ColumnName/User.php rename to tests/Fixtures/Wrong/ColumnName/User.php diff --git a/tests/Behavior/Fixtures/Wrong/FieldType/User.php b/tests/Fixtures/Wrong/FieldType/User.php similarity index 100% rename from tests/Behavior/Fixtures/Wrong/FieldType/User.php rename to tests/Fixtures/Wrong/FieldType/User.php diff --git a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/CaseTest.php b/tests/Regression/CaseTemplate/CaseTest.php similarity index 93% rename from tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/CaseTest.php rename to tests/Regression/CaseTemplate/CaseTest.php index 7e79390..c1e27fc 100644 --- a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/CaseTest.php +++ b/tests/Regression/CaseTemplate/CaseTest.php @@ -2,16 +2,13 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Integration\CaseTemplate; +namespace Cycle\ORM\Entity\Behavior\Tests\Regression\CaseTemplate; -use Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Integration\BaseTest; -use Cycle\ORM\Entity\Behavior\Tests\Traits\TableTrait; +use Cycle\ORM\Entity\Behavior\Tests\Support\IntegrationTestCase; use Cycle\ORM\Select; -abstract class CaseTest extends BaseTest +final class CaseTest extends IntegrationTestCase { - use TableTrait; - #[\Testo\Test] public function testPreparedData(): void { @@ -69,8 +66,6 @@ public function testUpdatedAt(): void #[\Testo\Lifecycle\BeforeTest] protected function setUp(): void { - // Init DB - parent::setUp(); $this->prepareOrm(__DIR__ . '/Entity'); $this->save(...$this->fillData()); $this->orm->getHeap()->clean(); diff --git a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/Comment.php b/tests/Regression/CaseTemplate/Entity/Comment.php similarity index 93% rename from tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/Comment.php rename to tests/Regression/CaseTemplate/Entity/Comment.php index 95e547b..f42fbab 100644 --- a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/Comment.php +++ b/tests/Regression/CaseTemplate/Entity/Comment.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Integration\CaseTemplate\Entity; +namespace Cycle\ORM\Entity\Behavior\Tests\Regression\CaseTemplate\Entity; use Cycle\Annotated\Annotation\Column; use Cycle\Annotated\Annotation\Entity; diff --git a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/Post.php b/tests/Regression/CaseTemplate/Entity/Post.php similarity index 95% rename from tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/Post.php rename to tests/Regression/CaseTemplate/Entity/Post.php index 0652de4..27cb4a7 100644 --- a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/Post.php +++ b/tests/Regression/CaseTemplate/Entity/Post.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Integration\CaseTemplate\Entity; +namespace Cycle\ORM\Entity\Behavior\Tests\Regression\CaseTemplate\Entity; use Cycle\Annotated\Annotation\Column; use Cycle\Annotated\Annotation\Entity; diff --git a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/PostTag.php b/tests/Regression/CaseTemplate/Entity/PostTag.php similarity index 80% rename from tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/PostTag.php rename to tests/Regression/CaseTemplate/Entity/PostTag.php index f26ca38..fed1fd3 100644 --- a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/PostTag.php +++ b/tests/Regression/CaseTemplate/Entity/PostTag.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Integration\CaseTemplate\Entity; +namespace Cycle\ORM\Entity\Behavior\Tests\Regression\CaseTemplate\Entity; use Cycle\Annotated\Annotation\Column; use Cycle\Annotated\Annotation\Entity; diff --git a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/Tag.php b/tests/Regression/CaseTemplate/Entity/Tag.php similarity index 88% rename from tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/Tag.php rename to tests/Regression/CaseTemplate/Entity/Tag.php index 4c94c58..0133a49 100644 --- a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/Tag.php +++ b/tests/Regression/CaseTemplate/Entity/Tag.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Integration\CaseTemplate\Entity; +namespace Cycle\ORM\Entity\Behavior\Tests\Regression\CaseTemplate\Entity; use Cycle\Annotated\Annotation\Column; use Cycle\Annotated\Annotation\Entity; diff --git a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/User.php b/tests/Regression/CaseTemplate/Entity/User.php similarity index 91% rename from tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/User.php rename to tests/Regression/CaseTemplate/Entity/User.php index 736fc1d..47025e8 100644 --- a/tests/Behavior/Functional/Driver/Common/Integration/CaseTemplate/Entity/User.php +++ b/tests/Regression/CaseTemplate/Entity/User.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Integration\CaseTemplate\Entity; +namespace Cycle\ORM\Entity\Behavior\Tests\Regression\CaseTemplate\Entity; use Cycle\Annotated\Annotation\Column; use Cycle\Annotated\Annotation\Entity; diff --git a/tests/Behavior/Functional/Driver/Common/Integration/BaseTest.php b/tests/Support/IntegrationTestCase.php similarity index 67% rename from tests/Behavior/Functional/Driver/Common/Integration/BaseTest.php rename to tests/Support/IntegrationTestCase.php index 2f69390..d87bf5f 100644 --- a/tests/Behavior/Functional/Driver/Common/Integration/BaseTest.php +++ b/tests/Support/IntegrationTestCase.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\Integration; +namespace Cycle\ORM\Entity\Behavior\Tests\Support; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -11,15 +11,7 @@ use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; use Cycle\Annotated\TableInheritance; -use Cycle\ORM\Collection\ArrayCollectionFactory; -use Cycle\ORM\Config\RelationConfig; -use Cycle\ORM\Entity\Behavior\EventDrivenCommandGenerator; -use Cycle\ORM\Entity\Behavior\Tests\Utils\SimpleContainer; -use Cycle\ORM\Factory; -use Cycle\ORM\ORM; -use Cycle\ORM\ORMInterface; use Cycle\ORM\Schema; -use Cycle\ORM\SchemaInterface; use Cycle\ORM\Transaction\UnitOfWork; use Cycle\Schema\Compiler; use Cycle\Schema\Generator\ForeignKeys; @@ -37,19 +29,11 @@ use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -abstract class BaseTest extends \Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseTest +/** + * Base of the regression cases: compiles the case's entities, creates their tables and builds the ORM. + */ +abstract class IntegrationTestCase extends ListenerTestCase { - protected SchemaInterface $schema; - protected ORMInterface $orm; - - #[\Testo\Lifecycle\AfterTest] - public function tearDown(): void - { - $this->disableProfiling(); - unset($this->orm, $this->schema); - parent::tearDown(); - } - /** * @param non-empty-array|non-empty-string $entitiesPath */ @@ -64,7 +48,7 @@ protected function prepareOrm(string|array $entitiesPath): void $classLocator = $tokenizer->classLocator(); - $this->schema = new Schema((new Compiler())->compile(new Registry($this->dbal), [ + $this->withSchema(new Schema((new Compiler())->compile(new Registry($this->dbal), [ new ResetTables(), new Embeddings(new TokenizerEmbeddingLocator($classLocator, $reader), $reader), new Entities(new TokenizerEntityLocator($classLocator, $reader), $reader), @@ -80,18 +64,7 @@ protected function prepareOrm(string|array $entitiesPath): void new MergeIndexes($reader), new SyncTables(), new GenerateTypecast(), - ])); - - $this->orm = new ORM( - new Factory( - $this->dbal, - RelationConfig::getDefault(), - null, - new ArrayCollectionFactory(), - ), - $this->schema, - new EventDrivenCommandGenerator($this->schema, new SimpleContainer()), - ); + ]))); } protected function save(object ...$entities): void diff --git a/tests/Support/ListenerTestCase.php b/tests/Support/ListenerTestCase.php new file mode 100644 index 0000000..32269fd --- /dev/null +++ b/tests/Support/ListenerTestCase.php @@ -0,0 +1,32 @@ +orm = new ORM( + new Factory($this->dbal, RelationConfig::getDefault(), null, new ArrayCollectionFactory()), + $schema, + new EventDrivenCommandGenerator($schema, new SimpleContainer()), + ); + } +} diff --git a/tests/Behavior/Functional/Driver/Common/BaseSchemaTest.php b/tests/Support/SchemaTestCase.php similarity index 77% rename from tests/Behavior/Functional/Driver/Common/BaseSchemaTest.php rename to tests/Support/SchemaTestCase.php index a3ff2f6..bf17e03 100644 --- a/tests/Behavior/Functional/Driver/Common/BaseSchemaTest.php +++ b/tests/Support/SchemaTestCase.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common; +namespace Cycle\ORM\Entity\Behavior\Tests\Support; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -22,15 +22,19 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\ValidateEntities; use Cycle\Schema\Registry; +use Cycle\Testing\Database\DatabaseTestCase; use Spiral\Attributes\AttributeReader; use Spiral\Tokenizer\Tokenizer; -abstract class BaseSchemaTest extends BaseTest +/** + * Compiles the annotated entities of a directory without creating tables. + */ +abstract class SchemaTestCase extends DatabaseTestCase { - protected ?Registry $registry = null; - protected ?SchemaInterface $schema = null; + protected Registry $registry; + protected SchemaInterface $schema; - public function compileWithTokenizer(Tokenizer $tokenizer): void + protected function compileWithTokenizer(Tokenizer $tokenizer): void { $reader = new AttributeReader(); @@ -51,13 +55,4 @@ public function compileWithTokenizer(Tokenizer $tokenizer): void new GenerateTypecast(), ])); } - - #[\Testo\Lifecycle\AfterTest] - public function tearDown(): void - { - parent::tearDown(); - - $this->schema = null; - $this->registry = null; - } } diff --git a/tests/Behavior/Utils/SimpleContainer.php b/tests/Support/SimpleContainer.php similarity index 96% rename from tests/Behavior/Utils/SimpleContainer.php rename to tests/Support/SimpleContainer.php index 67ebbd9..d2c3a83 100644 --- a/tests/Behavior/Utils/SimpleContainer.php +++ b/tests/Support/SimpleContainer.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\ORM\Entity\Behavior\Tests\Utils; +namespace Cycle\ORM\Entity\Behavior\Tests\Support; use Closure; use Psr\Container\ContainerInterface; diff --git a/tests/Behavior/Unit/Schema/RegistryModifierTest.php b/tests/Unit/Schema/RegistryModifierTest.php similarity index 100% rename from tests/Behavior/Unit/Schema/RegistryModifierTest.php rename to tests/Unit/Schema/RegistryModifierTest.php diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index b44ce1f..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,74 +0,0 @@ - new Database\Config\SQLiteDriverConfig( - queryCache: true, - options: [ - 'logInterpolatedQueries' => true, - ], - ), - 'mysql' => new Database\Config\MySQLDriverConfig( - connection: new Database\Config\MySQL\TcpConnectionConfig( - database: 'spiral', - host: '127.0.0.1', - port: 13306, - user: 'root', - password: 'YourStrong!Passw0rd', - ), - queryCache: true, - options: [ - 'logInterpolatedQueries' => true, - ], - ), - 'postgres' => new Database\Config\PostgresDriverConfig( - connection: new Database\Config\Postgres\TcpConnectionConfig( - database: 'spiral', - host: '127.0.0.1', - port: 15432, - user: 'postgres', - password: 'YourStrong!Passw0rd', - ), - schema: 'public', - queryCache: true, - options: [ - 'logInterpolatedQueries' => true, - ], - ), - 'sqlserver' => new Database\Config\SQLServerDriverConfig( - connection: new Database\Config\SQLServer\TcpConnectionConfig( - database: 'tempdb', - host: '127.0.0.1', - port: 11433, - trustServerCertificate: true, - user: 'SA', - password: 'YourStrong!Passw0rd', - ), - queryCache: true, - options: [ - 'logInterpolatedQueries' => true, - ], - ), -]; - -$db = \getenv('DB') ?: null; -\Cycle\ORM\Entity\Behavior\Tests\Functional\Driver\Common\BaseTest::$config = [ - 'debug' => \getenv('DB_DEBUG') ?: false, -] + ( - $db === null - ? $drivers - : \array_intersect_key($drivers, \array_flip((array) $db)) -); diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml deleted file mode 100644 index 4a6c6c1..0000000 --- a/tests/docker-compose.yml +++ /dev/null @@ -1,27 +0,0 @@ -services: - sqlserver: - image: mcr.microsoft.com/mssql/server:2019-latest - ports: - - "11433:1433" - environment: - SA_PASSWORD: "YourStrong!Passw0rd" - ACCEPT_EULA: "Y" - - mysql_latest: - image: mysql:8.0 - command: --default-authentication-plugin=mysql_native_password - ports: - - "13306:3306" - environment: - MYSQL_DATABASE: "spiral" - MYSQL_ROOT_PASSWORD: "YourStrong!Passw0rd" - MYSQL_ROOT_HOST: "%" - - postgres: - image: postgres:12 - ports: - - "15432:5432" - environment: - POSTGRES_DB: "spiral" - POSTGRES_USER: "postgres" - POSTGRES_PASSWORD: "YourStrong!Passw0rd" diff --git a/tests/generate-case.php b/tests/generate-case.php index 2ea6030..9e6495f 100644 --- a/tests/generate-case.php +++ b/tests/generate-case.php @@ -8,13 +8,13 @@ declare(strict_types=1); -\error_reporting(E_ALL | E_STRICT); +\error_reporting(E_ALL); \ini_set('display_errors', '1'); //Composer require_once \dirname(__DIR__) . '/vendor/autoload.php'; -$integrationDir = __DIR__ . '/Behavior/Functional/Driver/Common/Integration'; +$integrationDir = __DIR__ . '/Regression'; function defaultCaseName(string $integrationDir): string { @@ -32,7 +32,7 @@ function defaultCaseName(string $integrationDir): string function copyTemplateFiles(string $copyDir, string $caseTemplateDirName): void { - $caseTemplateDir = __DIR__ . '/Behavior/Functional/Driver/Common/Integration/' . $caseTemplateDirName; + $caseTemplateDir = __DIR__ . '/Regression/' . $caseTemplateDirName; if (!\file_exists($caseTemplateDir) || !\is_dir($caseTemplateDir)) { echo "Error. template folder '$caseTemplateDir' does not exists\n"; exit(1); @@ -79,6 +79,4 @@ function copyTemplateFiles(string $copyDir, string $caseTemplateDirName): void copyTemplateFiles($copyDir, $options['template'] ?? 'CaseTemplate'); -require 'generate.php'; - echo "Done. New test case is here:\n$copyDir\n"; From b67dec85bcd268d3f2fc6c9b6521fb0a503a210f Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 12:00:20 +0400 Subject: [PATCH 05/14] test: polish the Testo tests with Rector Assisted-By: Claude Opus 5.5 --- .../Common/CreatedAt/CreatedAtTest.php | 27 +++-- .../Feature/Common/CreatedAt/ListenerTest.php | 19 +-- .../EventListener/EventListenerTest.php | 25 ++-- .../Common/EventListener/ListenerTest.php | 11 +- tests/Feature/Common/Hook/HookTest.php | 23 ++-- tests/Feature/Common/Hook/ListenerTest.php | 33 +++--- .../OptimisticLock/InquiredRelationTest.php | 15 ++- .../Common/OptimisticLock/ListenerTest.php | 52 +++++---- .../OptimisticLock/OptimisticLockTest.php | 71 ++++++------ tests/Feature/Common/Schema/ErrorsTest.php | 9 +- .../Common/Schema/RegistryModifierTest.php | 108 +++++++++--------- .../Common/SoftDelete/ListenerTest.php | 17 +-- .../Common/SoftDelete/SoftDeleteTest.php | 27 +++-- .../Feature/Common/UpdatedAt/ListenerTest.php | 23 ++-- .../Common/UpdatedAt/UpdatedAtTest.php | 27 +++-- tests/Regression/CaseTemplate/CaseTest.php | 25 ++-- tests/Unit/Schema/RegistryModifierTest.php | 103 ++++++++--------- 17 files changed, 327 insertions(+), 288 deletions(-) diff --git a/tests/Feature/Common/CreatedAt/CreatedAtTest.php b/tests/Feature/Common/CreatedAt/CreatedAtTest.php index 2a13a7e..99bcc1d 100644 --- a/tests/Feature/Common/CreatedAt/CreatedAtTest.php +++ b/tests/Feature/Common/CreatedAt/CreatedAtTest.php @@ -9,35 +9,38 @@ use Cycle\ORM\Schema\GeneratedField; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class CreatedAtTest extends SchemaTestCase { - #[\Testo\Test] + #[Test] public function testExistenceColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - \Testo\Assert::true($fields->has('createdAt')); - \Testo\Assert::true($fields->hasColumn('created_at')); - \Testo\Assert::same($fields->get('createdAt')->getType(), 'datetime'); - \Testo\Assert::same($fields->get('createdAt')->getGenerated(), GeneratedField::BEFORE_INSERT); + Assert::true($fields->has('createdAt')); + Assert::true($fields->hasColumn('created_at')); + Assert::same($fields->get('createdAt')->getType(), 'datetime'); + Assert::same($fields->get('createdAt')->getGenerated(), GeneratedField::BEFORE_INSERT); // No new fields added - \Testo\Assert::same($fields->count(), 3); + Assert::same($fields->count(), 3); } - #[\Testo\Test] + #[Test] public function testAddedColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - \Testo\Assert::true($fields->has('newField')); - \Testo\Assert::true($fields->hasColumn('new_field')); - \Testo\Assert::same($fields->get('newField')->getType(), 'datetime'); - \Testo\Assert::same($fields->get('newField')->getGenerated(), GeneratedField::BEFORE_INSERT); + Assert::true($fields->has('newField')); + Assert::true($fields->hasColumn('new_field')); + Assert::same($fields->get('newField')->getType(), 'datetime'); + Assert::same($fields->get('newField')->getGenerated(), GeneratedField::BEFORE_INSERT); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ diff --git a/tests/Feature/Common/CreatedAt/ListenerTest.php b/tests/Feature/Common/CreatedAt/ListenerTest.php index b703228..a636772 100644 --- a/tests/Feature/Common/CreatedAt/ListenerTest.php +++ b/tests/Feature/Common/CreatedAt/ListenerTest.php @@ -11,10 +11,13 @@ use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class ListenerTest extends ListenerTestCase { - #[\Testo\Test] + #[Test] public function testCreate(): void { $post = new Post(); @@ -23,11 +26,11 @@ public function testCreate(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - \Testo\Assert::notNull($data->createdAt); - \Testo\Assert::notNull($data->customCreatedAt); + Assert::notNull($data->createdAt); + Assert::notNull($data->customCreatedAt); } - #[\Testo\Test] + #[Test] public function testUpdate(): void { $post = new Post(); @@ -47,12 +50,12 @@ public function testUpdate(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - \Testo\Assert::same($data->createdAt <=> $createdAt, 0); - \Testo\Assert::same($data->customCreatedAt <=> $customCreatedAt, 0); - \Testo\Assert::same($data->content, 'test'); + Assert::same($data->createdAt <=> $createdAt, 0); + Assert::same($data->customCreatedAt <=> $customCreatedAt, 0); + Assert::same($data->content, 'test'); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->makeTable( diff --git a/tests/Feature/Common/EventListener/EventListenerTest.php b/tests/Feature/Common/EventListener/EventListenerTest.php index 0a57e57..58e35d0 100644 --- a/tests/Feature/Common/EventListener/EventListenerTest.php +++ b/tests/Feature/Common/EventListener/EventListenerTest.php @@ -12,31 +12,34 @@ use Cycle\ORM\SchemaInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class EventListenerTest extends SchemaTestCase { - #[\Testo\Test] + #[Test] public function testSchemaWithArgs(): void { $listeners = $this->schema->define(Post::class, SchemaInterface::LISTENERS); - \Testo\Assert::array($listeners); - \Testo\Assert::array($listeners[0]); - \Testo\Assert::same($listeners[0][0], PostService::class); - \Testo\Assert::same($listeners[0][1], ['foo' => 'modified by EventListener', 'bar' => ['baz']]); - \Testo\Assert::count($listeners[0], 2); + Assert::array($listeners); + Assert::array($listeners[0]); + Assert::same($listeners[0][0], PostService::class); + Assert::same($listeners[0][1], ['foo' => 'modified by EventListener', 'bar' => ['baz']]); + Assert::count($listeners[0], 2); } - #[\Testo\Test] + #[Test] public function testSchema(): void { $listeners = $this->schema->define(Comment::class, SchemaInterface::LISTENERS); - \Testo\Assert::array($listeners); - \Testo\Assert::same($listeners[0], CommentService::class); - \Testo\Assert::count($listeners, 1); + Assert::array($listeners); + Assert::same($listeners[0], CommentService::class); + Assert::count($listeners, 1); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ diff --git a/tests/Feature/Common/EventListener/ListenerTest.php b/tests/Feature/Common/EventListener/ListenerTest.php index 4bc5d99..821d2bf 100644 --- a/tests/Feature/Common/EventListener/ListenerTest.php +++ b/tests/Feature/Common/EventListener/ListenerTest.php @@ -11,10 +11,13 @@ use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class ListenerTest extends ListenerTestCase { - #[\Testo\Test] + #[Test] public function testApply(): void { $post = new Post(); @@ -24,11 +27,11 @@ public function testApply(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - \Testo\Assert::same($data->title, 'modified by EventListener'); - \Testo\Assert::same($data->content, 'baz'); + Assert::same($data->title, 'modified by EventListener'); + Assert::same($data->content, 'baz'); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->makeTable( diff --git a/tests/Feature/Common/Hook/HookTest.php b/tests/Feature/Common/Hook/HookTest.php index 78c3ebc..f477adf 100644 --- a/tests/Feature/Common/Hook/HookTest.php +++ b/tests/Feature/Common/Hook/HookTest.php @@ -13,27 +13,30 @@ use Cycle\ORM\SchemaInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class HookTest extends SchemaTestCase { - #[\Testo\Test] + #[Test] public function testAddListener(): void { $listeners = $this->schema->define(Post::class, SchemaInterface::LISTENERS); - \Testo\Assert::array($listeners); - \Testo\Assert::count($listeners, 2); - \Testo\Assert::array($listeners[0]); - \Testo\Assert::array($listeners[1]); + Assert::array($listeners); + Assert::count($listeners, 2); + Assert::array($listeners[0]); + Assert::array($listeners[1]); - \Testo\Assert::same($listeners[0][0], Hook::class); - \Testo\Assert::same($listeners[0][1], ['callable' => [PostService::class, 'update'], 'events' => [OnUpdate::class]]); + Assert::same($listeners[0][0], Hook::class); + Assert::same($listeners[0][1], ['callable' => [PostService::class, 'update'], 'events' => [OnUpdate::class]]); - \Testo\Assert::same($listeners[1][0], Hook::class); - \Testo\Assert::same($listeners[1][1], ['callable' => [Post::class, 'touch'], 'events' => [OnCreate::class, OnUpdate::class]]); + Assert::same($listeners[1][0], Hook::class); + Assert::same($listeners[1][1], ['callable' => [Post::class, 'touch'], 'events' => [OnCreate::class, OnUpdate::class]]); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ diff --git a/tests/Feature/Common/Hook/ListenerTest.php b/tests/Feature/Common/Hook/ListenerTest.php index 02ad83e..596e4be 100644 --- a/tests/Feature/Common/Hook/ListenerTest.php +++ b/tests/Feature/Common/Hook/ListenerTest.php @@ -14,10 +14,13 @@ use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class ListenerTest extends ListenerTestCase { - #[\Testo\Test] + #[Test] public function testCreate(): void { $post = $this->createPost(); @@ -25,14 +28,14 @@ public function testCreate(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - \Testo\Assert::notNull($data->createdAt); - \Testo\Assert::notNull($data->updatedAt); - \Testo\Assert::null($data->content); - \Testo\Assert::same($post->slug, 'test'); - \Testo\Assert::same($data->lastEvent, OnCreate::class); + Assert::notNull($data->createdAt); + Assert::notNull($data->updatedAt); + Assert::null($data->content); + Assert::same($post->slug, 'test'); + Assert::same($data->lastEvent, OnCreate::class); } - #[\Testo\Test] + #[Test] public function testUpdate(): void { $this->createPost(); @@ -49,20 +52,20 @@ public function testUpdate(): void $data = $select->fetchOne(); // Triggered OnUpdate event - \Testo\Assert::null($content); - \Testo\Assert::same($data->content, 'modified by service'); + Assert::null($content); + Assert::same($data->content, 'modified by service'); // Not triggered OnCreate event, slug NOT changed. - \Testo\Assert::same($data->slug, 'test'); - \Testo\Assert::same($data->title, 'TEST 2'); + Assert::same($data->slug, 'test'); + Assert::same($data->title, 'TEST 2'); // Triggered union type event OnCreate|OnUpdate - \Testo\Assert::notNull($data->updatedAt); - \Testo\Assert::notNull($data->createdAt); - \Testo\Assert::same($data->lastEvent, OnUpdate::class); + Assert::notNull($data->updatedAt); + Assert::notNull($data->createdAt); + Assert::same($data->lastEvent, OnUpdate::class); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->makeTable( diff --git a/tests/Feature/Common/OptimisticLock/InquiredRelationTest.php b/tests/Feature/Common/OptimisticLock/InquiredRelationTest.php index e8cef50..5b8e9ce 100644 --- a/tests/Feature/Common/OptimisticLock/InquiredRelationTest.php +++ b/tests/Feature/Common/OptimisticLock/InquiredRelationTest.php @@ -29,10 +29,13 @@ use Spiral\Attributes\AttributeReader; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class InquiredRelationTest extends ListenerTestCase { - #[\Testo\Test] + #[Test] public function testUpdateWithSelectCollection(): void { $repo = $this->orm->getRepository(Product::class); @@ -58,23 +61,23 @@ public function testUpdateWithSelectCollection(): void $this->save($product1, $product2); // Persist 2 with Fetch all products - \Testo\Assert::same($product1->revision, 1); - \Testo\Assert::same($product2->revision, 1); + Assert::same($product1->revision, 1); + Assert::same($product2->revision, 1); $product1->name = '222'; // Persist 2 $this->save($product1); - \Testo\Assert::same($product1->revision, 2); + Assert::same($product1->revision, 2); // Persist 3 with Fetch all products $product1->name = '333'; $products = $repo->findAll(); $this->save($product1); - \Testo\Assert::equals($product1->revision, 3); + Assert::equals($product1->revision, 3); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $schema = $this->compileSchema(new Tokenizer(new TokenizerConfig([ diff --git a/tests/Feature/Common/OptimisticLock/ListenerTest.php b/tests/Feature/Common/OptimisticLock/ListenerTest.php index c4636b9..efa91cf 100644 --- a/tests/Feature/Common/OptimisticLock/ListenerTest.php +++ b/tests/Feature/Common/OptimisticLock/ListenerTest.php @@ -16,10 +16,14 @@ use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; use Cycle\ORM\Transaction; +use Testo\Assert; +use Testo\Expect; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class ListenerTest extends ListenerTestCase { - #[\Testo\Test] + #[Test] public function testAddVersionOnCreate(): void { $comment = new Comment(); @@ -32,13 +36,13 @@ public function testAddVersionOnCreate(): void $comment = $select->fetchOne(); - \Testo\Assert::same($comment->versionInt, 1); - \Testo\Assert::instanceOf($comment->versionDatetime, \DateTimeImmutable::class); - \Testo\Assert::string($comment->versionMicrotime); - \Testo\Assert::string($comment->versionStr); + Assert::same($comment->versionInt, 1); + Assert::instanceOf($comment->versionDatetime, \DateTimeImmutable::class); + Assert::string($comment->versionMicrotime); + Assert::string($comment->versionStr); } - #[\Testo\Test] + #[Test] public function testManualAddVersionOnCreate(): void { $comment = new Comment(); @@ -55,13 +59,13 @@ public function testManualAddVersionOnCreate(): void $comment = $select->fetchOne(); - \Testo\Assert::same($comment->versionInt, 3); - \Testo\Assert::same($comment->versionDatetime->getTimestamp(), 1638275394); - \Testo\Assert::same($comment->versionMicrotime, '1638275263.792011'); - \Testo\Assert::same($comment->versionStr, 'b0b55bb7237bb75611f7df8175e926d1'); + Assert::same($comment->versionInt, 3); + Assert::same($comment->versionDatetime->getTimestamp(), 1638275394); + Assert::same($comment->versionMicrotime, '1638275263.792011'); + Assert::same($comment->versionStr, 'b0b55bb7237bb75611f7df8175e926d1'); } - #[\Testo\Test] + #[Test] public function testManualVersionControl(): void { $comment = new Comment(); @@ -74,15 +78,15 @@ public function testManualVersionControl(): void $select = new Select($this->orm, Comment::class); $comment = $select->fetchOne(); - \Testo\Assert::same($comment->versionCustom, 1); + Assert::same($comment->versionCustom, 1); $comment->versionCustom = 2; $this->save($comment); - \Testo\Assert::same($comment->versionCustom, 2); + Assert::same($comment->versionCustom, 2); } - #[\Testo\Test] + #[Test] public function testExceptionOnChangeVersion(): void { $comment = new Comment(); @@ -94,15 +98,15 @@ public function testExceptionOnChangeVersion(): void $select = new Select($this->orm, Comment::class); $comment = $select->fetchOne(); - \Testo\Assert::same($comment->versionInt, 1); + Assert::same($comment->versionInt, 1); $comment->versionInt = 2; - \Testo\Expect::exception(ChangedVersionException::class)->withMessageContaining('Record version change detected. Old value `1`, a new value `2`'); + Expect::exception(ChangedVersionException::class)->withMessageContaining('Record version change detected. Old value `1`, a new value `2`'); $this->save($comment); } - #[\Testo\Test] + #[Test] public function testUpdate(): void { $comment = new Comment(); @@ -115,8 +119,8 @@ public function testUpdate(): void $comment = $select->fetchOne(); - \Testo\Assert::same($comment->versionInt, 1); - \Testo\Assert::same($comment->content, 'test'); + Assert::same($comment->versionInt, 1); + Assert::same($comment->content, 'test'); $comment->content = 'changed'; @@ -125,11 +129,11 @@ public function testUpdate(): void $select = new Select($this->orm->with(heap: new Heap()), Comment::class); $data = $select->fetchOne(); - \Testo\Assert::same($data->content, 'changed'); - \Testo\Assert::same($data->versionInt, 2); + Assert::same($data->content, 'changed'); + Assert::same($data->versionInt, 2); } - #[\Testo\Test] + #[Test] public function testLock(): void { $comment = new Comment(); @@ -148,11 +152,11 @@ public function testLock(): void (new Transaction($orm))->persist($data1)->run(); - \Testo\Expect::exception(RecordIsLockedException::class)->withMessageContaining('The `comment` record is locked.'); + Expect::exception(RecordIsLockedException::class)->withMessageContaining('The `comment` record is locked.'); (new Transaction($orm2))->persist($data2)->run(); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->makeTable( diff --git a/tests/Feature/Common/OptimisticLock/OptimisticLockTest.php b/tests/Feature/Common/OptimisticLock/OptimisticLockTest.php index fbc9d58..170210d 100644 --- a/tests/Feature/Common/OptimisticLock/OptimisticLockTest.php +++ b/tests/Feature/Common/OptimisticLock/OptimisticLockTest.php @@ -15,84 +15,87 @@ use Cycle\ORM\Schema\GeneratedField; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class OptimisticLockTest extends SchemaTestCase { - #[\Testo\Test] + #[Test] public function testAddIntColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - \Testo\Assert::true($fields->has('version')); - \Testo\Assert::true($fields->hasColumn('version')); - \Testo\Assert::same($fields->get('version')->getType(), 'integer'); - \Testo\Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); + Assert::true($fields->has('version')); + Assert::true($fields->hasColumn('version')); + Assert::same($fields->get('version')->getType(), 'integer'); + Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); } - #[\Testo\Test] + #[Test] public function testAddStringColumn(): void { $fields = $this->registry->getEntity(Comment::class)->getFields(); - \Testo\Assert::true($fields->has('version')); - \Testo\Assert::true($fields->hasColumn('version')); - \Testo\Assert::same($fields->get('version')->getType(), ColumnInterface::STRING); - \Testo\Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); + Assert::true($fields->has('version')); + Assert::true($fields->hasColumn('version')); + Assert::same($fields->get('version')->getType(), ColumnInterface::STRING); + Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); } - #[\Testo\Test] + #[Test] public function testAddDatetimeColumn(): void { $fields = $this->registry->getEntity(Page::class)->getFields(); - \Testo\Assert::true($fields->has('version')); - \Testo\Assert::true($fields->hasColumn('version')); - \Testo\Assert::same($fields->get('version')->getType(), 'datetime'); - \Testo\Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); + Assert::true($fields->has('version')); + Assert::true($fields->hasColumn('version')); + Assert::same($fields->get('version')->getType(), 'datetime'); + Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); } - #[\Testo\Test] + #[Test] public function testExistColumn(): void { $fields = $this->registry->getEntity(Item::class)->getFields(); - \Testo\Assert::true($fields->has('revision')); - \Testo\Assert::true($fields->hasColumn('revision_field')); - \Testo\Assert::same($fields->get('revision')->getType(), 'integer'); - \Testo\Assert::same($fields->get('revision')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); + Assert::true($fields->has('revision')); + Assert::true($fields->hasColumn('revision_field')); + Assert::same($fields->get('revision')->getType(), 'integer'); + Assert::same($fields->get('revision')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); // not added new columns - \Testo\Assert::same($fields->count(), 2); + Assert::same($fields->count(), 2); } - #[\Testo\Test] + #[Test] public function testExistColumnAndAllOptimisticLockParameters(): void { $fields = $this->registry->getEntity(WithAllParameters::class)->getFields(); - \Testo\Assert::true($fields->has('revision')); - \Testo\Assert::true($fields->hasColumn('revision_field')); - \Testo\Assert::same($fields->get('revision')->getType(), 'integer'); - \Testo\Assert::same($fields->get('revision')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); + Assert::true($fields->has('revision')); + Assert::true($fields->hasColumn('revision_field')); + Assert::same($fields->get('revision')->getType(), 'integer'); + Assert::same($fields->get('revision')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); // not added new columns - \Testo\Assert::same($fields->count(), 2); + Assert::same($fields->count(), 2); } - #[\Testo\Test] + #[Test] public function testAddDefaultColumAndRule(): void { $fields = $this->registry->getEntity(News::class)->getFields(); - \Testo\Assert::true($fields->has('version')); - \Testo\Assert::true($fields->hasColumn('version')); - \Testo\Assert::same($fields->get('version')->getType(), 'integer'); - \Testo\Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); + Assert::true($fields->has('version')); + Assert::true($fields->hasColumn('version')); + Assert::same($fields->get('version')->getType(), 'integer'); + Assert::same($fields->get('version')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); - \Testo\Assert::same($fields->count(), 2); + Assert::same($fields->count(), 2); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ diff --git a/tests/Feature/Common/Schema/ErrorsTest.php b/tests/Feature/Common/Schema/ErrorsTest.php index 66f1c59..afd1006 100644 --- a/tests/Feature/Common/Schema/ErrorsTest.php +++ b/tests/Feature/Common/Schema/ErrorsTest.php @@ -8,6 +8,9 @@ use Cycle\ORM\Entity\Behavior\Tests\Support\SchemaTestCase; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Data\DataProvider; +use Testo\Expect; +use Testo\Test; final class ErrorsTest extends SchemaTestCase { @@ -31,11 +34,11 @@ public static function errorsProvider(): array ]; } - #[\Testo\Test] - #[\Testo\Data\DataProvider('errorsProvider')] + #[Test] + #[DataProvider('errorsProvider')] public function testErrors(Tokenizer $tokenizer, string $message): void { - \Testo\Expect::exception(BehaviorCompilationException::class)->withMessageMatchingRegex(\sprintf('/%s/', $message)); + Expect::exception(BehaviorCompilationException::class)->withMessageMatchingRegex(\sprintf('/%s/', $message)); $this->compileWithTokenizer($tokenizer); } diff --git a/tests/Feature/Common/Schema/RegistryModifierTest.php b/tests/Feature/Common/Schema/RegistryModifierTest.php index e97017c..1c0eb2d 100644 --- a/tests/Feature/Common/Schema/RegistryModifierTest.php +++ b/tests/Feature/Common/Schema/RegistryModifierTest.php @@ -8,12 +8,16 @@ use Cycle\ORM\Entity\Behavior\Exception\BehaviorCompilationException; use Cycle\ORM\Entity\Behavior\Schema\RegistryModifier; use Cycle\ORM\Entity\Behavior\Tests\Fixtures\CustomTypecast; -use Cycle\Testing\Database\DatabaseTestCase; use Cycle\ORM\Parser\Typecast; use Cycle\ORM\SchemaInterface; use Cycle\Schema\Definition\Entity; use Cycle\Schema\Registry; +use Cycle\Testing\Database\DatabaseTestCase; use Ramsey\Uuid\Uuid; +use Testo\Assert; +use Testo\Expect; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class RegistryModifierTest extends DatabaseTestCase { @@ -22,7 +26,7 @@ final class RegistryModifierTest extends DatabaseTestCase protected RegistryModifier $modifier; protected Registry $registry; - #[\Testo\Test] + #[Test] public function testAddDatetimeField(): void { $this->modifier->addDatetimeColumn('created_at', 'createdAt'); @@ -30,12 +34,12 @@ public function testAddDatetimeField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - \Testo\Assert::true($fields->has('createdAt')); - \Testo\Assert::same($fields->get('createdAt')->getType(), 'datetime'); - \Testo\Assert::same($fields->get('createdAt')->getColumn(), 'created_at'); + Assert::true($fields->has('createdAt')); + Assert::same($fields->get('createdAt')->getType(), 'datetime'); + Assert::same($fields->get('createdAt')->getColumn(), 'created_at'); } - #[\Testo\Test] + #[Test] public function testAddStringField(): void { $this->modifier->addStringColumn('version_str', 'version'); @@ -43,12 +47,12 @@ public function testAddStringField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - \Testo\Assert::true($fields->has('version')); - \Testo\Assert::same($fields->get('version')->getType(), ColumnInterface::STRING); - \Testo\Assert::same($fields->get('version')->getColumn(), 'version_str'); + Assert::true($fields->has('version')); + Assert::same($fields->get('version')->getType(), ColumnInterface::STRING); + Assert::same($fields->get('version')->getColumn(), 'version_str'); } - #[\Testo\Test] + #[Test] public function testAddIntegerField(): void { $this->modifier->addIntegerColumn('version_int', 'version'); @@ -56,12 +60,12 @@ public function testAddIntegerField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - \Testo\Assert::true($fields->has('version')); - \Testo\Assert::same($fields->get('version')->getType(), 'integer'); - \Testo\Assert::same($fields->get('version')->getColumn(), 'version_int'); + Assert::true($fields->has('version')); + Assert::same($fields->get('version')->getType(), 'integer'); + Assert::same($fields->get('version')->getColumn(), 'version_int'); } - #[\Testo\Test] + #[Test] public function testAddBigIntegerField(): void { $this->modifier->addBigIntegerColumn('snowflake_column', 'snowflake'); @@ -69,22 +73,22 @@ public function testAddBigIntegerField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - \Testo\Assert::true($fields->has('snowflake')); - \Testo\Assert::same($fields->get('snowflake')->getType(), 'bigInteger'); - \Testo\Assert::same($fields->get('snowflake')->getColumn(), 'snowflake_column'); + Assert::true($fields->has('snowflake')); + Assert::same($fields->get('snowflake')->getType(), 'bigInteger'); + Assert::same($fields->get('snowflake')->getColumn(), 'snowflake_column'); } - #[\Testo\Test] + #[Test] public function testAddBigIntegerFieldThrowsException(): void { $this->modifier->addIntegerColumn('snowflake_column', 'snowflake'); - \Testo\Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field snowflake must be of type big integer.'); + Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field snowflake must be of type big integer.'); $this->modifier->addBigIntegerColumn('snowflake_column', 'snowflake'); } - #[\Testo\Test] + #[Test] public function testAddSnowflakeField(): void { $this->modifier->addSnowflakeColumn('snowflake_column', 'snowflake'); @@ -92,22 +96,22 @@ public function testAddSnowflakeField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - \Testo\Assert::true($fields->has('snowflake')); - \Testo\Assert::same($fields->get('snowflake')->getType(), 'snowflake'); - \Testo\Assert::same($fields->get('snowflake')->getColumn(), 'snowflake_column'); + Assert::true($fields->has('snowflake')); + Assert::same($fields->get('snowflake')->getType(), 'snowflake'); + Assert::same($fields->get('snowflake')->getColumn(), 'snowflake_column'); } - #[\Testo\Test] + #[Test] public function testAddSnowflakeFieldThrowsException(): void { $this->modifier->addStringColumn('snowflake_column', 'snowflake'); - \Testo\Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field snowflake must be of type snowflake.'); + Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field snowflake must be of type snowflake.'); $this->modifier->addSnowflakeColumn('snowflake_column', 'snowflake'); } - #[\Testo\Test] + #[Test] public function testAddUlidField(): void { $this->modifier->addUlidColumn('ulid_column', 'ulid'); @@ -115,22 +119,22 @@ public function testAddUlidField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - \Testo\Assert::true($fields->has('ulid')); - \Testo\Assert::same($fields->get('ulid')->getType(), 'ulid'); - \Testo\Assert::same($fields->get('ulid')->getColumn(), 'ulid_column'); + Assert::true($fields->has('ulid')); + Assert::same($fields->get('ulid')->getType(), 'ulid'); + Assert::same($fields->get('ulid')->getColumn(), 'ulid_column'); } - #[\Testo\Test] + #[Test] public function testAddUlidFieldThrowsException(): void { $this->modifier->addIntegerColumn('ulid_column', 'ulid'); - \Testo\Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field ulid must be of type ulid.'); + Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field ulid must be of type ulid.'); $this->modifier->addUlidColumn('ulid_column', 'ulid'); } - #[\Testo\Test] + #[Test] public function testAddUuidField(): void { $this->modifier->addUuidColumn('uuid_column', 'uuid'); @@ -138,22 +142,22 @@ public function testAddUuidField(): void $entity = $this->registry->getEntity(self::ROLE_TEST); $fields = $entity->getFields(); - \Testo\Assert::true($fields->has('uuid')); - \Testo\Assert::same($fields->get('uuid')->getType(), 'uuid'); - \Testo\Assert::same($fields->get('uuid')->getColumn(), 'uuid_column'); + Assert::true($fields->has('uuid')); + Assert::same($fields->get('uuid')->getType(), 'uuid'); + Assert::same($fields->get('uuid')->getColumn(), 'uuid_column'); } - #[\Testo\Test] + #[Test] public function testAddUuidFieldThrowsException(): void { $this->modifier->addIntegerColumn('uuid_column', 'uuid'); - \Testo\Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field uuid must be of type uuid.'); + Expect::exception(BehaviorCompilationException::class)->withMessageContaining('Field uuid must be of type uuid.'); $this->modifier->addUuidColumn('uuid_column', 'uuid'); } - #[\Testo\Test] + #[Test] public function testAddTypecast(): void { $this->modifier->addUuidColumn('uuid_column', 'uuid'); @@ -168,15 +172,15 @@ public function testAddTypecast(): void $this->modifier->setTypecast($field3, 'int', CustomTypecast::class); // field has custom UUID typecast - \Testo\Assert::same($field1->getTypecast(), [Uuid::class, 'fromString']); - \Testo\Assert::same($field2->getTypecast(), 'int'); - \Testo\Assert::same($field3->getTypecast(), 'int'); + Assert::same($field1->getTypecast(), [Uuid::class, 'fromString']); + Assert::same($field2->getTypecast(), 'int'); + Assert::same($field3->getTypecast(), 'int'); // entity has default typecast - \Testo\Assert::same($this->registry->getEntity(self::ROLE_TEST)->getTypecast(), [Typecast::class, CustomTypecast::class]); + Assert::same($this->registry->getEntity(self::ROLE_TEST)->getTypecast(), [Typecast::class, CustomTypecast::class]); } - #[\Testo\Test] + #[Test] public function testAddTypecastEntityWithTypecast(): void { $this->registry->getEntity(self::ROLE_TEST)->setTypecast(CustomTypecast::class); @@ -187,13 +191,13 @@ public function testAddTypecastEntityWithTypecast(): void $this->modifier->setTypecast($field, [Uuid::class, 'fromString']); // field has custom UUID typecast - \Testo\Assert::same($field->getTypecast(), [Uuid::class, 'fromString']); + Assert::same($field->getTypecast(), [Uuid::class, 'fromString']); // entity has default typecast and custom typecast - \Testo\Assert::same($this->registry->getEntity(self::ROLE_TEST)->getTypecast(), [CustomTypecast::class, Typecast::class]); + Assert::same($this->registry->getEntity(self::ROLE_TEST)->getTypecast(), [CustomTypecast::class, Typecast::class]); } - #[\Testo\Test] + #[Test] public function testAddTypecastShouldBeSkipped(): void { $this->registry->getEntity(self::ROLE_TEST); @@ -201,20 +205,20 @@ public function testAddTypecastShouldBeSkipped(): void $this->modifier->addUuidColumn('uuid_column', 'uuid'); $this->registry->getDefaults()->offsetSet(SchemaInterface::TYPECAST_HANDLER, Typecast::class); - \Testo\Assert::null($this->registry->getEntity(self::ROLE_TEST)->getTypecast()); + Assert::null($this->registry->getEntity(self::ROLE_TEST)->getTypecast()); } - #[\Testo\Test] + #[Test] public function testAddTypecastShouldBeDuplicated(): void { $this->registry->getEntity(self::ROLE_TEST)->setTypecast(CustomTypecast::class); $this->modifier->addUuidColumn('uuid_column', 'uuid'); - \Testo\Assert::same($this->registry->getEntity(self::ROLE_TEST)->getTypecast(), CustomTypecast::class); + Assert::same($this->registry->getEntity(self::ROLE_TEST)->getTypecast(), CustomTypecast::class); } - #[\Testo\Test] + #[Test] public function testCustomTypecastNotOverridden(): void { $this->modifier->addUuidColumn('uuid_column', 'uuid'); @@ -224,10 +228,10 @@ public function testCustomTypecastNotOverridden(): void $this->modifier->setTypecast($field, [Uuid::class, 'fromString']); - \Testo\Assert::same($field->getTypecast(), ['foo', 'bar']); + Assert::same($field->getTypecast(), ['foo', 'bar']); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->registry = new Registry($this->dbal); diff --git a/tests/Feature/Common/SoftDelete/ListenerTest.php b/tests/Feature/Common/SoftDelete/ListenerTest.php index e01ddaf..a565061 100644 --- a/tests/Feature/Common/SoftDelete/ListenerTest.php +++ b/tests/Feature/Common/SoftDelete/ListenerTest.php @@ -12,10 +12,13 @@ use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; use Cycle\ORM\Transaction; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class ListenerTest extends ListenerTestCase { - #[\Testo\Test] + #[Test] public function testDelete(): void { $this->save(new Post()); @@ -23,8 +26,8 @@ public function testDelete(): void $select = new Select($this->orm, Post::class); $post = $select->fetchOne(); - \Testo\Assert::null($post->deletedAt); - \Testo\Assert::null($post->customDeletedAt); + Assert::null($post->deletedAt); + Assert::null($post->customDeletedAt); $tr = new Transaction($this->orm); $tr->delete($post); @@ -33,12 +36,12 @@ public function testDelete(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - \Testo\Assert::instanceOf($data, Post::class); - \Testo\Assert::notNull($data->deletedAt); - \Testo\Assert::notNull($data->customDeletedAt); + Assert::instanceOf($data, Post::class); + Assert::notNull($data->deletedAt); + Assert::notNull($data->customDeletedAt); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->makeTable( diff --git a/tests/Feature/Common/SoftDelete/SoftDeleteTest.php b/tests/Feature/Common/SoftDelete/SoftDeleteTest.php index 794b004..8f3e54a 100644 --- a/tests/Feature/Common/SoftDelete/SoftDeleteTest.php +++ b/tests/Feature/Common/SoftDelete/SoftDeleteTest.php @@ -9,35 +9,38 @@ use Cycle\ORM\Schema\GeneratedField; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class SoftDeleteTest extends SchemaTestCase { - #[\Testo\Test] + #[Test] public function testExistenceColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - \Testo\Assert::true($fields->has('deletedAt')); - \Testo\Assert::true($fields->hasColumn('deleted_at')); - \Testo\Assert::same($fields->get('deletedAt')->getType(), 'datetime'); - \Testo\Assert::same($fields->get('deletedAt')->getGenerated(), GeneratedField::BEFORE_UPDATE); + Assert::true($fields->has('deletedAt')); + Assert::true($fields->hasColumn('deleted_at')); + Assert::same($fields->get('deletedAt')->getType(), 'datetime'); + Assert::same($fields->get('deletedAt')->getGenerated(), GeneratedField::BEFORE_UPDATE); // No new fields added - \Testo\Assert::same($fields->count(), 3); + Assert::same($fields->count(), 3); } - #[\Testo\Test] + #[Test] public function testAddedColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - \Testo\Assert::true($fields->has('newField')); - \Testo\Assert::true($fields->hasColumn('new_field')); - \Testo\Assert::same($fields->get('newField')->getType(), 'datetime'); - \Testo\Assert::same($fields->get('newField')->getGenerated(), GeneratedField::BEFORE_UPDATE); + Assert::true($fields->has('newField')); + Assert::true($fields->hasColumn('new_field')); + Assert::same($fields->get('newField')->getType(), 'datetime'); + Assert::same($fields->get('newField')->getGenerated(), GeneratedField::BEFORE_UPDATE); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ diff --git a/tests/Feature/Common/UpdatedAt/ListenerTest.php b/tests/Feature/Common/UpdatedAt/ListenerTest.php index 2156e3b..f195a82 100644 --- a/tests/Feature/Common/UpdatedAt/ListenerTest.php +++ b/tests/Feature/Common/UpdatedAt/ListenerTest.php @@ -11,10 +11,13 @@ use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; use Cycle\ORM\Select; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class ListenerTest extends ListenerTestCase { - #[\Testo\Test] + #[Test] public function testCreate(): void { $post = new Post(); @@ -23,11 +26,11 @@ public function testCreate(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - \Testo\Assert::null($data->updatedAt); - \Testo\Assert::null($data->customUpdatedAt); + Assert::null($data->updatedAt); + Assert::null($data->customUpdatedAt); } - #[\Testo\Test] + #[Test] public function testCreateNotNullable(): void { $post = new Post(); @@ -38,10 +41,10 @@ public function testCreateNotNullable(): void $select = new Select($this->orm, Post::class); $data = $select->fetchOne(); - \Testo\Assert::instanceOf($data->notNullableUpdatedAt, \DateTimeImmutable::class); + Assert::instanceOf($data->notNullableUpdatedAt, \DateTimeImmutable::class); } - #[\Testo\Test] + #[Test] public function testUpdate(): void { $post = new Post(); @@ -60,12 +63,12 @@ public function testUpdate(): void $select = new Select($this->orm->with(heap: new Heap()), Post::class); $data = $select->fetchOne(); - \Testo\Assert::numeric($data->updatedAt <=> $updatedAt)->greaterThan(0); - \Testo\Assert::numeric($data->customUpdatedAt <=> $customUpdatedAt)->greaterThan(0); - \Testo\Assert::same($data->content, 'test'); + Assert::numeric($data->updatedAt <=> $updatedAt)->greaterThan(0); + Assert::numeric($data->customUpdatedAt <=> $customUpdatedAt)->greaterThan(0); + Assert::same($data->content, 'test'); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->makeTable( diff --git a/tests/Feature/Common/UpdatedAt/UpdatedAtTest.php b/tests/Feature/Common/UpdatedAt/UpdatedAtTest.php index ebf16c6..ba022ab 100644 --- a/tests/Feature/Common/UpdatedAt/UpdatedAtTest.php +++ b/tests/Feature/Common/UpdatedAt/UpdatedAtTest.php @@ -9,35 +9,38 @@ use Cycle\ORM\Schema\GeneratedField; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class UpdatedAtTest extends SchemaTestCase { - #[\Testo\Test] + #[Test] public function testExistenceColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - \Testo\Assert::true($fields->has('updatedAt')); - \Testo\Assert::true($fields->hasColumn('updated_at')); - \Testo\Assert::same($fields->get('updatedAt')->getType(), 'datetime'); - \Testo\Assert::same($fields->get('updatedAt')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); + Assert::true($fields->has('updatedAt')); + Assert::true($fields->hasColumn('updated_at')); + Assert::same($fields->get('updatedAt')->getType(), 'datetime'); + Assert::same($fields->get('updatedAt')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); // No new fields added - \Testo\Assert::same($fields->count(), 3); + Assert::same($fields->count(), 3); } - #[\Testo\Test] + #[Test] public function testAddedColumn(): void { $fields = $this->registry->getEntity(Post::class)->getFields(); - \Testo\Assert::true($fields->has('newField')); - \Testo\Assert::true($fields->hasColumn('new_field')); - \Testo\Assert::same($fields->get('newField')->getType(), 'datetime'); - \Testo\Assert::same($fields->get('newField')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); + Assert::true($fields->has('newField')); + Assert::true($fields->hasColumn('new_field')); + Assert::same($fields->get('newField')->getType(), 'datetime'); + Assert::same($fields->get('newField')->getGenerated(), GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->compileWithTokenizer(new Tokenizer(new TokenizerConfig([ diff --git a/tests/Regression/CaseTemplate/CaseTest.php b/tests/Regression/CaseTemplate/CaseTest.php index c1e27fc..30b6e92 100644 --- a/tests/Regression/CaseTemplate/CaseTest.php +++ b/tests/Regression/CaseTemplate/CaseTest.php @@ -6,10 +6,13 @@ use Cycle\ORM\Entity\Behavior\Tests\Support\IntegrationTestCase; use Cycle\ORM\Select; +use Testo\Assert; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; final class CaseTest extends IntegrationTestCase { - #[\Testo\Test] + #[Test] public function testPreparedData(): void { // Get entity @@ -20,21 +23,21 @@ public function testPreparedData(): void \assert($user instanceof Entity\User); // Check results - \Testo\Assert::notNull($user->createdAt); - \Testo\Assert::notNull($user->updatedAt); - \Testo\Assert::same($user->createdAt <=> $user->updatedAt, 0); + Assert::notNull($user->createdAt); + Assert::notNull($user->updatedAt); + Assert::same($user->createdAt <=> $user->updatedAt, 0); } - #[\Testo\Test] + #[Test] public function testCreatedAt(): void { // Get entity $user = $this->orm->make(Entity\User::class, ['login' => 'new-user', 'passwordHash' => '123456789']); - \Testo\Assert::false(isset($user->createdAt)); + Assert::false(isset($user->createdAt)); $this->save($user); - \Testo\Assert::notNull($user->createdAt); + Assert::notNull($user->createdAt); // Reload entity $id = $user->id; @@ -42,10 +45,10 @@ public function testCreatedAt(): void $user = (new Select($this->orm, Entity\User::class)) ->wherePK($id) ->fetchOne(); - \Testo\Assert::notNull($user->createdAt); + Assert::notNull($user->createdAt); } - #[\Testo\Test] + #[Test] public function testUpdatedAt(): void { // Get entity @@ -60,10 +63,10 @@ public function testUpdatedAt(): void $this->save($user); // Check results - \Testo\Assert::same($user->updatedAt <=> $updatedAt, 1); + Assert::same($user->updatedAt <=> $updatedAt, 1); } - #[\Testo\Lifecycle\BeforeTest] + #[BeforeTest] protected function setUp(): void { $this->prepareOrm(__DIR__ . '/Entity'); diff --git a/tests/Unit/Schema/RegistryModifierTest.php b/tests/Unit/Schema/RegistryModifierTest.php index a8a4900..ab60029 100644 --- a/tests/Unit/Schema/RegistryModifierTest.php +++ b/tests/Unit/Schema/RegistryModifierTest.php @@ -5,8 +5,11 @@ namespace Cycle\ORM\Entity\Behavior\Tests\Unit\Schema; use Cycle\ORM\Entity\Behavior\Schema\RegistryModifier; -use PHPUnit\Framework\TestCase; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; +#[Test] final class RegistryModifierTest { public static function integerDataProvider(): \Traversable @@ -49,115 +52,101 @@ public static function invalidDataProvider(): \Traversable yield ['bar(32)']; } - #[\Testo\Test] - #[\Testo\Data\DataProvider('integerDataProvider')] + #[DataProvider('integerDataProvider')] public function testIsIntegerTypeTrue(mixed $type): void { - \Testo\Assert::true(RegistryModifier::isIntegerType($type)); + Assert::true(RegistryModifier::isIntegerType($type)); } - #[\Testo\Test] - #[\Testo\Data\DataProvider('datetimeDataProvider')] - #[\Testo\Data\DataProvider('stringDataProvider')] - #[\Testo\Data\DataProvider('invalidDataProvider')] + #[DataProvider('datetimeDataProvider')] + #[DataProvider('stringDataProvider')] + #[DataProvider('invalidDataProvider')] public function testIsIntegerTypeFalse(mixed $type): void { - \Testo\Assert::false(RegistryModifier::isIntegerType($type)); + Assert::false(RegistryModifier::isIntegerType($type)); } - #[\Testo\Test] - #[\Testo\Data\DataProvider('bigIntegerDataProvider')] + #[DataProvider('bigIntegerDataProvider')] public function testIsBigIntegerTypeTrue(mixed $type): void { - \Testo\Assert::true(RegistryModifier::isBigIntegerType($type)); + Assert::true(RegistryModifier::isBigIntegerType($type)); } - #[\Testo\Test] - #[\Testo\Data\DataProvider('datetimeDataProvider')] - #[\Testo\Data\DataProvider('stringDataProvider')] - #[\Testo\Data\DataProvider('invalidDataProvider')] + #[DataProvider('datetimeDataProvider')] + #[DataProvider('stringDataProvider')] + #[DataProvider('invalidDataProvider')] public function testIsBigIntegerTypeFalse(mixed $type): void { - \Testo\Assert::false(RegistryModifier::isBigIntegerType($type)); + Assert::false(RegistryModifier::isBigIntegerType($type)); } - #[\Testo\Test] - #[\Testo\Data\DataProvider('datetimeDataProvider')] + #[DataProvider('datetimeDataProvider')] public function testIsDatetimeTypeTrue(mixed $type): void { - \Testo\Assert::true(RegistryModifier::isDatetimeType($type)); + Assert::true(RegistryModifier::isDatetimeType($type)); } - #[\Testo\Test] - #[\Testo\Data\DataProvider('integerDataProvider')] - #[\Testo\Data\DataProvider('stringDataProvider')] - #[\Testo\Data\DataProvider('invalidDataProvider')] + #[DataProvider('integerDataProvider')] + #[DataProvider('stringDataProvider')] + #[DataProvider('invalidDataProvider')] public function testIsDatetimeTypeFalse(mixed $type): void { - \Testo\Assert::false(RegistryModifier::isDatetimeType($type)); + Assert::false(RegistryModifier::isDatetimeType($type)); } - #[\Testo\Test] - #[\Testo\Data\DataProvider('stringDataProvider')] + #[DataProvider('stringDataProvider')] public function testIsStringTypeTrue(mixed $type): void { - \Testo\Assert::true(RegistryModifier::isStringType($type)); + Assert::true(RegistryModifier::isStringType($type)); } - #[\Testo\Test] - #[\Testo\Data\DataProvider('integerDataProvider')] - #[\Testo\Data\DataProvider('datetimeDataProvider')] - #[\Testo\Data\DataProvider('invalidDataProvider')] + #[DataProvider('integerDataProvider')] + #[DataProvider('datetimeDataProvider')] + #[DataProvider('invalidDataProvider')] public function testIsStringTypeFalse(mixed $type): void { - \Testo\Assert::false(RegistryModifier::isStringType($type)); + Assert::false(RegistryModifier::isStringType($type)); } - #[\Testo\Test] public function testIsSnowflakeTypeTrue(): void { - \Testo\Assert::true(RegistryModifier::isSnowflakeType('snowflake')); + Assert::true(RegistryModifier::isSnowflakeType('snowflake')); } - #[\Testo\Test] - #[\Testo\Data\DataProvider('integerDataProvider')] - #[\Testo\Data\DataProvider('datetimeDataProvider')] - #[\Testo\Data\DataProvider('invalidDataProvider')] - #[\Testo\Data\DataProvider('stringDataProvider')] + #[DataProvider('integerDataProvider')] + #[DataProvider('datetimeDataProvider')] + #[DataProvider('invalidDataProvider')] + #[DataProvider('stringDataProvider')] public function testIsSnowflakeTypeFalse(mixed $type): void { - \Testo\Assert::false(RegistryModifier::isSnowflakeType($type)); + Assert::false(RegistryModifier::isSnowflakeType($type)); } - #[\Testo\Test] public function testIsUlidTypeTrue(): void { - \Testo\Assert::true(RegistryModifier::isUlidType('ulid')); + Assert::true(RegistryModifier::isUlidType('ulid')); } - #[\Testo\Test] - #[\Testo\Data\DataProvider('integerDataProvider')] - #[\Testo\Data\DataProvider('datetimeDataProvider')] - #[\Testo\Data\DataProvider('invalidDataProvider')] - #[\Testo\Data\DataProvider('stringDataProvider')] + #[DataProvider('integerDataProvider')] + #[DataProvider('datetimeDataProvider')] + #[DataProvider('invalidDataProvider')] + #[DataProvider('stringDataProvider')] public function testIsUlidTypeFalse(mixed $type): void { - \Testo\Assert::false(RegistryModifier::isUlidType($type)); + Assert::false(RegistryModifier::isUlidType($type)); } - #[\Testo\Test] public function testIsUuidTypeTrue(): void { - \Testo\Assert::true(RegistryModifier::isUuidType('uuid')); + Assert::true(RegistryModifier::isUuidType('uuid')); } - #[\Testo\Test] - #[\Testo\Data\DataProvider('integerDataProvider')] - #[\Testo\Data\DataProvider('datetimeDataProvider')] - #[\Testo\Data\DataProvider('invalidDataProvider')] - #[\Testo\Data\DataProvider('stringDataProvider')] + #[DataProvider('integerDataProvider')] + #[DataProvider('datetimeDataProvider')] + #[DataProvider('invalidDataProvider')] + #[DataProvider('stringDataProvider')] public function testIsUuidTypeFalse(mixed $type): void { - \Testo\Assert::false(RegistryModifier::isUuidType($type)); + Assert::false(RegistryModifier::isUuidType($type)); } } From 30b0c42c07c365e836ebcf5f43db9b05598f0941 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 12:02:10 +0400 Subject: [PATCH 06/14] test: use the SimpleContainer of cycle/testing Assisted-By: Claude Opus 5.5 --- tests/Support/ListenerTestCase.php | 1 + tests/Support/SimpleContainer.php | 47 ------------------------------ 2 files changed, 1 insertion(+), 47 deletions(-) delete mode 100644 tests/Support/SimpleContainer.php diff --git a/tests/Support/ListenerTestCase.php b/tests/Support/ListenerTestCase.php index 32269fd..05790b4 100644 --- a/tests/Support/ListenerTestCase.php +++ b/tests/Support/ListenerTestCase.php @@ -12,6 +12,7 @@ use Cycle\ORM\ORMInterface; use Cycle\ORM\Schema; use Cycle\ORM\SchemaInterface; +use Cycle\Testing\Container\SimpleContainer; use Cycle\Testing\ORM\OrmTestCase; /** diff --git a/tests/Support/SimpleContainer.php b/tests/Support/SimpleContainer.php deleted file mode 100644 index d2c3a83..0000000 --- a/tests/Support/SimpleContainer.php +++ /dev/null @@ -1,47 +0,0 @@ -definitions = $definitions; - $this->factory = $factory ?? static function (string $id): void { - throw new class("No definition or class found for \"$id\".") extends \Exception implements NotFoundExceptionInterface {}; - }; - } - - public function get($id): mixed - { - if (!\array_key_exists($id, $this->definitions)) { - $this->definitions[$id] = ($this->factory)($id); - } - return $this->definitions[$id]; - } - - public function has($id): bool - { - if (\array_key_exists($id, $this->definitions)) { - return true; - } - try { - $this->get($id); - return true; - } catch (\Throwable $e) { - return false; - } - } -} From f445a67028337b1f67f64946694622efcf87cb61 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 12:02:11 +0400 Subject: [PATCH 07/14] test: run the tests with Testo through composer scripts PHPUnit and the Rector bridge are no longer used once every test runs on Testo. Assisted-By: Claude Opus 5.5 --- composer.json | 11 ++++++++--- phpunit.xml | 31 ------------------------------- 2 files changed, 8 insertions(+), 34 deletions(-) delete mode 100644 phpunit.xml diff --git a/composer.json b/composer.json index 845ddf2..7514d2a 100644 --- a/composer.json +++ b/composer.json @@ -49,11 +49,9 @@ "cycle/annotated": "^4.6", "cycle/testing": "1.x-dev", "llm/skills": "^1.20", - "phpunit/phpunit": "^11.5", "ramsey/uuid": "^4.9", "roxblnfk/unpoly": "^1.8", "spiral/tokenizer": "^3.18", - "testo/bridge-rector": "^0.3.6", "testo/testo": "^0.10.60" }, "autoload": { @@ -87,10 +85,17 @@ "scripts": { "cs:diff": "php-cs-fixer fix --dry-run -v --diff --config=vendor-bin/code-style/.php-cs-fixer.dist.php", "cs:fix": "php-cs-fixer fix -v --config=vendor-bin/code-style/.php-cs-fixer.dist.php", + "db:down": "docker compose -f vendor/cycle/testing/resources/docker/compose.yaml down -v", + "db:up": "docker compose -f vendor/cycle/testing/resources/docker/compose.yaml up -d --wait", "psalm": "psalm -c vendor-bin/psalm/psalm.xml", "psalm:baseline": "psalm -c vendor-bin/psalm/psalm.xml --set-baseline=vendor-bin/psalm/psalm-baseline.xml", "psalm:ci": "psalm -c vendor-bin/psalm/psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4", - "test": "phpunit --color=always" + "test": "testo", + "test:mysql": "testo --suite=Feature/MySQL --suite=Regression/MySQL", + "test:postgres": "testo --suite=Feature/Postgres --suite=Regression/Postgres", + "test:sqlite": "testo --suite=Feature/SQLite --suite=Regression/SQLite", + "test:sqlserver": "testo --suite=Feature/SQLServer --suite=Regression/SQLServer", + "test:unit": "testo --suite=Unit" }, "extra": { "bamarni-bin": { diff --git a/phpunit.xml b/phpunit.xml deleted file mode 100644 index f1d9a19..0000000 --- a/phpunit.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - ./tests/ - ./tests/Behavior/Functional/Driver/Common - - - - - - src - - - From d2b332136b55ffefd17d71aa0ecf1fe086a8e477 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 12:03:25 +0400 Subject: [PATCH 08/14] ci: run the Testo suites through composer scripts The package compose file waits for the database itself, and DB_REQUIRED=1 makes an unreachable database fail the job instead of skipping its tests. Assisted-By: Claude Opus 5.5 --- .github/workflows/ci-mssql.yml | 55 ++++++++++++++++++++++++++++++---- .github/workflows/ci-mysql.yml | 49 ++++++++++++++++++++++++++---- .github/workflows/ci-pgsql.yml | 49 ++++++++++++++++++++++++++---- .github/workflows/main.yml | 54 +++++++++++++++------------------ CONTRIBUTING.md | 22 +++++++------- 5 files changed, 171 insertions(+), 58 deletions(-) diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml index 23bafb8..b6d816b 100644 --- a/.github/workflows/ci-mssql.yml +++ b/.github/workflows/ci-mssql.yml @@ -1,10 +1,10 @@ --- on: # yamllint disable-line rule:truthy + pull_request: null push: branches: - 1.x - pull_request: null name: MSSQL @@ -16,10 +16,53 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - phpunit: - uses: cycle/gh-actions/.github/workflows/db-mssql.yml@master - with: - php: '["8.2","8.3","8.4","8.5"]' - stability: '["prefer-lowest","prefer-stable"]' + testo: + name: MSSQL, PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }} + runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + php-version: + - "8.2" + - "8.3" + - "8.4" + - "8.5" + dependencies: + - lowest + - highest + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + persist-credentials: false + + - name: Install ODBC driver + run: | + curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list \ + | sudo tee /etc/apt/sources.list.d/mssql-release.list + sudo apt-get update + sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + extensions: mbstring, pdo, sqlsrv, pdo_sqlsrv + + - name: Install dependencies with composer + # TODO(cycle/testing): switch to the released package + uses: ramsey/composer-install@v4 + with: + dependency-versions: ${{ matrix.dependencies }} + + - name: Start MSSQL + run: composer db:up -- sqlserver + + - name: MSSQL tests + env: + DB_REQUIRED: 1 + run: composer test:sqlserver ... diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index 55b16d7..7a292c8 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -1,10 +1,10 @@ --- on: # yamllint disable-line rule:truthy + pull_request: null push: branches: - 1.x - pull_request: null name: MySQL @@ -16,10 +16,47 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - phpunit: - uses: cycle/gh-actions/.github/workflows/db-mysql.yml@master - with: - php: '["8.2","8.3","8.4","8.5"]' - stability: '["prefer-lowest","prefer-stable"]' + testo: + name: MySQL, PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }} + runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + php-version: + - "8.2" + - "8.3" + - "8.4" + - "8.5" + dependencies: + - lowest + - highest + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + persist-credentials: false + + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + extensions: mbstring, pdo, pdo_mysql + + - name: Install dependencies with composer + # TODO(cycle/testing): switch to the released package + uses: ramsey/composer-install@v4 + with: + dependency-versions: ${{ matrix.dependencies }} + + - name: Start MySQL + run: composer db:up -- mysql + + - name: MySQL tests + env: + DB_REQUIRED: 1 + run: composer test:mysql ... diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index dd474b7..169bb25 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -1,10 +1,10 @@ --- on: # yamllint disable-line rule:truthy + pull_request: null push: branches: - 1.x - pull_request: null name: Postgres @@ -16,10 +16,47 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - phpunit: - uses: cycle/gh-actions/.github/workflows/db-pgsql.yml@master - with: - php: '["8.2","8.3","8.4","8.5"]' - stability: '["prefer-lowest","prefer-stable"]' + testo: + name: Postgres, PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }} + runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + php-version: + - "8.2" + - "8.3" + - "8.4" + - "8.5" + dependencies: + - lowest + - highest + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + persist-credentials: false + + + - name: Setup PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: none + extensions: mbstring, pdo, pdo_pgsql + + - name: Install dependencies with composer + # TODO(cycle/testing): switch to the released package + uses: ramsey/composer-install@v4 + with: + dependency-versions: ${{ matrix.dependencies }} + + - name: Start Postgres + run: composer db:up -- postgres + + - name: Postgres tests + env: + DB_REQUIRED: 1 + run: composer test:postgres ... diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 388b7dc..6d69130 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ concurrency: jobs: sqlite: - name: SQLite PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }} + name: Unit and SQLite, PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }} runs-on: ubuntu-latest timeout-minutes: 10 strategy: @@ -45,64 +45,58 @@ jobs: extensions: mbstring, pdo, pdo_sqlite - name: Install dependencies with composer + # TODO(cycle/testing): switch to the released package uses: ramsey/composer-install@v4 with: dependency-versions: ${{ matrix.dependencies }} - - name: Execute Tests + - name: Unit tests + run: composer test:unit + + - name: SQLite tests env: - DB: sqlite - run: vendor/bin/phpunit --group driver-sqlite --colors=always + DB_REQUIRED: 1 + run: composer test:sqlite - test: + coverage: needs: sqlite - name: Test PHP ${{ matrix.php-version }} with Code Coverage + name: Code coverage runs-on: ubuntu-latest - timeout-minutes: 20 + timeout-minutes: 10 strategy: - fail-fast: false matrix: - php-version: - - "8.2" - - "8.3" - - "8.4" - - "8.5" + dependencies: + - highest steps: - - name: Install ODBC driver - run: | - sudo curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list - sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 - - name: Checkout uses: actions/checkout@v7 with: persist-credentials: false - - name: Setup DB services - working-directory: tests - run: docker compose up -d - - - name: Setup PHP ${{ matrix.php-version }} + - name: Setup PHP uses: shivammathur/setup-php@v2 with: - php-version: ${{ matrix.php-version }} + php-version: "8.4" coverage: pcov - tools: pecl - extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, pdo_sqlsrv, pdo_mysql + extensions: mbstring, pdo, pdo_sqlite - name: Install dependencies with composer + # TODO(cycle/testing): switch to the released package uses: ramsey/composer-install@v4 with: - dependency-versions: highest + dependency-versions: ${{ matrix.dependencies }} - - name: Execute Tests - run: vendor/bin/phpunit --coverage-clover=coverage.clover + - name: Unit and SQLite tests with coverage + env: + DB_DRIVERS: sqlite + DB_REQUIRED: 1 + run: composer test -- --coverage-clover=runtime/clover.xml - name: Upload coverage to Codecov continue-on-error: true # forks have no token uses: codecov/codecov-action@v7 with: token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage.clover + files: ./runtime/clover.xml ... diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0b08636..490de2d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,23 +10,25 @@ Please make sure that the following requirements are satisfied before submitting > Use our discord server to check for the advice or suggestion https://discord.gg/FZ9BCWg ## Testing Cycle ORM Entity Behavior -To test Cycle ORM Entity Behavior locally, download the `cycle/entity-behavior` repository and start docker containers inside the tests folder: +Tests run on [Testo](https://github.com/php-testo/testo) through the `cycle/testing` harness: `tests/Unit` needs no +database, `tests/Feature` runs once per database driver. +Reproductions of reported issues go to `tests/Regression/Issue/`; start from `tests/Regression/CaseTemplate` +(`php tests/generate-case.php --case-name=Issue` copies it). -```bash -$ cd tests/ -$ docker-composer up -``` - -To run full test suite: +Unit and SQLite tests need no docker: ```bash -$ ./vendor/bin/phpunit +composer test:unit +composer test:sqlite ``` -To run quick test suite: +The other drivers run against the shared test databases: ```bash -$ ./vendor/bin/phpunit --group driver-sqlite +composer db:up # or: composer db:up -- mysql +composer test # every suite; drivers whose server is down are skipped +composer test:mysql # also test:postgres, test:sqlserver +composer db:down ``` ## Help Needed In From 983c1b2a16a8bea23feb21246bb6fea0d1d3e332 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 15:57:41 +0400 Subject: [PATCH 09/14] build: install cycle/testing from its repository Assisted-By: Claude Opus 5.5 --- .github/workflows/ci-mssql.yml | 1 - .github/workflows/ci-mysql.yml | 1 - .github/workflows/ci-pgsql.yml | 1 - .github/workflows/main.yml | 2 -- composer.json | 9 +++------ 5 files changed, 3 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml index b6d816b..6fc50e2 100644 --- a/.github/workflows/ci-mssql.yml +++ b/.github/workflows/ci-mssql.yml @@ -52,7 +52,6 @@ jobs: extensions: mbstring, pdo, sqlsrv, pdo_sqlsrv - name: Install dependencies with composer - # TODO(cycle/testing): switch to the released package uses: ramsey/composer-install@v4 with: dependency-versions: ${{ matrix.dependencies }} diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml index 7a292c8..ffeb858 100644 --- a/.github/workflows/ci-mysql.yml +++ b/.github/workflows/ci-mysql.yml @@ -46,7 +46,6 @@ jobs: extensions: mbstring, pdo, pdo_mysql - name: Install dependencies with composer - # TODO(cycle/testing): switch to the released package uses: ramsey/composer-install@v4 with: dependency-versions: ${{ matrix.dependencies }} diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml index 169bb25..9ad9422 100644 --- a/.github/workflows/ci-pgsql.yml +++ b/.github/workflows/ci-pgsql.yml @@ -46,7 +46,6 @@ jobs: extensions: mbstring, pdo, pdo_pgsql - name: Install dependencies with composer - # TODO(cycle/testing): switch to the released package uses: ramsey/composer-install@v4 with: dependency-versions: ${{ matrix.dependencies }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6d69130..0d75348 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,7 +45,6 @@ jobs: extensions: mbstring, pdo, pdo_sqlite - name: Install dependencies with composer - # TODO(cycle/testing): switch to the released package uses: ramsey/composer-install@v4 with: dependency-versions: ${{ matrix.dependencies }} @@ -81,7 +80,6 @@ jobs: extensions: mbstring, pdo, pdo_sqlite - name: Install dependencies with composer - # TODO(cycle/testing): switch to the released package uses: ramsey/composer-install@v4 with: dependency-versions: ${{ matrix.dependencies }} diff --git a/composer.json b/composer.json index 7514d2a..7037caf 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "bamarni/composer-bin-plugin": "^1.8", "buggregator/trap": "^1.20", "cycle/annotated": "^4.6", - "cycle/testing": "1.x-dev", + "cycle/testing": "^0.1", "llm/skills": "^1.20", "ramsey/uuid": "^4.9", "roxblnfk/unpoly": "^1.8", @@ -66,11 +66,8 @@ }, "repositories": [ { - "type": "path", - "url": "../../testing", - "options": { - "symlink": true - } + "type": "vcs", + "url": "https://github.com/cycle/testing" } ], "config": { From 3a41bc157cac0b0cbd4875f93ea6259573dc0aba Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 16:07:55 +0400 Subject: [PATCH 10/14] ci: collect coverage on every driver The PHPUnit coverage job ran all drivers, so a SQLite-only run drops the lines only the server drivers reach. Assisted-By: Claude Opus 5.5 --- .github/workflows/main.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0d75348..555b380 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -61,7 +61,7 @@ jobs: needs: sqlite name: Code coverage runs-on: ubuntu-latest - timeout-minutes: 10 + timeout-minutes: 20 strategy: matrix: dependencies: @@ -72,21 +72,29 @@ jobs: with: persist-credentials: false + - name: Install ODBC driver + run: | + curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list + sudo apt-get update + sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: "8.4" coverage: pcov - extensions: mbstring, pdo, pdo_sqlite + extensions: mbstring, pdo, pdo_sqlite, pdo_mysql, pdo_pgsql, sqlsrv, pdo_sqlsrv - name: Install dependencies with composer uses: ramsey/composer-install@v4 with: dependency-versions: ${{ matrix.dependencies }} - - name: Unit and SQLite tests with coverage + - name: Start databases + run: composer db:up + + - name: Tests on every driver with coverage env: - DB_DRIVERS: sqlite DB_REQUIRED: 1 run: composer test -- --coverage-clover=runtime/clover.xml From 80adc0924c28f6b87aa8a7fd1d47dcfdc8c11c89 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 17:00:36 +0400 Subject: [PATCH 11/14] build: update cycle/testing to 0.1.1 Assisted-By: Claude Opus 5.5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 7037caf..cf51390 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ "bamarni/composer-bin-plugin": "^1.8", "buggregator/trap": "^1.20", "cycle/annotated": "^4.6", - "cycle/testing": "^0.1", + "cycle/testing": "^0.1.1", "llm/skills": "^1.20", "ramsey/uuid": "^4.9", "roxblnfk/unpoly": "^1.8", From 777b254fceecf53b0445f9a221b19a305ba0d67d Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 17:02:08 +0400 Subject: [PATCH 12/14] test: generate regression cases with cycle-testing new-case The orm-behaviors template of cycle/testing replaces the local CaseTemplate and its copy script. Assisted-By: Claude Opus 5.5 --- CONTRIBUTING.md | 4 +- composer.json | 4 + tests/Regression/CaseTemplate/CaseTest.php | 132 ------------------ .../CaseTemplate/Entity/Comment.php | 51 ------- tests/Regression/CaseTemplate/Entity/Post.php | 64 --------- .../CaseTemplate/Entity/PostTag.php | 20 --- tests/Regression/CaseTemplate/Entity/Tag.php | 31 ---- tests/Regression/CaseTemplate/Entity/User.php | 41 ------ tests/generate-case.php | 82 ----------- 9 files changed, 6 insertions(+), 423 deletions(-) delete mode 100644 tests/Regression/CaseTemplate/CaseTest.php delete mode 100644 tests/Regression/CaseTemplate/Entity/Comment.php delete mode 100644 tests/Regression/CaseTemplate/Entity/Post.php delete mode 100644 tests/Regression/CaseTemplate/Entity/PostTag.php delete mode 100644 tests/Regression/CaseTemplate/Entity/Tag.php delete mode 100644 tests/Regression/CaseTemplate/Entity/User.php delete mode 100644 tests/generate-case.php diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 490de2d..dbcc070 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,8 +12,8 @@ Please make sure that the following requirements are satisfied before submitting ## Testing Cycle ORM Entity Behavior Tests run on [Testo](https://github.com/php-testo/testo) through the `cycle/testing` harness: `tests/Unit` needs no database, `tests/Feature` runs once per database driver. -Reproductions of reported issues go to `tests/Regression/Issue/`; start from `tests/Regression/CaseTemplate` -(`php tests/generate-case.php --case-name=Issue` copies it). +Reproductions of reported issues go to `tests/Regression/Issue/`; `composer test:new-case -- ` writes a runnable +case there to start from. Unit and SQLite tests need no docker: diff --git a/composer.json b/composer.json index cf51390..abff212 100644 --- a/composer.json +++ b/composer.json @@ -89,11 +89,15 @@ "psalm:ci": "psalm -c vendor-bin/psalm/psalm.xml --output-format=github --shepherd --show-info=false --stats --threads=4", "test": "testo", "test:mysql": "testo --suite=Feature/MySQL --suite=Regression/MySQL", + "test:new-case": "cycle-testing new-case --template=orm-behaviors", "test:postgres": "testo --suite=Feature/Postgres --suite=Regression/Postgres", "test:sqlite": "testo --suite=Feature/SQLite --suite=Regression/SQLite", "test:sqlserver": "testo --suite=Feature/SQLServer --suite=Regression/SQLServer", "test:unit": "testo --suite=Unit" }, + "scripts-descriptions": { + "test:new-case": "Write a regression case into tests/Regression/Issue: composer test:new-case -- " + }, "extra": { "bamarni-bin": { "bin-links": true, diff --git a/tests/Regression/CaseTemplate/CaseTest.php b/tests/Regression/CaseTemplate/CaseTest.php deleted file mode 100644 index 30b6e92..0000000 --- a/tests/Regression/CaseTemplate/CaseTest.php +++ /dev/null @@ -1,132 +0,0 @@ -orm, Entity\User::class)) - ->load('posts') - ->wherePK(2) - ->fetchOne(); - \assert($user instanceof Entity\User); - - // Check results - Assert::notNull($user->createdAt); - Assert::notNull($user->updatedAt); - Assert::same($user->createdAt <=> $user->updatedAt, 0); - } - - #[Test] - public function testCreatedAt(): void - { - // Get entity - $user = $this->orm->make(Entity\User::class, ['login' => 'new-user', 'passwordHash' => '123456789']); - - Assert::false(isset($user->createdAt)); - $this->save($user); - - Assert::notNull($user->createdAt); - - // Reload entity - $id = $user->id; - $this->cleanHeap(); - $user = (new Select($this->orm, Entity\User::class)) - ->wherePK($id) - ->fetchOne(); - Assert::notNull($user->createdAt); - } - - #[Test] - public function testUpdatedAt(): void - { - // Get entity - $user = (new Select($this->orm, Entity\User::class)) - ->wherePK(2) - ->fetchOne(); - \assert($user instanceof Entity\User); - $updatedAt = $user->updatedAt; - - // Change data - $user->passwordHash = 'new-password-hash'; - $this->save($user); - - // Check results - Assert::same($user->updatedAt <=> $updatedAt, 1); - } - - #[BeforeTest] - protected function setUp(): void - { - $this->prepareOrm(__DIR__ . '/Entity'); - $this->save(...$this->fillData()); - $this->orm->getHeap()->clean(); - } - - private function fillData(): iterable - { - /** - * @var callable(class-string, array): object $c - */ - $c = \Closure::fromCallable([$this->orm, 'make']); - - // Users - $u1 = $c(Entity\User::class, ['login' => 'user-1', 'passwordHash' => '123456789']); - $u2 = $c(Entity\User::class, ['login' => 'user-2', 'passwordHash' => '852741963']); - $u3 = $c(Entity\User::class, ['login' => 'user-3', 'passwordHash' => '321654987']); - $u4 = $c(Entity\User::class, ['login' => 'user-4', 'passwordHash' => '321456987']); - - // Posts - $p1 = $c(Entity\Post::class, ['slug' => 'slug-string-1', 'title' => 'Title 1', 'public' => true, 'content' => 'Foo-bar-baz content 1']); - $p2 = $c(Entity\Post::class, ['slug' => 'slug-string-2', 'title' => 'Title 2', 'public' => true, 'content' => 'Foo-bar-baz content 2']); - $p3 = $c(Entity\Post::class, ['slug' => 'slug-string-3', 'title' => 'Title 3', 'public' => false, 'content' => 'Foo-bar-baz content 3']); - $p4 = $c(Entity\Post::class, ['slug' => 'slug-string-4', 'title' => 'Title 4', 'public' => true, 'content' => 'Foo-bar-baz content 4']); - $p5 = $c(Entity\Post::class, ['slug' => 'slug-string-5', 'title' => 'Title 5', 'public' => true, 'content' => 'Foo-bar-baz content 5']); - $p6 = $c(Entity\Post::class, ['slug' => 'slug-string-6', 'title' => 'Title 6', 'public' => true, 'content' => 'Foo-bar-baz content 6']); - - // Link posts with users - $u1->posts = [$p1]; - $u2->posts = [$p2, $p3]; - $u3->posts = [$p4, $p5, $p6]; - - // Comments - $c1 = $c(Entity\Comment::class, ['post' => $p1, 'user' => $u2, 'content' => 'Foo-bar-baz comment 1', 'public' => true]); - $c2 = $c(Entity\Comment::class, ['post' => $p1, 'user' => $u1, 'content' => 'Reply to comment 1', 'public' => true]); - $c3 = $c(Entity\Comment::class, ['post' => $p2, 'user' => $u1, 'content' => 'Foo-bar-baz comment 2', 'public' => true]); - $c4 = $c(Entity\Comment::class, ['post' => $p2, 'user' => $u2, 'content' => 'Reply to comment 2', 'public' => true]); - $c5 = $c(Entity\Comment::class, ['post' => $p2, 'user' => $u3, 'content' => 'Foo-bar-baz comment 3', 'public' => true]); - $c6 = $c(Entity\Comment::class, ['post' => $p2, 'user' => $u4, 'content' => 'Hidden comment', 'public' => false]); - $c7 = $c(Entity\Comment::class, ['post' => $p2, 'user' => $u4, 'content' => 'Yet another comment', 'public' => true]); - - // Tags - $t1 = $c(Entity\Tag::class, ['label' => 'tag-1']); - $t2 = $c(Entity\Tag::class, ['label' => 'tag-2']); - $t3 = $c(Entity\Tag::class, ['label' => 'tag-3']); - $t4 = $c(Entity\Tag::class, ['label' => 'tag-4']); - $t5 = $c(Entity\Tag::class, ['label' => 'tag-5']); - - // Link tags with posts - $t1->posts = [$p1, $p2]; - $t2->posts = [$p2, $p3]; - $t3->posts = [$p3, $p4, $p5]; - $t4->posts = [$p4, $p5]; - $t5->posts = [$p5, $p6, $p1]; - - // yield all the entities - yield from [$u1, $u2, $u3, $u4]; - yield from [$p1, $p2, $p3, $p4, $p5, $p6]; - yield from [$c1, $c2, $c3, $c4, $c5, $c6, $c7]; - yield from [$t1, $t2, $t3, $t4, $t5]; - } -} diff --git a/tests/Regression/CaseTemplate/Entity/Comment.php b/tests/Regression/CaseTemplate/Entity/Comment.php deleted file mode 100644 index f42fbab..0000000 --- a/tests/Regression/CaseTemplate/Entity/Comment.php +++ /dev/null @@ -1,51 +0,0 @@ - */ - #[ManyToMany(target: Tag::class, innerKey: 'id', outerKey: 'id', throughInnerKey: 'postId', throughOuterKey: 'tagId', through: PostTag::class)] - public iterable $tags = []; - - /** @var iterable */ - #[HasMany(target: Comment::class, innerKey: 'id', outerKey: 'postId', fkCreate: false)] - public iterable $comments = []; - - private function __construct() {} -} diff --git a/tests/Regression/CaseTemplate/Entity/PostTag.php b/tests/Regression/CaseTemplate/Entity/PostTag.php deleted file mode 100644 index fed1fd3..0000000 --- a/tests/Regression/CaseTemplate/Entity/PostTag.php +++ /dev/null @@ -1,20 +0,0 @@ - */ - #[ManyToMany(target: Post::class, innerKey: 'id', outerKey: 'id', throughInnerKey: 'tagId', throughOuterKey: 'postId', through: PostTag::class)] - public iterable $posts = []; - - private function __construct() {} -} diff --git a/tests/Regression/CaseTemplate/Entity/User.php b/tests/Regression/CaseTemplate/Entity/User.php deleted file mode 100644 index 47025e8..0000000 --- a/tests/Regression/CaseTemplate/Entity/User.php +++ /dev/null @@ -1,41 +0,0 @@ - */ - #[HasMany(target: Post::class, innerKey: 'id', outerKey: 'userId', fkCreate: false)] - public iterable $posts = []; - - /** @var iterable */ - #[HasMany(target: Comment::class, innerKey: 'id', outerKey: 'userId', fkCreate: false)] - public iterable $comments = []; - - private function __construct() {} -} diff --git a/tests/generate-case.php b/tests/generate-case.php deleted file mode 100644 index 9e6495f..0000000 --- a/tests/generate-case.php +++ /dev/null @@ -1,82 +0,0 @@ -getRealPath(); - $target = \substr($filePath, \strlen($caseTemplateDir)); - - // creating directory... - $dirName = \dirname($copyDir . $target); - if (!\is_dir($dirName)) { - \mkdir($dirName, recursive: true); - } - - $contents = \str_replace($caseTemplateDirName, \basename($copyDir), \file_get_contents($filePath)); - \file_put_contents($copyDir . $target, $contents); - } -} - -$options = \getopt('', [ - 'case-name:', - 'template:', -]); - -$copyDir = isset($options['case-name']) - ? $integrationDir . DIRECTORY_SEPARATOR . $options['case-name'] - : defaultCaseName($integrationDir); - -if (\file_exists($copyDir)) { - echo "Error. Tests folder `$copyDir` already exists\n"; - exit(1); -} - -echo \sprintf("Generating new test case '%s'... \n", \basename($copyDir)); - -\mkdir($copyDir); -$copyDir = \realpath($copyDir); - -copyTemplateFiles($copyDir, $options['template'] ?? 'CaseTemplate'); - -echo "Done. New test case is here:\n$copyDir\n"; From 28818a68172f7d4bf661cba5da89a1db0598711b Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 17:07:16 +0400 Subject: [PATCH 13/14] ci: run tests through the shared cycle/gh-actions workflow Assisted-By: Claude Opus 5.5 --- .github/workflows/ci-mssql.yml | 67 -------------------- .github/workflows/ci-mysql.yml | 61 ------------------- .github/workflows/ci-pgsql.yml | 61 ------------------- .github/workflows/main.yml | 108 --------------------------------- .github/workflows/testing.yml | 25 ++++++++ 5 files changed, 25 insertions(+), 297 deletions(-) delete mode 100644 .github/workflows/ci-mssql.yml delete mode 100644 .github/workflows/ci-mysql.yml delete mode 100644 .github/workflows/ci-pgsql.yml delete mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/testing.yml diff --git a/.github/workflows/ci-mssql.yml b/.github/workflows/ci-mssql.yml deleted file mode 100644 index 6fc50e2..0000000 --- a/.github/workflows/ci-mssql.yml +++ /dev/null @@ -1,67 +0,0 @@ ---- - -on: # yamllint disable-line rule:truthy - pull_request: null - push: - branches: - - 1.x - -name: MSSQL - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -jobs: - testo: - name: MSSQL, PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }} - runs-on: ubuntu-latest - timeout-minutes: 15 - strategy: - fail-fast: false - matrix: - php-version: - - "8.2" - - "8.3" - - "8.4" - - "8.5" - dependencies: - - lowest - - highest - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - name: Install ODBC driver - run: | - curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list \ - | sudo tee /etc/apt/sources.list.d/mssql-release.list - sudo apt-get update - sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 - - - name: Setup PHP ${{ matrix.php-version }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - coverage: none - extensions: mbstring, pdo, sqlsrv, pdo_sqlsrv - - - name: Install dependencies with composer - uses: ramsey/composer-install@v4 - with: - dependency-versions: ${{ matrix.dependencies }} - - - name: Start MSSQL - run: composer db:up -- sqlserver - - - name: MSSQL tests - env: - DB_REQUIRED: 1 - run: composer test:sqlserver - -... diff --git a/.github/workflows/ci-mysql.yml b/.github/workflows/ci-mysql.yml deleted file mode 100644 index ffeb858..0000000 --- a/.github/workflows/ci-mysql.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- - -on: # yamllint disable-line rule:truthy - pull_request: null - push: - branches: - - 1.x - -name: MySQL - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -jobs: - testo: - name: MySQL, PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }} - runs-on: ubuntu-latest - timeout-minutes: 15 - strategy: - fail-fast: false - matrix: - php-version: - - "8.2" - - "8.3" - - "8.4" - - "8.5" - dependencies: - - lowest - - highest - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - - name: Setup PHP ${{ matrix.php-version }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - coverage: none - extensions: mbstring, pdo, pdo_mysql - - - name: Install dependencies with composer - uses: ramsey/composer-install@v4 - with: - dependency-versions: ${{ matrix.dependencies }} - - - name: Start MySQL - run: composer db:up -- mysql - - - name: MySQL tests - env: - DB_REQUIRED: 1 - run: composer test:mysql - -... diff --git a/.github/workflows/ci-pgsql.yml b/.github/workflows/ci-pgsql.yml deleted file mode 100644 index 9ad9422..0000000 --- a/.github/workflows/ci-pgsql.yml +++ /dev/null @@ -1,61 +0,0 @@ ---- - -on: # yamllint disable-line rule:truthy - pull_request: null - push: - branches: - - 1.x - -name: Postgres - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -jobs: - testo: - name: Postgres, PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }} - runs-on: ubuntu-latest - timeout-minutes: 15 - strategy: - fail-fast: false - matrix: - php-version: - - "8.2" - - "8.3" - - "8.4" - - "8.5" - dependencies: - - lowest - - highest - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - - name: Setup PHP ${{ matrix.php-version }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - coverage: none - extensions: mbstring, pdo, pdo_pgsql - - - name: Install dependencies with composer - uses: ramsey/composer-install@v4 - with: - dependency-versions: ${{ matrix.dependencies }} - - - name: Start Postgres - run: composer db:up -- postgres - - - name: Postgres tests - env: - DB_REQUIRED: 1 - run: composer test:postgres - -... diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 555b380..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,108 +0,0 @@ ---- - -on: # yamllint disable-line rule:truthy - pull_request: null - push: - branches: - - 1.x - -name: build - -permissions: - contents: read - -concurrency: - group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} - cancel-in-progress: ${{ github.event_name == 'pull_request' }} - -jobs: - sqlite: - name: Unit and SQLite, PHP ${{ matrix.php-version }}, ${{ matrix.dependencies }} - runs-on: ubuntu-latest - timeout-minutes: 10 - strategy: - fail-fast: false - matrix: - php-version: - - "8.2" - - "8.3" - - "8.4" - - "8.5" - dependencies: - - lowest - - highest - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - name: Setup PHP ${{ matrix.php-version }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - coverage: none - extensions: mbstring, pdo, pdo_sqlite - - - name: Install dependencies with composer - uses: ramsey/composer-install@v4 - with: - dependency-versions: ${{ matrix.dependencies }} - - - name: Unit tests - run: composer test:unit - - - name: SQLite tests - env: - DB_REQUIRED: 1 - run: composer test:sqlite - - coverage: - needs: sqlite - name: Code coverage - runs-on: ubuntu-latest - timeout-minutes: 20 - strategy: - matrix: - dependencies: - - highest - steps: - - name: Checkout - uses: actions/checkout@v7 - with: - persist-credentials: false - - - name: Install ODBC driver - run: | - curl https://packages.microsoft.com/config/ubuntu/$(lsb_release -rs)/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list - sudo apt-get update - sudo ACCEPT_EULA=Y apt-get install -y msodbcsql18 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "8.4" - coverage: pcov - extensions: mbstring, pdo, pdo_sqlite, pdo_mysql, pdo_pgsql, sqlsrv, pdo_sqlsrv - - - name: Install dependencies with composer - uses: ramsey/composer-install@v4 - with: - dependency-versions: ${{ matrix.dependencies }} - - - name: Start databases - run: composer db:up - - - name: Tests on every driver with coverage - env: - DB_REQUIRED: 1 - run: composer test -- --coverage-clover=runtime/clover.xml - - - name: Upload coverage to Codecov - continue-on-error: true # forks have no token - uses: codecov/codecov-action@v7 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./runtime/clover.xml - -... diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml new file mode 100644 index 0000000..3aa714a --- /dev/null +++ b/.github/workflows/testing.yml @@ -0,0 +1,25 @@ +--- + +name: 🧪 Tests + +on: # yamllint disable-line rule:truthy + pull_request: + push: + branches: + - 1.x + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +permissions: + contents: read + +jobs: + testo: + uses: cycle/gh-actions/.github/workflows/testo.yml@master + with: + coverage: true + secrets: inherit + +... From 0c4f0b88625b8eac8238461e62ce54f51b69a34a Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 17:30:55 +0400 Subject: [PATCH 14/14] ci: show the test job as Testo Assisted-By: Claude Opus 5.5 --- .github/workflows/testing.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 3aa714a..0b0fb38 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -17,6 +17,7 @@ permissions: jobs: testo: + name: Testo uses: cycle/gh-actions/.github/workflows/testo.yml@master with: coverage: true