From cf66d3779ba0f8bb3870292ab2ee546ef5bf10fb Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 11:15:34 +0400 Subject: [PATCH 01/12] test: wire cycle/testing and Testo PHPUnit stays the test runner until the tests are migrated. Assisted-By: Claude Opus 5.5 --- composer.json | 13 ++++++++++++- testo.php | 16 ++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 testo.php diff --git a/composer.json b/composer.json index 3a34689a..d0ca4368 100644 --- a/composer.json +++ b/composer.json @@ -36,6 +36,15 @@ "url": "https://github.com/sponsors/cycle" } ], + "repositories": [ + { + "type": "path", + "url": "../../testing", + "options": { + "symlink": true + } + } + ], "require": { "php": ">=8.2", "cycle/database": "^2.23", @@ -48,10 +57,12 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.8", "buggregator/trap": "^1.20", + "cycle/testing": "1.x-dev", "doctrine/annotations": "^2.0.2", "llm/skills": "^1.20", "phpunit/phpunit": "^11.5", - "roxblnfk/unpoly": "^1.8" + "roxblnfk/unpoly": "^1.8", + "testo/testo": "^0.10.60" }, "suggest": { "llm/skills": "To sync the cycle-orm-attributes AI skill into your project" diff --git a/testo.php b/testo.php new file mode 100644 index 00000000..df5b02b7 --- /dev/null +++ b/testo.php @@ -0,0 +1,16 @@ +unit('tests/Annotated/Unit') + ->acceptance( + 'tests/Annotated/Acceptance', + layout: Layout::prefixed(['secondary' => 'secondary_']), + plugins: [new OrmPlugin()], + ) + ->build(); From f50c32fee95436d441964a88dd9fae50ac454d8c Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 11:36:54 +0400 Subject: [PATCH 02/12] test: split Testo suites into Feature and Regression Assisted-By: Claude Opus 5.5 --- testo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testo.php b/testo.php index df5b02b7..3aef8dff 100644 --- a/testo.php +++ b/testo.php @@ -8,8 +8,8 @@ return Config::forPackage('cycle/annotated', root: __DIR__) ->unit('tests/Annotated/Unit') - ->acceptance( - 'tests/Annotated/Acceptance', + ->feature( + 'tests/Annotated/Feature', layout: Layout::prefixed(['secondary' => 'secondary_']), plugins: [new OrmPlugin()], ) From 6140f769f0b9394a7d2c796480cda8d1125269fc Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 11:59:09 +0400 Subject: [PATCH 03/12] test: convert PHPUnit tests to Testo with Rector A mechanical pass of the PHPUNIT_TO_TESTO set, kept apart from the harness migration so the hand-written changes review on their own; the generated per-driver stubs are left for that step to delete. Assisted-By: Claude Opus 5.5 --- composer.json | 4 +- .../Functional/Driver/Common/BaseTestCase.php | 6 +- .../Driver/Common/ChildTestCase.php | 9 +- .../Common/CompositePkGeneratedTestCase.php | 36 ++- .../Driver/Common/GeneratedFieldsTestCase.php | 18 +- .../Driver/Common/GeneratorTestCase.php | 93 +++---- .../Inheritance/JoinedTableTestCase.php | 80 +++--- .../Inheritance/SingleTableTestCase.php | 229 ++++++++---------- .../Driver/Common/InheritanceTestCase.php | 144 +++++------ .../Driver/Common/InvalidTestCase.php | 11 +- .../Common/Relation/BelongsToTestCase.php | 9 +- .../Common/Relation/CompositeKeysTestCase.php | 5 +- .../Common/Relation/EmbeddedTestCase.php | 38 +-- .../Common/Relation/HasManyTestCase.php | 39 +-- .../Driver/Common/Relation/HasOneTestCase.php | 31 +-- .../Common/Relation/InverseTestCase.php | 85 ++++--- .../Common/Relation/ManyToManyTestCase.php | 91 ++----- .../Morphed/BelongsToMorphedTestCase.php | 17 +- .../Morphed/MorphedHasManyTestCase.php | 56 ++--- .../Morphed/MorphedHasOneTestCase.php | 39 ++- .../Morphed/RefersToMorphedTestCase.php | 19 +- .../Common/Relation/RefersToTestCase.php | 22 +- .../Driver/Common/SchemaModifiersTestCase.php | 13 +- .../Driver/Common/TableTestCase.php | 135 ++++++----- .../Driver/Common/TypecastTestCase.php | 40 ++- .../Functional/Driver/MySQL/TableTest.php | 29 ++- .../Driver/Postgres/GeneratedFieldsTest.php | 22 +- tests/Annotated/Unit/Attribute/ColumnTest.php | 55 +++-- .../Attribute/SingleTable/SingleTableTest.php | 7 +- .../Locator/TokenizerEmbeddingLocatorTest.php | 7 +- .../Locator/TokenizerEntityLocatorTest.php | 7 +- tests/Annotated/Unit/ReaderFactoryTest.php | 11 +- .../Annotated/Unit/Utils/EntityUtilsTest.php | 13 +- 33 files changed, 667 insertions(+), 753 deletions(-) diff --git a/composer.json b/composer.json index d0ca4368..82feb673 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,9 @@ "llm/skills": "^1.20", "phpunit/phpunit": "^11.5", "roxblnfk/unpoly": "^1.8", - "testo/testo": "^0.10.60" + "testo/testo": "^0.10.60", + "testo/bridge-rector": "^0.3.6", + "rector/rector": "^2.8" }, "suggest": { "llm/skills": "To sync the cycle-orm-attributes AI skill into your project" diff --git a/tests/Annotated/Functional/Driver/Common/BaseTestCase.php b/tests/Annotated/Functional/Driver/Common/BaseTestCase.php index bbe78715..40288eb2 100644 --- a/tests/Annotated/Functional/Driver/Common/BaseTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/BaseTestCase.php @@ -22,7 +22,7 @@ use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -abstract class BaseTestCase extends TestCase +abstract class BaseTestCase { // currently active driver public const DRIVER = null; @@ -69,10 +69,9 @@ public function getDriver(): Driver /** * Init all we need. */ + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { - parent::setUp(); - $this->dbal = new DatabaseManager(new DatabaseConfig(['default' => 'default'])); $this->dbal->addDatabase(new Database( 'default', @@ -116,6 +115,7 @@ public function setUp(): void /** * Cleanup. */ + #[\Testo\Lifecycle\AfterTest] public function tearDown(): void { $this->disableProfiling(); diff --git a/tests/Annotated/Functional/Driver/Common/ChildTestCase.php b/tests/Annotated/Functional/Driver/Common/ChildTestCase.php index 69a126db..e5089752 100644 --- a/tests/Annotated/Functional/Driver/Common/ChildTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/ChildTestCase.php @@ -52,7 +52,8 @@ abstract class ChildTestCase extends BaseTestCase // $this->assertSame([Schema::ROLE => 'simple'], $schema[Third::class]); // } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelationToChild(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -77,9 +78,9 @@ public function testRelationToChild(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('article', $schema['some'][Schema::RELATIONS]); - $this->assertSame(Relation::HAS_ONE, $schema['some'][Schema::RELATIONS]['article'][Relation::TYPE]); + \Testo\Assert::array($schema['some'][Schema::RELATIONS])->hasKeys('article'); + \Testo\Assert::same($schema['some'][Schema::RELATIONS]['article'][Relation::TYPE], Relation::HAS_ONE); - $this->assertSame('post', $schema['some'][Schema::RELATIONS]['article'][Relation::TARGET]); + \Testo\Assert::same($schema['some'][Schema::RELATIONS]['article'][Relation::TARGET], 'post'); } } diff --git a/tests/Annotated/Functional/Driver/Common/CompositePkGeneratedTestCase.php b/tests/Annotated/Functional/Driver/Common/CompositePkGeneratedTestCase.php index 38fb7d68..c2f7552a 100644 --- a/tests/Annotated/Functional/Driver/Common/CompositePkGeneratedTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/CompositePkGeneratedTestCase.php @@ -44,29 +44,24 @@ abstract class CompositePkGeneratedTestCase extends BaseTestCase * The composite PK and the database-generated component must be derived * from the attributes alone. */ - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testCompositePkSchema(ReaderInterface $reader): void { $schema = $this->compile($reader); - $this->assertSame(['parentId', 'id'], $schema['event'][SchemaInterface::PRIMARY_KEY]); - $this->assertSame( - ['parentId' => 'parent_id', 'id' => 'id', 'payload' => 'payload'], - $schema['event'][SchemaInterface::COLUMNS], - ); + \Testo\Assert::same($schema['event'][SchemaInterface::PRIMARY_KEY], ['parentId', 'id']); + \Testo\Assert::same($schema['event'][SchemaInterface::COLUMNS], ['parentId' => 'parent_id', 'id' => 'id', 'payload' => 'payload']); // Both primary columns are flagged ON_INSERT: the bigserial `id` is // genuinely database-generated, while the app-supplied uuid `parentId` // is auto-flagged purely because it is primary (see Event::$parentId // and Configurator::isOnInsertGeneratedField()). The parentId flag only // echoes the value back via RETURNING — harmless for a uuid string. - $this->assertSame( - [ - 'parentId' => GeneratedField::ON_INSERT, - 'id' => GeneratedField::ON_INSERT, - ], - $schema['event'][SchemaInterface::GENERATED_FIELDS], - ); + \Testo\Assert::same($schema['event'][SchemaInterface::GENERATED_FIELDS], [ + 'parentId' => GeneratedField::ON_INSERT, + 'id' => GeneratedField::ON_INSERT, + ]); } /** @@ -74,7 +69,8 @@ public function testCompositePkSchema(ReaderInterface $reader): void * database-generated ids returned on INSERT, and can be fetched back by * the full composite key. */ - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testCreateGeneratesIdAndFetchByCompositePk(ReaderInterface $reader): void { $orm = new ORM( @@ -95,9 +91,9 @@ public function testCreateGeneratesIdAndFetchByCompositePk(ReaderInterface $read (new EntityManager($orm))->persist($first)->persist($second)->run(); // database-generated ids - $this->assertIsInt($first->id); - $this->assertIsInt($second->id); - $this->assertNotSame($first->id, $second->id); + \Testo\Assert::int($first->id); + \Testo\Assert::int($second->id); + \Testo\Assert::notSame($second->id, $first->id); // fetch by the full composite key $found = (new Select($orm, Event::class)) @@ -105,9 +101,9 @@ public function testCreateGeneratesIdAndFetchByCompositePk(ReaderInterface $read ->where('id', $second->id) ->fetchOne(); - $this->assertNotNull($found); - $this->assertSame('second', $found->payload); - $this->assertSame($second, $found, 'Heap returns the same identity for the composite key.'); + \Testo\Assert::notNull($found); + \Testo\Assert::same($found->payload, 'second'); + \Testo\Assert::same($found, $second, 'Heap returns the same identity for the composite key.'); } private function compile(ReaderInterface $reader): array diff --git a/tests/Annotated/Functional/Driver/Common/GeneratedFieldsTestCase.php b/tests/Annotated/Functional/Driver/Common/GeneratedFieldsTestCase.php index 7ef6dd04..b4f1f1b6 100644 --- a/tests/Annotated/Functional/Driver/Common/GeneratedFieldsTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/GeneratedFieldsTestCase.php @@ -17,7 +17,8 @@ abstract class GeneratedFieldsTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testGeneratedFields(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -32,14 +33,11 @@ public function testGeneratedFields(ReaderInterface $reader): void new Entities(new TokenizerEntityLocator($locator, $reader), $reader), ]); - $this->assertSame( - [ - 'id' => GeneratedField::ON_INSERT, - 'createdAt' => GeneratedField::BEFORE_INSERT, - 'createdAtGeneratedByDatabase' => GeneratedField::ON_INSERT, - 'updatedAt' => GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE, - ], - $schema['withGeneratedFields'][SchemaInterface::GENERATED_FIELDS], - ); + \Testo\Assert::same($schema['withGeneratedFields'][SchemaInterface::GENERATED_FIELDS], [ + 'id' => GeneratedField::ON_INSERT, + 'createdAt' => GeneratedField::BEFORE_INSERT, + 'createdAtGeneratedByDatabase' => GeneratedField::ON_INSERT, + 'updatedAt' => GeneratedField::BEFORE_INSERT | GeneratedField::BEFORE_UPDATE, + ]); } } diff --git a/tests/Annotated/Functional/Driver/Common/GeneratorTestCase.php b/tests/Annotated/Functional/Driver/Common/GeneratorTestCase.php index 33b1cadb..5795f41d 100644 --- a/tests/Annotated/Functional/Driver/Common/GeneratorTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/GeneratorTestCase.php @@ -29,16 +29,18 @@ abstract class GeneratorTestCase extends BaseTestCase { + #[\Testo\Test] public function testCreateEntitiesWithNullReader(): void { $r = new Registry($this->dbal); (new Entities(new TokenizerEntityLocator($this->locator)))->run($r); - $this->assertTrue($r->hasEntity(Simple::class)); - $this->assertTrue($r->hasEntity(WithTable::class)); - $this->assertTrue($r->hasEntity(Complete::class)); + \Testo\Assert::true($r->hasEntity(Simple::class)); + \Testo\Assert::true($r->hasEntity(WithTable::class)); + \Testo\Assert::true($r->hasEntity(Complete::class)); } + #[\Testo\Test] public function testCreateGeneratorsWithDoctrineAnnotationReader(): void { $reader = new DoctrineAnnotationReader(); @@ -51,19 +53,20 @@ public function testCreateGeneratorsWithDoctrineAnnotationReader(): void (new SyncTables())->run($r); // Entities - $this->assertTrue($r->hasEntity(Simple::class)); - $this->assertTrue($r->hasEntity(WithTable::class)); - $this->assertTrue($r->hasEntity(Complete::class)); + \Testo\Assert::true($r->hasEntity(Simple::class)); + \Testo\Assert::true($r->hasEntity(WithTable::class)); + \Testo\Assert::true($r->hasEntity(Complete::class)); // MergeColumns $schema = $r->getTableSchema($r->getEntity('withTable')); - $this->assertTrue($schema->hasColumn('name')); - $this->assertSame('string', $schema->column('status')->getType()); + \Testo\Assert::true($schema->hasColumn('name')); + \Testo\Assert::same($schema->column('status')->getType(), 'string'); // MergeIndexes - $this->assertTrue($schema->hasIndex(['name'])); - $this->assertTrue($schema->index(['name'])->isUnique()); - $this->assertSame('name_index', $schema->index(['name'])->getName()); + \Testo\Assert::true($schema->hasIndex(['name'])); + \Testo\Assert::true($schema->index(['name'])->isUnique()); + \Testo\Assert::same($schema->index(['name'])->getName(), 'name_index'); } + #[\Testo\Test] public function testCreateGeneratorsWithCustomMergeReader(): void { $reader = new MergeReader([new AnnotationReader(), new AttributeReader()]); @@ -82,69 +85,69 @@ public function testCreateGeneratorsWithCustomMergeReader(): void (new SyncTables())->run($r); - $this->assertTrue($r->hasTable($r->getEntity('MergedMeta'))); + \Testo\Assert::true($r->hasTable($r->getEntity('MergedMeta'))); $schema = $r->getTableSchema($r->getEntity('MergedMeta')); - $this->assertTrue($schema->hasColumn('name')); - $this->assertTrue($schema->hasIndex(['name', 'id DESC'])); + \Testo\Assert::true($schema->hasColumn('name')); + \Testo\Assert::true($schema->hasIndex(['name', 'id DESC'])); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testLocateAll(ReaderInterface $reader): void { $r = new Registry($this->dbal); (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); - $this->assertTrue($r->hasEntity(Simple::class)); - $this->assertTrue($r->hasEntity(WithTable::class)); - $this->assertTrue($r->hasEntity(Complete::class)); + \Testo\Assert::true($r->hasEntity(Simple::class)); + \Testo\Assert::true($r->hasEntity(WithTable::class)); + \Testo\Assert::true($r->hasEntity(Complete::class)); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testSimpleSchema(ReaderInterface $reader): void { $r = new Registry($this->dbal); (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); - $this->assertTrue($r->hasEntity(Simple::class)); - $this->assertTrue($r->hasEntity('simple')); + \Testo\Assert::true($r->hasEntity(Simple::class)); + \Testo\Assert::true($r->hasEntity('simple')); - $this->assertSame(null, $r->getEntity('simple')->getMapper()); - $this->assertSame(null, $r->getEntity('simple')->getRepository()); + \Testo\Assert::same($r->getEntity('simple')->getMapper(), null); + \Testo\Assert::same($r->getEntity('simple')->getRepository(), null); - $this->assertTrue($r->hasTable($r->getEntity('simple'))); - $this->assertSame('default', $r->getDatabase($r->getEntity('simple'))); - $this->assertSame('simples', $r->getTable($r->getEntity('simple'))); + \Testo\Assert::true($r->hasTable($r->getEntity('simple'))); + \Testo\Assert::same($r->getDatabase($r->getEntity('simple')), 'default'); + \Testo\Assert::same($r->getTable($r->getEntity('simple')), 'simples'); - $this->assertTrue($r->getEntity('simple')->getFields()->has('id')); - $this->assertSame('id', $r->getEntity('simple')->getFields()->get('id')->getColumn()); + \Testo\Assert::true($r->getEntity('simple')->getFields()->has('id')); + \Testo\Assert::same($r->getEntity('simple')->getFields()->get('id')->getColumn(), 'id'); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testCompleteSchema(ReaderInterface $reader): void { $r = new Registry($this->dbal); (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); - $this->assertTrue($r->hasEntity(Complete::class)); - $this->assertTrue($r->hasEntity('eComplete')); + \Testo\Assert::true($r->hasEntity(Complete::class)); + \Testo\Assert::true($r->hasEntity('eComplete')); - $this->assertSame(CompleteMapper::class, $r->getEntity('eComplete')->getMapper()); - $this->assertSame(CompleteRepository::class, $r->getEntity('eComplete')->getRepository()); - $this->assertSame(TestSource::class, $r->getEntity('eComplete')->getSource()); - $this->assertSame(SomeConstrain::class, $r->getEntity('eComplete')->getScope()); + \Testo\Assert::same($r->getEntity('eComplete')->getMapper(), CompleteMapper::class); + \Testo\Assert::same($r->getEntity('eComplete')->getRepository(), CompleteRepository::class); + \Testo\Assert::same($r->getEntity('eComplete')->getSource(), TestSource::class); + \Testo\Assert::same($r->getEntity('eComplete')->getScope(), SomeConstrain::class); - $this->assertTrue($r->hasTable($r->getEntity('eComplete'))); - $this->assertSame('secondary', $r->getDatabase($r->getEntity('eComplete'))); - $this->assertSame('complete_data', $r->getTable($r->getEntity('eComplete'))); + \Testo\Assert::true($r->hasTable($r->getEntity('eComplete'))); + \Testo\Assert::same($r->getDatabase($r->getEntity('eComplete')), 'secondary'); + \Testo\Assert::same($r->getTable($r->getEntity('eComplete')), 'complete_data'); - $this->assertTrue($r->getEntity('eComplete')->getFields()->has('id')); - $this->assertTrue($r->getEntity('eComplete')->getFields()->has('name')); + \Testo\Assert::true($r->getEntity('eComplete')->getFields()->has('id')); + \Testo\Assert::true($r->getEntity('eComplete')->getFields()->has('name')); - $this->assertSame( - 'username', - $r->getEntity('eComplete')->getFields()->get('name')->getColumn(), - ); + \Testo\Assert::same($r->getEntity('eComplete')->getFields()->get('name')->getColumn(), 'username'); - $this->assertFalse($r->getEntity('eComplete')->getFields()->has('ignored')); + \Testo\Assert::false($r->getEntity('eComplete')->getFields()->has('ignored')); } } diff --git a/tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php b/tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php index 831c9c00..30b213f1 100644 --- a/tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php @@ -36,7 +36,8 @@ abstract class JoinedTableTestCase extends BaseTestCase { use TableTrait; - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testTableInheritance(ReaderInterface $reader): void { $this->orm = $this->orm->with(new Schema($this->compile($reader))); @@ -57,16 +58,17 @@ public function testTableInheritance(ReaderInterface $reader): void $this->orm->getHeap()->clean(); $loadedExecutive = $this->orm->getRepository(Executive::class)->findByPK($executive->getFooId()); - $this->assertInstanceOf(Executive::class, $loadedExecutive); - $this->assertSame('executive', $loadedExecutive->getName()); - $this->assertSame(50000, $loadedExecutive->getSalary()); - $this->assertSame('secret', $loadedExecutive->hidden); - $this->assertSame(15000, $loadedExecutive->bonus); - $this->assertSame('executive', $loadedExecutive->getType()); - $this->assertSame('value', $loadedExecutive->proxyFieldWithAnnotation); + \Testo\Assert::instanceOf($loadedExecutive, Executive::class); + \Testo\Assert::same($loadedExecutive->getName(), 'executive'); + \Testo\Assert::same($loadedExecutive->getSalary(), 50000); + \Testo\Assert::same($loadedExecutive->hidden, 'secret'); + \Testo\Assert::same($loadedExecutive->bonus, 15000); + \Testo\Assert::same($loadedExecutive->getType(), 'executive'); + \Testo\Assert::same($loadedExecutive->proxyFieldWithAnnotation, 'value'); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testAddForeignKeys(ReaderInterface $reader): void { $this->orm = $this->orm->with(new Schema($this->compile($reader))); @@ -77,36 +79,38 @@ public function testAddForeignKeys(ReaderInterface $reader): void $externalSuppliersFk = $db->table('external_suppliers')->getForeignKeys(); // simple case. Supplier -> Person - $this->assertCount(1, $suppliersFk); - $this->assertInstanceOf(AbstractForeignKey::class, reset($suppliersFk)); - $this->assertSame('people', reset($suppliersFk)->getForeignTable()); - $this->assertSame(['id'], reset($suppliersFk)->getForeignKeys()); - $this->assertSame(['id'], reset($suppliersFk)->getColumns()); + \Testo\Assert::count($suppliersFk, 1); + \Testo\Assert::instanceOf(reset($suppliersFk), AbstractForeignKey::class); + \Testo\Assert::same(reset($suppliersFk)->getForeignTable(), 'people'); + \Testo\Assert::same(reset($suppliersFk)->getForeignKeys(), ['id']); + \Testo\Assert::same(reset($suppliersFk)->getColumns(), ['id']); // Executive -> Employee (STI) -> Person - $this->assertCount(1, $executivesFk); - $this->assertInstanceOf(AbstractForeignKey::class, reset($executivesFk)); - $this->assertSame('people', reset($executivesFk)->getForeignTable()); - $this->assertSame(['id'], reset($executivesFk)->getForeignKeys()); - $this->assertSame(['id'], reset($executivesFk)->getColumns()); + \Testo\Assert::count($executivesFk, 1); + \Testo\Assert::instanceOf(reset($executivesFk), AbstractForeignKey::class); + \Testo\Assert::same(reset($executivesFk)->getForeignTable(), 'people'); + \Testo\Assert::same(reset($executivesFk)->getForeignKeys(), ['id']); + \Testo\Assert::same(reset($executivesFk)->getColumns(), ['id']); // ExternalSupplier -> Supplier (JTI) -> Person. With outerKey - $this->assertCount(1, $externalSuppliersFk); - $this->assertInstanceOf(AbstractForeignKey::class, reset($externalSuppliersFk)); - $this->assertSame('suppliers', reset($externalSuppliersFk)->getForeignTable()); - $this->assertSame(['custom_id'], reset($externalSuppliersFk)->getForeignKeys()); - $this->assertSame(['id'], reset($externalSuppliersFk)->getColumns()); + \Testo\Assert::count($externalSuppliersFk, 1); + \Testo\Assert::instanceOf(reset($externalSuppliersFk), AbstractForeignKey::class); + \Testo\Assert::same(reset($externalSuppliersFk)->getForeignTable(), 'suppliers'); + \Testo\Assert::same(reset($externalSuppliersFk)->getForeignKeys(), ['custom_id']); + \Testo\Assert::same(reset($externalSuppliersFk)->getColumns(), ['id']); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testNotAddForeignKey(ReaderInterface $reader): void { $this->orm = $this->orm->with(new Schema($this->compile($reader))); - $this->assertCount(0, $this->dbal->database()->table('buyers')->getForeignKeys()); + \Testo\Assert::count($this->dbal->database()->table('buyers')->getForeignKeys(), 0); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testAddIndex(ReaderInterface $reader): void { $this->orm = $this->orm->with(new Schema($this->compile($reader))); @@ -117,32 +121,34 @@ public function testAddIndex(ReaderInterface $reader): void $indexes = array_filter($indexes, fn(AbstractIndex $index) => $index->getColumns() !== ['id']); // one index added automatically, one added manual - $this->assertCount(2, $indexes); + \Testo\Assert::count($indexes, 2); - $this->assertTrue($this->dbal->database()->table('suppliers')->hasIndex(['index_id'])); - $this->assertTrue($this->dbal->database()->table('suppliers')->hasIndex(['custom_id'])); + \Testo\Assert::true($this->dbal->database()->table('suppliers')->hasIndex(['index_id'])); + \Testo\Assert::true($this->dbal->database()->table('suppliers')->hasIndex(['custom_id'])); - $this->assertTrue(reset($indexes)->isUnique()); - $this->assertTrue(end($indexes)->isUnique()); + \Testo\Assert::true(reset($indexes)->isUnique()); + \Testo\Assert::true(end($indexes)->isUnique()); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testJtiParentColumns(ReaderInterface $reader): void { $schema = $this->compile($reader, 'Fixtures21'); - $this->assertNotEmpty($schema); + \Testo\Assert::notBlank($schema); - $this->assertArrayHasKey(SchemaInterface::COLUMNS, $schema['person']); + \Testo\Assert::array($schema['person'])->hasKeys(SchemaInterface::COLUMNS); // assert that parent doesn't have jti columns - $this->assertEquals([ + \Testo\Assert::equals($schema['person'][SchemaInterface::COLUMNS], [ 'id' => 'id', 'name' => 'name', 'type' => 'type', - ], $schema['person'][SchemaInterface::COLUMNS]); + ]); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Annotated/Functional/Driver/Common/Inheritance/SingleTableTestCase.php b/tests/Annotated/Functional/Driver/Common/Inheritance/SingleTableTestCase.php index cde14b95..92081f91 100644 --- a/tests/Annotated/Functional/Driver/Common/Inheritance/SingleTableTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Inheritance/SingleTableTestCase.php @@ -71,7 +71,8 @@ public static function columnDeclarationWithReadersDataProvider(): \Traversable } } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testTableInheritance(ReaderInterface $reader): void { $tokenizer = new Tokenizer( @@ -134,37 +135,38 @@ public function testTableInheritance(ReaderInterface $reader): void $this->orm->getHeap()->clean(); - $this->assertNotNull($person->getFooId()); + \Testo\Assert::notNull($person->getFooId()); $loadedPerson = $this->orm->getRepository(Person::class)->findByPK($person->getFooId()); - $this->assertInstanceOf(Person::class, $loadedPerson); - $this->assertSame('baz', $loadedPerson->name); - $this->assertFalse(isset($loadedPerson->preferences)); - $this->assertFalse(isset($loadedPerson->salary)); + \Testo\Assert::instanceOf($loadedPerson, Person::class); + \Testo\Assert::same($loadedPerson->name, 'baz'); + \Testo\Assert::false(isset($loadedPerson->preferences)); + \Testo\Assert::false(isset($loadedPerson->salary)); - $this->assertNotNull($employee->getFooId()); + \Testo\Assert::notNull($employee->getFooId()); $loadedEmployee = $this->orm->getRepository(Person::class)->findByPK($employee->getFooId()); - $this->assertInstanceOf(Employee::class, $loadedEmployee); - $this->assertSame('foo', $loadedEmployee->name); - $this->assertSame(12500, $loadedEmployee->salary); - $this->assertSame('test', $loadedEmployee->bar); - $this->assertFalse(isset($loadedEmployee->preferences)); + \Testo\Assert::instanceOf($loadedEmployee, Employee::class); + \Testo\Assert::same($loadedEmployee->name, 'foo'); + \Testo\Assert::same($loadedEmployee->salary, 12500); + \Testo\Assert::same($loadedEmployee->bar, 'test'); + \Testo\Assert::false(isset($loadedEmployee->preferences)); - $this->assertNotNull($customer->getFooId()); + \Testo\Assert::notNull($customer->getFooId()); $loadedCustomer = $this->orm->getRepository(Person::class)->findByPK($customer->getFooId()); - $this->assertInstanceOf(Customer::class, $loadedCustomer); - $this->assertSame('baz', $loadedCustomer->name); - $this->assertSame('private', $loadedCustomer->preferences); - $this->assertFalse(isset($loadedCustomer->salary)); + \Testo\Assert::instanceOf($loadedCustomer, Customer::class); + \Testo\Assert::same($loadedCustomer->name, 'baz'); + \Testo\Assert::same($loadedCustomer->preferences, 'private'); + \Testo\Assert::false(isset($loadedCustomer->salary)); - $this->assertNotNull($ceo->getFooId()); + \Testo\Assert::notNull($ceo->getFooId()); $loadedCeo = $this->orm->getRepository(Ceo::class)->findByPK($ceo->getFooId()); - $this->assertInstanceOf(Ceo::class, $loadedCeo); - $this->assertSame('ceo', $loadedCeo->name); - $this->assertSame(150000, $loadedCeo->salary); - $this->assertSame(1000, $loadedCeo->stocks); + \Testo\Assert::instanceOf($loadedCeo, Ceo::class); + \Testo\Assert::same($loadedCeo->name, 'ceo'); + \Testo\Assert::same($loadedCeo->salary, 150000); + \Testo\Assert::same($loadedCeo->stocks, 1000); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testTableInheritanceSchema(ReaderInterface $reader): void { $tokenizer = new Tokenizer( @@ -191,17 +193,18 @@ public function testTableInheritanceSchema(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertNotEmpty($schema); + \Testo\Assert::notBlank($schema); - $this->assertArrayHasKey(SchemaInterface::CHILDREN, $schema['person']); - $this->assertArrayHasKey(SchemaInterface::DISCRIMINATOR, $schema['person']); - $this->assertSame('type', $schema['person'][SchemaInterface::DISCRIMINATOR]); + \Testo\Assert::array($schema['person'])->hasKeys(SchemaInterface::CHILDREN); + \Testo\Assert::array($schema['person'])->hasKeys(SchemaInterface::DISCRIMINATOR); + \Testo\Assert::same($schema['person'][SchemaInterface::DISCRIMINATOR], 'type'); - $this->assertArrayHasKey(SchemaInterface::PARENT, $schema['buyer']); - $this->assertArrayHasKey(SchemaInterface::PARENT_KEY, $schema['buyer']); + \Testo\Assert::array($schema['buyer'])->hasKeys(SchemaInterface::PARENT); + \Testo\Assert::array($schema['buyer'])->hasKeys(SchemaInterface::PARENT_KEY); } - #[DataProvider('columnDeclarationWithReadersDataProvider')] + #[\Testo\Data\DataProvider('columnDeclarationWithReadersDataProvider')] + #[\Testo\Test] public function testSingleTableInheritanceWithDifferentColumnDeclaration( string $directory, string $namespace, @@ -231,117 +234,87 @@ public function testSingleTableInheritanceWithDifferentColumnDeclaration( new GenerateTypecast(), ]); - $this->assertNotEmpty($schema); - $this->assertSame(\sprintf( + \Testo\Assert::notBlank($schema); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::ENTITY], \sprintf( 'Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\BaseEvent', $namespace, - ), $schema['baseEvent'][SchemaInterface::ENTITY]); - $this->assertSame(Mapper::class, $schema['baseEvent'][SchemaInterface::MAPPER]); - $this->assertSame(Source::class, $schema['baseEvent'][SchemaInterface::SOURCE]); - $this->assertSame(Repository::class, $schema['baseEvent'][SchemaInterface::REPOSITORY]); - $this->assertSame('default', $schema['baseEvent'][SchemaInterface::DATABASE]); - $this->assertSame('base_events', $schema['baseEvent'][SchemaInterface::TABLE]); - $this->assertSame(['id'], $schema['baseEvent'][SchemaInterface::PRIMARY_KEY]); - $this->assertSame(['id'], $schema['baseEvent'][SchemaInterface::FIND_BY_KEYS]); - $this->assertCount(4, $schema['baseEvent'][SchemaInterface::COLUMNS]); - $this->assertSame('id', $schema['baseEvent'][SchemaInterface::COLUMNS]['id']); - $this->assertSame('action', $schema['baseEvent'][SchemaInterface::COLUMNS]['action']); - $this->assertSame('object_id', $schema['baseEvent'][SchemaInterface::COLUMNS]['object_id']); - $this->assertSame('object_type', $schema['baseEvent'][SchemaInterface::COLUMNS]['object_type']); - $this->assertSame( - Relation::BELONGS_TO_MORPHED, - $schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::TYPE], - ); - $this->assertSame( - \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\EventEmitterInterface', $namespace), - $schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::TARGET], - ); - $this->assertSame( - Relation::LOAD_PROMISE, - $schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::LOAD], - ); - $this->assertTrue( - $schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::CASCADE], - ); - $this->assertTrue( - $schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::NULLABLE], - ); - $this->assertSame( - ['id'], - $schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::OUTER_KEY], - ); - $this->assertSame( - 'object_id', - $schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::INNER_KEY], - ); - $this->assertSame( - 'object_type', - $schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::MORPH_KEY], - ); - $this->assertCount(2, $schema['baseEvent'][SchemaInterface::CHILDREN]); - $this->assertSame( - \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentCreated', $namespace), - $schema['baseEvent'][SchemaInterface::CHILDREN]['comment.created'], - ); - $this->assertSame( - \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentUpdated', $namespace), - $schema['baseEvent'][SchemaInterface::CHILDREN]['comment.updated'], - ); - $this->assertNull($schema['baseEvent'][SchemaInterface::SCOPE]); - $this->assertSame('int', $schema['baseEvent'][SchemaInterface::TYPECAST]['id']); - $this->assertSame('int', $schema['baseEvent'][SchemaInterface::TYPECAST]['object_id']); - $this->assertSame([], $schema['baseEvent'][SchemaInterface::SCHEMA]); - $this->assertSame('action', $schema['baseEvent'][SchemaInterface::DISCRIMINATOR]); - $this->assertNull($schema['baseEvent'][SchemaInterface::TYPECAST_HANDLER]); - $this->assertSame( - [ - SchemaInterface::ENTITY => \sprintf( - 'Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\Comment', - $namespace, - ), - SchemaInterface::MAPPER => Mapper::class, - SchemaInterface::SOURCE => Source::class, - SchemaInterface::REPOSITORY => Repository::class, - SchemaInterface::DATABASE => 'default', - SchemaInterface::TABLE => 'comments', - SchemaInterface::PRIMARY_KEY => [ - 'id', - ], - SchemaInterface::FIND_BY_KEYS => [ - 'id', - ], - SchemaInterface::COLUMNS => [ - 'id' => 'id', - 'body' => 'body', - ], - SchemaInterface::RELATIONS => [], - SchemaInterface::SCOPE => null, - SchemaInterface::TYPECAST => [ - 'id' => 'int', - 'body' => 'string', - ], - SchemaInterface::SCHEMA => [], - SchemaInterface::TYPECAST_HANDLER => null, - SchemaInterface::GENERATED_FIELDS => [ - 'id' => GeneratedField::ON_INSERT, - ], + )); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::MAPPER], Mapper::class); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::SOURCE], Source::class); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::REPOSITORY], Repository::class); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::DATABASE], 'default'); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::TABLE], 'base_events'); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::PRIMARY_KEY], ['id']); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::FIND_BY_KEYS], ['id']); + \Testo\Assert::count($schema['baseEvent'][SchemaInterface::COLUMNS], 4); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['id'], 'id'); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['action'], 'action'); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['object_id'], 'object_id'); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['object_type'], 'object_type'); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::TYPE], Relation::BELONGS_TO_MORPHED); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::TARGET], \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\EventEmitterInterface', $namespace)); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::LOAD], Relation::LOAD_PROMISE); + \Testo\Assert::true($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::CASCADE]); + \Testo\Assert::true($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::NULLABLE]); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::OUTER_KEY], ['id']); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::INNER_KEY], 'object_id'); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::MORPH_KEY], 'object_type'); + \Testo\Assert::count($schema['baseEvent'][SchemaInterface::CHILDREN], 2); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::CHILDREN]['comment.created'], \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentCreated', $namespace)); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::CHILDREN]['comment.updated'], \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentUpdated', $namespace)); + \Testo\Assert::null($schema['baseEvent'][SchemaInterface::SCOPE]); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::TYPECAST]['id'], 'int'); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::TYPECAST]['object_id'], 'int'); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::SCHEMA], []); + \Testo\Assert::same($schema['baseEvent'][SchemaInterface::DISCRIMINATOR], 'action'); + \Testo\Assert::null($schema['baseEvent'][SchemaInterface::TYPECAST_HANDLER]); + \Testo\Assert::same($schema['comment'], [ + SchemaInterface::ENTITY => \sprintf( + 'Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\Comment', + $namespace, + ), + SchemaInterface::MAPPER => Mapper::class, + SchemaInterface::SOURCE => Source::class, + SchemaInterface::REPOSITORY => Repository::class, + SchemaInterface::DATABASE => 'default', + SchemaInterface::TABLE => 'comments', + SchemaInterface::PRIMARY_KEY => [ + 'id', ], - $schema['comment'], - ); - $this->assertSame([ + SchemaInterface::FIND_BY_KEYS => [ + 'id', + ], + SchemaInterface::COLUMNS => [ + 'id' => 'id', + 'body' => 'body', + ], + SchemaInterface::RELATIONS => [], + SchemaInterface::SCOPE => null, + SchemaInterface::TYPECAST => [ + 'id' => 'int', + 'body' => 'string', + ], + SchemaInterface::SCHEMA => [], + SchemaInterface::TYPECAST_HANDLER => null, + SchemaInterface::GENERATED_FIELDS => [ + 'id' => GeneratedField::ON_INSERT, + ], + ]); + \Testo\Assert::same($schema['commentCreated'], [ SchemaInterface::ENTITY => \sprintf( 'Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentCreated', $namespace, ), - ], $schema['commentCreated']); - $this->assertSame([ + ]); + \Testo\Assert::same($schema['commentUpdated'], [ SchemaInterface::ENTITY => \sprintf( 'Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentUpdated', $namespace, ), - ], $schema['commentUpdated']); + ]); } + #[\Testo\Lifecycle\BeforeTest] public function setUp(): void { parent::setUp(); diff --git a/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php b/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php index 27889034..066df6a8 100644 --- a/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php @@ -52,7 +52,8 @@ abstract class InheritanceTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testTableInheritance(ReaderInterface $reader): void { $tokenizer = new Tokenizer( @@ -88,17 +89,17 @@ public function testTableInheritance(ReaderInterface $reader): void // Beaver - Separate table // Tool - $this->assertArrayHasKey('tool', $schema); + \Testo\Assert::array($schema)->hasKeys('tool'); // Person - $this->assertCount(3, $schema['person'][SchemaInterface::CHILDREN]); - $this->assertEquals([ + \Testo\Assert::count($schema['person'][SchemaInterface::CHILDREN], 3); + \Testo\Assert::equals($schema['person'][SchemaInterface::CHILDREN], [ 'employee' => Employee::class, 'foo_customer' => Customer::class, 'ceo' => Ceo::class, - ], $schema['person'][SchemaInterface::CHILDREN]); - $this->assertSame('type', $schema['person'][SchemaInterface::DISCRIMINATOR]); - $this->assertEquals([ + ]); + \Testo\Assert::same($schema['person'][SchemaInterface::DISCRIMINATOR], 'type'); + \Testo\Assert::equals($schema['person'][SchemaInterface::COLUMNS], [ 'foo_id' => 'id', 'name' => 'name', 'type' => 'type', @@ -109,72 +110,70 @@ public function testTableInheritance(ReaderInterface $reader): void 'stocks' => 'stocks', 'tool_id' => 'tool_id', // 'teethAmount' => 'teeth_amount', // Not child - ], $schema['person'][SchemaInterface::COLUMNS]); + ]); $this->assertEmpty($schema['person'][SchemaInterface::PARENT] ?? null); $this->assertEmpty($schema['person'][SchemaInterface::PARENT_KEY] ?? null); - $this->assertSame('people', $schema['person'][SchemaInterface::TABLE]); - $this->assertCount(1, $schema['person'][SchemaInterface::RELATIONS]); + \Testo\Assert::same($schema['person'][SchemaInterface::TABLE], 'people'); + \Testo\Assert::count($schema['person'][SchemaInterface::RELATIONS], 1); // Employee - $this->assertArrayHasKey('employee', $schema); - $this->assertCount(1, $schema['employee']); - $this->assertSame(Employee::class, $schema['employee'][SchemaInterface::ENTITY]); - $this->assertNull($schema['employee'][SchemaInterface::TABLE] ?? null); - $this->assertCount(0, $schema['employee'][SchemaInterface::RELATIONS] ?? []); + \Testo\Assert::array($schema)->hasKeys('employee'); + \Testo\Assert::count($schema['employee'], 1); + \Testo\Assert::same($schema['employee'][SchemaInterface::ENTITY], Employee::class); + \Testo\Assert::null($schema['employee'][SchemaInterface::TABLE] ?? null); + \Testo\Assert::count($schema['employee'][SchemaInterface::RELATIONS] ?? [], 0); // Customer - $this->assertArrayHasKey('customer', $schema); - $this->assertCount(1, $schema['customer']); - $this->assertSame(Customer::class, $schema['customer'][SchemaInterface::ENTITY]); - $this->assertNull($schema['customer'][SchemaInterface::TABLE] ?? null); - $this->assertCount(0, $schema['customer'][SchemaInterface::RELATIONS] ?? []); + \Testo\Assert::array($schema)->hasKeys('customer'); + \Testo\Assert::count($schema['customer'], 1); + \Testo\Assert::same($schema['customer'][SchemaInterface::ENTITY], Customer::class); + \Testo\Assert::null($schema['customer'][SchemaInterface::TABLE] ?? null); + \Testo\Assert::count($schema['customer'][SchemaInterface::RELATIONS] ?? [], 0); // Executive - $this->assertSame('employee', $schema['executive'][SchemaInterface::PARENT]); - $this->assertSame('foo_id', $schema['executive'][SchemaInterface::PARENT_KEY]); - $this->assertSame('executives', $schema['executive'][SchemaInterface::TABLE]); - $this->assertEquals( - [ - 'bonus' => 'bonus', - 'proxyFieldWithAnnotation' => 'proxy', - 'foo_id' => 'id', - 'hidden' => 'hidden', - 'added_tool_id' => 'added_tool_id', - ], - $schema['executive'][SchemaInterface::COLUMNS], - ); - $this->assertCount(1, $schema['executive'][SchemaInterface::RELATIONS]); + \Testo\Assert::same($schema['executive'][SchemaInterface::PARENT], 'employee'); + \Testo\Assert::same($schema['executive'][SchemaInterface::PARENT_KEY], 'foo_id'); + \Testo\Assert::same($schema['executive'][SchemaInterface::TABLE], 'executives'); + \Testo\Assert::equals($schema['executive'][SchemaInterface::COLUMNS], [ + 'bonus' => 'bonus', + 'proxyFieldWithAnnotation' => 'proxy', + 'foo_id' => 'id', + 'hidden' => 'hidden', + 'added_tool_id' => 'added_tool_id', + ]); + \Testo\Assert::count($schema['executive'][SchemaInterface::RELATIONS], 1); // Executive2 - $this->assertSame('executive', $schema['executive2'][SchemaInterface::PARENT]); - $this->assertSame('foo_id', $schema['executive2'][SchemaInterface::PARENT_KEY]); - $this->assertEquals(['foo_id' => 'id'], $schema['executive2'][SchemaInterface::COLUMNS]); - $this->assertCount(0, $schema['executive2'][SchemaInterface::RELATIONS]); + \Testo\Assert::same($schema['executive2'][SchemaInterface::PARENT], 'executive'); + \Testo\Assert::same($schema['executive2'][SchemaInterface::PARENT_KEY], 'foo_id'); + \Testo\Assert::equals($schema['executive2'][SchemaInterface::COLUMNS], ['foo_id' => 'id']); + \Testo\Assert::count($schema['executive2'][SchemaInterface::RELATIONS], 0); // Ceo - $this->assertArrayHasKey('ceo', $schema); - $this->assertCount(1, $schema['ceo']); - $this->assertSame(Ceo::class, $schema['ceo'][SchemaInterface::ENTITY]); - $this->assertNull($schema['ceo'][SchemaInterface::TABLE] ?? null); - $this->assertCount(0, $schema['ceo'][SchemaInterface::RELATIONS] ?? []); + \Testo\Assert::array($schema)->hasKeys('ceo'); + \Testo\Assert::count($schema['ceo'], 1); + \Testo\Assert::same($schema['ceo'][SchemaInterface::ENTITY], Ceo::class); + \Testo\Assert::null($schema['ceo'][SchemaInterface::TABLE] ?? null); + \Testo\Assert::count($schema['ceo'][SchemaInterface::RELATIONS] ?? [], 0); // Beaver $this->assertEmpty($schema['beaver'][SchemaInterface::DISCRIMINATOR] ?? null); $this->assertEmpty($schema['beaver'][SchemaInterface::PARENT] ?? null); $this->assertEmpty($schema['beaver'][SchemaInterface::PARENT_KEY] ?? null); $this->assertEmpty($schema['beaver'][SchemaInterface::CHILDREN] ?? null); - $this->assertSame('beavers', $schema['beaver'][SchemaInterface::TABLE]); - $this->assertEquals([ + \Testo\Assert::same($schema['beaver'][SchemaInterface::TABLE], 'beavers'); + \Testo\Assert::equals($schema['beaver'][SchemaInterface::COLUMNS], [ 'teethAmount' => 'teeth_amount', 'foo_id' => 'id', 'name' => 'name', 'type' => 'type', 'hidden' => 'hidden', 'tool_id' => 'tool_id', - ], $schema['beaver'][SchemaInterface::COLUMNS]); - $this->assertCount(1, $schema['beaver'][SchemaInterface::RELATIONS] ?? []); + ]); + \Testo\Assert::count($schema['beaver'][SchemaInterface::RELATIONS] ?? [], 1); } + #[\Testo\Test] public function testTableInheritanceWithIncorrectClassesOrder(): void { $r = new Registry($this->dbal); @@ -203,34 +202,37 @@ public function testTableInheritanceWithIncorrectClassesOrder(): void new GenerateTypecast(), ]); - $this->assertSame('executives', $schema['executive'][SchemaInterface::TABLE]); - $this->assertNull($schema['employee'][SchemaInterface::TABLE] ?? null); - $this->assertSame('people', $schema['person'][SchemaInterface::TABLE]); + \Testo\Assert::same($schema['executive'][SchemaInterface::TABLE], 'executives'); + \Testo\Assert::null($schema['employee'][SchemaInterface::TABLE] ?? null); + \Testo\Assert::same($schema['person'][SchemaInterface::TABLE], 'people'); } + #[\Testo\Test] public function testJtiChildDoesNotInheritBelongsToColumn(): void { $schema = $this->compileWithClasses([BtTarget::class, BtParent::class, BtJoined::class]); // BtParent owns the BelongsTo + its FK column - $this->assertArrayHasKey('target_id', $schema['btParent'][SchemaInterface::COLUMNS]); - $this->assertCount(1, $schema['btParent'][SchemaInterface::RELATIONS]); + \Testo\Assert::array($schema['btParent'][SchemaInterface::COLUMNS])->hasKeys('target_id'); + \Testo\Assert::count($schema['btParent'][SchemaInterface::RELATIONS], 1); // JTI child must not duplicate the BelongsTo FK column nor inherit the relation - $this->assertArrayNotHasKey('target_id', $schema['btJoined'][SchemaInterface::COLUMNS]); - $this->assertCount(0, $schema['btJoined'][SchemaInterface::RELATIONS] ?? []); + \Testo\Assert::array($schema['btJoined'][SchemaInterface::COLUMNS])->doesNotHaveKeys('target_id'); + \Testo\Assert::count($schema['btJoined'][SchemaInterface::RELATIONS] ?? [], 0); } + #[\Testo\Test] public function testStiChildOwnRelationMergesIntoParent(): void { $schema = $this->compileWithClasses([StTarget::class, StParent::class, StChild::class]); // Relation declared on the STI child must end up on the parent after merge - $this->assertArrayHasKey('target_id', $schema['stParent'][SchemaInterface::COLUMNS]); - $this->assertCount(1, $schema['stParent'][SchemaInterface::RELATIONS]); - $this->assertArrayHasKey('target', $schema['stParent'][SchemaInterface::RELATIONS]); + \Testo\Assert::array($schema['stParent'][SchemaInterface::COLUMNS])->hasKeys('target_id'); + \Testo\Assert::count($schema['stParent'][SchemaInterface::RELATIONS], 1); + \Testo\Assert::array($schema['stParent'][SchemaInterface::RELATIONS])->hasKeys('target'); } + #[\Testo\Test] public function testSeparateEntityExtendingStiChildKeepsInheritedRelation(): void { $schema = $this->compileWithClasses([ @@ -242,26 +244,28 @@ public function testSeparateEntityExtendingStiChildKeepsInheritedRelation(): voi // Separate entity (no Inheritance attr) extending an STI child must keep ancestor relations $this->assertEmpty($schema['soSeparate'][SchemaInterface::PARENT] ?? null); - $this->assertNotNull($schema['soSeparate'][SchemaInterface::TABLE] ?? null); - $this->assertArrayHasKey('target_id', $schema['soSeparate'][SchemaInterface::COLUMNS]); - $this->assertArrayHasKey('extra', $schema['soSeparate'][SchemaInterface::COLUMNS]); - $this->assertCount(1, $schema['soSeparate'][SchemaInterface::RELATIONS] ?? []); - $this->assertArrayHasKey('target', $schema['soSeparate'][SchemaInterface::RELATIONS]); + \Testo\Assert::notNull($schema['soSeparate'][SchemaInterface::TABLE] ?? null); + \Testo\Assert::array($schema['soSeparate'][SchemaInterface::COLUMNS])->hasKeys('target_id'); + \Testo\Assert::array($schema['soSeparate'][SchemaInterface::COLUMNS])->hasKeys('extra'); + \Testo\Assert::count($schema['soSeparate'][SchemaInterface::RELATIONS] ?? [], 1); + \Testo\Assert::array($schema['soSeparate'][SchemaInterface::RELATIONS])->hasKeys('target'); } + #[\Testo\Test] public function testJtiChildDoesNotInheritRelationFromTrait(): void { $schema = $this->compileWithClasses([TrTarget::class, TrParent::class, TrJti::class]); // Trait-declared relation belongs to the entity that uses the trait - $this->assertArrayHasKey('target_id', $schema['trParent'][SchemaInterface::COLUMNS]); - $this->assertCount(1, $schema['trParent'][SchemaInterface::RELATIONS]); + \Testo\Assert::array($schema['trParent'][SchemaInterface::COLUMNS])->hasKeys('target_id'); + \Testo\Assert::count($schema['trParent'][SchemaInterface::RELATIONS], 1); // JTI child must not duplicate the trait's relation columns - $this->assertArrayNotHasKey('target_id', $schema['trJti'][SchemaInterface::COLUMNS]); - $this->assertCount(0, $schema['trJti'][SchemaInterface::RELATIONS] ?? []); + \Testo\Assert::array($schema['trJti'][SchemaInterface::COLUMNS])->doesNotHaveKeys('target_id'); + \Testo\Assert::count($schema['trJti'][SchemaInterface::RELATIONS] ?? [], 0); } + #[\Testo\Test] public function testJtiGrandchildDoesNotInheritMidLevelRelation(): void { $schema = $this->compileWithClasses([ @@ -272,12 +276,12 @@ public function testJtiGrandchildDoesNotInheritMidLevelRelation(): void ]); // Relation declared on the JTI middle entity stays on the middle table - $this->assertArrayHasKey('target_id', $schema['jgMid'][SchemaInterface::COLUMNS]); - $this->assertCount(1, $schema['jgMid'][SchemaInterface::RELATIONS]); + \Testo\Assert::array($schema['jgMid'][SchemaInterface::COLUMNS])->hasKeys('target_id'); + \Testo\Assert::count($schema['jgMid'][SchemaInterface::RELATIONS], 1); // JTI grandchild must not duplicate the middle entity's relation column - $this->assertArrayNotHasKey('target_id', $schema['jgLeaf'][SchemaInterface::COLUMNS]); - $this->assertCount(0, $schema['jgLeaf'][SchemaInterface::RELATIONS] ?? []); + \Testo\Assert::array($schema['jgLeaf'][SchemaInterface::COLUMNS])->doesNotHaveKeys('target_id'); + \Testo\Assert::count($schema['jgLeaf'][SchemaInterface::RELATIONS] ?? [], 0); } /** diff --git a/tests/Annotated/Functional/Driver/Common/InvalidTestCase.php b/tests/Annotated/Functional/Driver/Common/InvalidTestCase.php index a9d0c31b..3a108dbd 100644 --- a/tests/Annotated/Functional/Driver/Common/InvalidTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/InvalidTestCase.php @@ -27,7 +27,8 @@ abstract class InvalidTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testInvalidRelation(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -39,7 +40,7 @@ public function testInvalidRelation(ReaderInterface $reader): void $r = new Registry($this->dbal); - $this->expectException(RelationException::class); + \Testo\Expect::exception(RelationException::class); (new Compiler())->compile($r, [ new Entities(new TokenizerEntityLocator($locator, $reader), $reader), @@ -55,15 +56,15 @@ public function testInvalidRelation(ReaderInterface $reader): void ]); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testNotDefinedColumnTypeShouldThrowAnException(ReaderInterface $reader): void { $message = $reader instanceof AnnotationReader ? 'Too few arguments to function Cycle\Annotated\Annotation\Column::__construct(), 0 passed' : 'Some of required arguments [`type`] is missed on `Cycle\Annotated\Tests\Fixtures\Fixtures4\User.id.`'; - $this->expectException(AnnotationException::class); - $this->expectExceptionMessage($message); + \Testo\Expect::exception(AnnotationException::class)->withMessageContaining($message); $tokenizer = new Tokenizer(new TokenizerConfig([ 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures4'], diff --git a/tests/Annotated/Functional/Driver/Common/Relation/BelongsToTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/BelongsToTestCase.php index 3d2ce88a..c7f2ddb0 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/BelongsToTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/BelongsToTestCase.php @@ -24,7 +24,8 @@ abstract class BelongsToTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -41,8 +42,8 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('parent', $schema['eComplete'][Schema::RELATIONS]); - $this->assertSame(Relation::BELONGS_TO, $schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TYPE]); - $this->assertSame('simple', $schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TARGET]); + \Testo\Assert::array($schema['eComplete'][Schema::RELATIONS])->hasKeys('parent'); + \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::BELONGS_TO); + \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TARGET], 'simple'); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/CompositeKeysTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/CompositeKeysTestCase.php index 4990106d..0fad1a78 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/CompositeKeysTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/CompositeKeysTestCase.php @@ -26,7 +26,8 @@ abstract class CompositeKeysTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelationToChild(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -51,6 +52,6 @@ public function testRelationToChild(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertTrue(true, 'No exceptions thrown.'); + \Testo\Assert::true(true, 'No exceptions thrown.'); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/EmbeddedTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/EmbeddedTestCase.php index 2233756a..d1d630ac 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/EmbeddedTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/EmbeddedTestCase.php @@ -29,7 +29,8 @@ abstract class EmbeddedTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelation(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -54,15 +55,16 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('address', $schema['user'][Schema::RELATIONS]); - $this->assertSame(Relation::EMBEDDED, $schema['user'][Schema::RELATIONS]['address'][Relation::TYPE]); + \Testo\Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('address'); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TYPE], Relation::EMBEDDED); - $this->assertSame('user:address:address', $schema['user'][Schema::RELATIONS]['address'][Relation::TARGET]); - $this->assertSame(Relation::LOAD_EAGER, $schema['user'][Schema::RELATIONS]['address'][Relation::LOAD]); - $this->assertTrue($r->getTableSchema($r->getEntity('user'))->hasIndex(['address_zipcode'])); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TARGET], 'user:address:address'); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::LOAD], Relation::LOAD_EAGER); + \Testo\Assert::true($r->getTableSchema($r->getEntity('user'))->hasIndex(['address_zipcode'])); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelationLazyLoad(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -87,15 +89,16 @@ public function testRelationLazyLoad(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('address', $schema['user'][Schema::RELATIONS]); - $this->assertSame(Relation::EMBEDDED, $schema['user'][Schema::RELATIONS]['address'][Relation::TYPE]); + \Testo\Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('address'); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TYPE], Relation::EMBEDDED); - $this->assertSame('user:address:address', $schema['user'][Schema::RELATIONS]['address'][Relation::TARGET]); - $this->assertSame(Relation::LOAD_PROMISE, $schema['user'][Schema::RELATIONS]['address'][Relation::LOAD]); - $this->assertTrue($r->getTableSchema($r->getEntity('user:address:address'))->hasIndex(['address_zipcode'])); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TARGET], 'user:address:address'); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::LOAD], Relation::LOAD_PROMISE); + \Testo\Assert::true($r->getTableSchema($r->getEntity('user:address:address'))->hasIndex(['address_zipcode'])); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testEmbeddedPrefix(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -135,11 +138,12 @@ public function testEmbeddedPrefix(ReaderInterface $reader): void 'id' => 'id', ]; - $this->assertSame($address, $schema['user:address:address'][Schema::COLUMNS]); - $this->assertSame($workAddress, $schema['user:address:workAddress'][Schema::COLUMNS]); + \Testo\Assert::same($schema['user:address:address'][Schema::COLUMNS], $address); + \Testo\Assert::same($schema['user:address:workAddress'][Schema::COLUMNS], $workAddress); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testEmbeddedTypecast(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -164,6 +168,6 @@ public function testEmbeddedTypecast(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertSame(CityTypecast::class, $schema['user:address:address'][Schema::TYPECAST_HANDLER][0]); + \Testo\Assert::same($schema['user:address:address'][Schema::TYPECAST_HANDLER][0], CityTypecast::class); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/HasManyTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/HasManyTestCase.php index c4db451b..e86fb354 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/HasManyTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/HasManyTestCase.php @@ -28,7 +28,8 @@ abstract class HasManyTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -48,23 +49,15 @@ public function testRelation(ReaderInterface $reader): void ], ); - $this->assertArrayHasKey('many', $schema['simple'][Schema::RELATIONS]); - $this->assertSame(Relation::HAS_MANY, $schema['simple'][Schema::RELATIONS]['many'][Relation::TYPE]); - $this->assertSame('withTable', $schema['simple'][Schema::RELATIONS]['many'][Relation::TARGET]); - $this->assertSame( - ['id' => ['>=' => 1]], - $schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::WHERE], - ); - $this->assertSame( - ['id' => 'DESC'], - $schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::ORDER_BY], - ); - $this->assertSame( - 'bar', - $schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::COLLECTION_TYPE], - ); + \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('many'); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::TYPE], Relation::HAS_MANY); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::TARGET], 'withTable'); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::WHERE], ['id' => ['>=' => 1]]); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::ORDER_BY], ['id' => 'DESC']); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::COLLECTION_TYPE], 'bar'); } + #[\Testo\Test] public function testInnerOuterKeys(): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -101,17 +94,9 @@ public function testInnerOuterKeys(): void foreach ($checks as [$name, $innerKey, $outerKey]) { $relation = $schema['booking_reservation'][SchemaInterface::RELATIONS][$name]; - $this->assertSame(Relation::HAS_MANY, $relation[Relation::TYPE], "$name: relation type"); - $this->assertSame( - (array) $innerKey, - (array) $relation[Relation::SCHEMA][Relation::INNER_KEY], - "$name: Inner Key", - ); - $this->assertSame( - (array) $outerKey, - (array) $relation[Relation::SCHEMA][Relation::OUTER_KEY], - "$name: Outer Key", - ); + \Testo\Assert::same($relation[Relation::TYPE], Relation::HAS_MANY, "$name: relation type"); + \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::INNER_KEY], (array) $innerKey, "$name: Inner Key"); + \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::OUTER_KEY], (array) $outerKey, "$name: Outer Key"); } } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/HasOneTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/HasOneTestCase.php index 430d5db6..f2100e4f 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/HasOneTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/HasOneTestCase.php @@ -27,7 +27,8 @@ abstract class HasOneTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -44,12 +45,13 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('one', $schema['simple'][SchemaInterface::RELATIONS]); - $this->assertSame(Relation::HAS_ONE, $schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::TYPE]); - $this->assertSame('eComplete', $schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::TARGET]); - $this->assertSame(Relation::LOAD_PROMISE, $schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::LOAD]); + \Testo\Assert::array($schema['simple'][SchemaInterface::RELATIONS])->hasKeys('one'); + \Testo\Assert::same($schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::TYPE], Relation::HAS_ONE); + \Testo\Assert::same($schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::TARGET], 'eComplete'); + \Testo\Assert::same($schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::LOAD], Relation::LOAD_PROMISE); } + #[\Testo\Test] public function testInnerOuterKeys(): void { $tokenizer = new Tokenizer( @@ -89,21 +91,10 @@ public function testInnerOuterKeys(): void foreach ($checks as [$name, $innerKey, $outerKey]) { $relation = $schema['booking'][SchemaInterface::RELATIONS][$name]; - $this->assertSame(Relation::HAS_ONE, $relation[Relation::TYPE], "$name: relation type"); - $this->assertSame( - (array) $innerKey, - (array) $relation[Relation::SCHEMA][Relation::INNER_KEY], - "$name: Inner Key", - ); - $this->assertSame( - (array) $outerKey, - (array) $relation[Relation::SCHEMA][Relation::OUTER_KEY], - "$name: Outer Key", - ); + \Testo\Assert::same($relation[Relation::TYPE], Relation::HAS_ONE, "$name: relation type"); + \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::INNER_KEY], (array) $innerKey, "$name: Inner Key"); + \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::OUTER_KEY], (array) $outerKey, "$name: Outer Key"); } - $this->assertArrayNotHasKey( - 'id_reservation', - $schema['booking'][SchemaInterface::COLUMNS], - ); + \Testo\Assert::array($schema['booking'][SchemaInterface::COLUMNS])->doesNotHaveKeys('id_reservation'); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/InverseTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/InverseTestCase.php index 95221068..7f3640f0 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/InverseTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/InverseTestCase.php @@ -28,7 +28,8 @@ abstract class InverseTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testBelongsToOne(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -53,16 +54,17 @@ public function testBelongsToOne(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('parent', $schema['eComplete'][Schema::RELATIONS]); - $this->assertSame(Relation::BELONGS_TO, $schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TYPE]); - $this->assertSame('simple', $schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TARGET]); + \Testo\Assert::array($schema['eComplete'][Schema::RELATIONS])->hasKeys('parent'); + \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::BELONGS_TO); + \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TARGET], 'simple'); - $this->assertArrayHasKey('child', $schema['simple'][Schema::RELATIONS]); - $this->assertSame(Relation::HAS_ONE, $schema['simple'][Schema::RELATIONS]['child'][Relation::TYPE]); - $this->assertSame('eComplete', $schema['simple'][Schema::RELATIONS]['child'][Relation::TARGET]); + \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('child'); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['child'][Relation::TYPE], Relation::HAS_ONE); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['child'][Relation::TARGET], 'eComplete'); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testBelongsToMany(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -87,16 +89,17 @@ public function testBelongsToMany(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('uncles', $schema['eComplete'][Schema::RELATIONS]); - $this->assertSame(Relation::BELONGS_TO, $schema['eComplete'][Schema::RELATIONS]['uncles'][Relation::TYPE]); - $this->assertSame('simple', $schema['eComplete'][Schema::RELATIONS]['uncles'][Relation::TARGET]); + \Testo\Assert::array($schema['eComplete'][Schema::RELATIONS])->hasKeys('uncles'); + \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['uncles'][Relation::TYPE], Relation::BELONGS_TO); + \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['uncles'][Relation::TARGET], 'simple'); - $this->assertArrayHasKey('stepKids', $schema['simple'][Schema::RELATIONS]); - $this->assertSame(Relation::HAS_MANY, $schema['simple'][Schema::RELATIONS]['stepKids'][Relation::TYPE]); - $this->assertSame('eComplete', $schema['simple'][Schema::RELATIONS]['stepKids'][Relation::TARGET]); + \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('stepKids'); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['stepKids'][Relation::TYPE], Relation::HAS_MANY); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['stepKids'][Relation::TARGET], 'eComplete'); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testHasOne(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -121,16 +124,17 @@ public function testHasOne(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('simple', $schema['user'][Schema::RELATIONS]); - $this->assertSame(Relation::HAS_ONE, $schema['user'][Schema::RELATIONS]['simple'][Relation::TYPE]); - $this->assertSame('simple', $schema['user'][Schema::RELATIONS]['simple'][Relation::TARGET]); + \Testo\Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('simple'); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TYPE], Relation::HAS_ONE); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TARGET], 'simple'); - $this->assertArrayHasKey('user', $schema['simple'][Schema::RELATIONS]); - $this->assertSame(Relation::BELONGS_TO, $schema['simple'][Schema::RELATIONS]['user'][Relation::TYPE]); - $this->assertSame('user', $schema['simple'][Schema::RELATIONS]['user'][Relation::TARGET]); + \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('user'); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TYPE], Relation::BELONGS_TO); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TARGET], 'user'); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testHasOneInverseLoad(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -155,20 +159,21 @@ public function testHasOneInverseLoad(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('simple', $schema['user'][Schema::RELATIONS]); - $this->assertSame(Relation::HAS_ONE, $schema['user'][Schema::RELATIONS]['simple'][Relation::TYPE]); - $this->assertSame('simple', $schema['user'][Schema::RELATIONS]['simple'][Relation::TARGET]); + \Testo\Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('simple'); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TYPE], Relation::HAS_ONE); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TARGET], 'simple'); - $this->assertSame(Relation::LOAD_EAGER, $schema['user'][Schema::RELATIONS]['simple'][Relation::LOAD]); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::LOAD], Relation::LOAD_EAGER); - $this->assertArrayHasKey('user', $schema['simple'][Schema::RELATIONS]); - $this->assertSame(Relation::BELONGS_TO, $schema['simple'][Schema::RELATIONS]['user'][Relation::TYPE]); - $this->assertSame('user', $schema['simple'][Schema::RELATIONS]['user'][Relation::TARGET]); + \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('user'); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TYPE], Relation::BELONGS_TO); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TARGET], 'user'); - $this->assertSame(Relation::LOAD_PROMISE, $schema['simple'][Schema::RELATIONS]['user'][Relation::LOAD]); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::LOAD], Relation::LOAD_PROMISE); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testBelongsTo(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -193,16 +198,16 @@ public function testBelongsTo(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('owner', $schema['mark'][Schema::RELATIONS]); - $this->assertSame(Relation::BELONGS_TO_MORPHED, $schema['mark'][Schema::RELATIONS]['owner'][Relation::TYPE]); - $this->assertSame(MarkedInterface::class, $schema['mark'][Schema::RELATIONS]['owner'][Relation::TARGET]); + \Testo\Assert::array($schema['mark'][Schema::RELATIONS])->hasKeys('owner'); + \Testo\Assert::same($schema['mark'][Schema::RELATIONS]['owner'][Relation::TYPE], Relation::BELONGS_TO_MORPHED); + \Testo\Assert::same($schema['mark'][Schema::RELATIONS]['owner'][Relation::TARGET], MarkedInterface::class); - $this->assertArrayHasKey('mark', $schema['user'][Schema::RELATIONS]); - $this->assertSame(Relation::MORPHED_HAS_ONE, $schema['user'][Schema::RELATIONS]['mark'][Relation::TYPE]); - $this->assertSame('mark', $schema['user'][Schema::RELATIONS]['mark'][Relation::TARGET]); + \Testo\Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('mark'); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['mark'][Relation::TYPE], Relation::MORPHED_HAS_ONE); + \Testo\Assert::same($schema['user'][Schema::RELATIONS]['mark'][Relation::TARGET], 'mark'); - $this->assertArrayHasKey('mark', $schema['simple'][Schema::RELATIONS]); - $this->assertSame(Relation::MORPHED_HAS_ONE, $schema['simple'][Schema::RELATIONS]['mark'][Relation::TYPE]); - $this->assertSame('mark', $schema['simple'][Schema::RELATIONS]['mark'][Relation::TARGET]); + \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('mark'); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['mark'][Relation::TYPE], Relation::MORPHED_HAS_ONE); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['mark'][Relation::TARGET], 'mark'); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/ManyToManyTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/ManyToManyTestCase.php index fbb1cdf5..545a179e 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/ManyToManyTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/ManyToManyTestCase.php @@ -32,7 +32,8 @@ abstract class ManyToManyTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testPivotPrimaryKeys(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -65,18 +66,16 @@ public function testPivotPrimaryKeys(ReaderInterface $reader): void assert($table instanceof AbstractTable); // Check MTM relation in the Schema - $this->assertSame(Relation::MANY_TO_MANY, $schema['post'][Schema::RELATIONS]['tags'][Relation::TYPE]); - $this->assertSame('tag', $schema['post'][Schema::RELATIONS]['tags'][Relation::TARGET]); - $this->assertSame( - 'context', - $schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_ENTITY], - ); + \Testo\Assert::same($schema['post'][Schema::RELATIONS]['tags'][Relation::TYPE], Relation::MANY_TO_MANY); + \Testo\Assert::same($schema['post'][Schema::RELATIONS]['tags'][Relation::TARGET], 'tag'); + \Testo\Assert::same($schema['post'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_ENTITY], 'context'); // Check table - assertCount(1, $table->getIndexes()); + \Testo\Assert::count($table->getIndexes(), 1); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -93,47 +92,24 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('tags', $schema['withTable'][Schema::RELATIONS]); + \Testo\Assert::array($schema['withTable'][Schema::RELATIONS])->hasKeys('tags'); - $this->assertSame( - Relation::MANY_TO_MANY, - $schema['withTable'][Schema::RELATIONS]['tags'][Relation::TYPE], - ); + \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['tags'][Relation::TYPE], Relation::MANY_TO_MANY); - $this->assertSame( - 'tag', - $schema['withTable'][Schema::RELATIONS]['tags'][Relation::TARGET], - ); + \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['tags'][Relation::TARGET], 'tag'); - $this->assertSame( - 'tagContext', - $schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_ENTITY], - ); + \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_ENTITY], 'tagContext'); - $this->assertSame( - ['withTable_id'], - $schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_INNER_KEY], - ); + \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_INNER_KEY], ['withTable_id']); - $this->assertSame( - ['tag_id'], - $schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_OUTER_KEY], - ); + \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::THROUGH_OUTER_KEY], ['tag_id']); - $this->assertSame( - ['id' => ['>=' => '1']], - $schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::WHERE], - ); - $this->assertSame( - ['id' => 'DESC'], - $schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::ORDER_BY], - ); - $this->assertSame( - BaseCollection::class, - $schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::COLLECTION_TYPE], - ); + \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::WHERE], ['id' => ['>=' => '1']]); + \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::ORDER_BY], ['id' => 'DESC']); + \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::COLLECTION_TYPE], BaseCollection::class); } + #[\Testo\Test] public function testInnerOuterKeys(): void { $tokenizer = new Tokenizer( @@ -179,31 +155,12 @@ public function testInnerOuterKeys(): void $throughInnerKey = (array) $throughInnerKey; $throughOuterKey = (array) $throughOuterKey; - $this->assertSame(Relation::MANY_TO_MANY, $relation[Relation::TYPE], "$name: relation type"); - $this->assertSame( - $innerKey, - (array) $relation[Relation::SCHEMA][Relation::INNER_KEY], - "$name: Inner Key", - ); - $this->assertSame( - $outerKey, - (array) $relation[Relation::SCHEMA][Relation::OUTER_KEY], - "$name: Outer Key", - ); - $this->assertSame( - $throughInnerKey, - (array) $relation[Relation::SCHEMA][Relation::THROUGH_INNER_KEY], - "$name: Through inner Key", - ); - $this->assertSame( - $throughOuterKey, - (array) $relation[Relation::SCHEMA][Relation::THROUGH_OUTER_KEY], - "$name: Through outer Key", - ); + \Testo\Assert::same($relation[Relation::TYPE], Relation::MANY_TO_MANY, "$name: relation type"); + \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::INNER_KEY], $innerKey, "$name: Inner Key"); + \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::OUTER_KEY], $outerKey, "$name: Outer Key"); + \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::THROUGH_INNER_KEY], $throughInnerKey, "$name: Through inner Key"); + \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::THROUGH_OUTER_KEY], $throughOuterKey, "$name: Through outer Key"); } - $this->assertArrayNotHasKey( - 'booking_id_column', - $schema['booking_reservation'][SchemaInterface::COLUMNS], - ); + \Testo\Assert::array($schema['booking_reservation'][SchemaInterface::COLUMNS])->doesNotHaveKeys('booking_id_column'); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/BelongsToMorphedTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/Morphed/BelongsToMorphedTestCase.php index 95830ac7..83c78781 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/BelongsToMorphedTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/Morphed/BelongsToMorphedTestCase.php @@ -26,7 +26,8 @@ abstract class BelongsToMorphedTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -43,17 +44,11 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('owner', $schema['label'][Schema::RELATIONS]); - $this->assertSame( - Relation::BELONGS_TO_MORPHED, - $schema['label'][Schema::RELATIONS]['owner'][Relation::TYPE], - ); + \Testo\Assert::array($schema['label'][Schema::RELATIONS])->hasKeys('owner'); + \Testo\Assert::same($schema['label'][Schema::RELATIONS]['owner'][Relation::TYPE], Relation::BELONGS_TO_MORPHED); - $this->assertSame( - LabelledInterface::class, - $schema['label'][Schema::RELATIONS]['owner'][Relation::TARGET], - ); + \Testo\Assert::same($schema['label'][Schema::RELATIONS]['owner'][Relation::TARGET], LabelledInterface::class); - $this->assertSame(SomeConstrain::class, $schema['label'][Schema::SCOPE]); + \Testo\Assert::same($schema['label'][Schema::SCOPE], SomeConstrain::class); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasManyTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasManyTestCase.php index b5233482..d164b58c 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasManyTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasManyTestCase.php @@ -25,7 +25,8 @@ abstract class MorphedHasManyTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -42,45 +43,30 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('labels', $schema['simple'][Schema::RELATIONS]); - $this->assertSame( - Relation::MORPHED_HAS_MANY, - $schema['simple'][Schema::RELATIONS]['labels'][Relation::TYPE], - ); - $this->assertSame('label', $schema['simple'][Schema::RELATIONS]['labels'][Relation::TARGET]); + \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('labels'); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['labels'][Relation::TYPE], Relation::MORPHED_HAS_MANY); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['labels'][Relation::TARGET], 'label'); - $this->assertArrayHasKey('labels', $schema['withTable'][Schema::RELATIONS]); - $this->assertSame( - Relation::MORPHED_HAS_MANY, - $schema['withTable'][Schema::RELATIONS]['labels'][Relation::TYPE], - ); + \Testo\Assert::array($schema['withTable'][Schema::RELATIONS])->hasKeys('labels'); + \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['labels'][Relation::TYPE], Relation::MORPHED_HAS_MANY); - $this->assertSame('label', $schema['withTable'][Schema::RELATIONS]['labels'][Relation::TARGET]); + \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['labels'][Relation::TARGET], 'label'); - $this->assertTrue( - $this->dbal->database('default') - ->getDriver() - ->getSchema('labels') - ->hasColumn('owner_id'), - ); + \Testo\Assert::true($this->dbal->database('default') + ->getDriver() + ->getSchema('labels') + ->hasColumn('owner_id')); - $this->assertTrue( - $this->dbal->database('default') - ->getDriver() - ->getSchema('labels') - ->hasColumn('owner_role'), - ); + \Testo\Assert::true($this->dbal->database('default') + ->getDriver() + ->getSchema('labels') + ->hasColumn('owner_role')); - $this->assertFalse( - $this->dbal->database('default') - ->getDriver() - ->getSchema('labels') - ->hasIndex(['owner_id', 'owner_role']), - ); + \Testo\Assert::false($this->dbal->database('default') + ->getDriver() + ->getSchema('labels') + ->hasIndex(['owner_id', 'owner_role'])); - $this->assertSame( - BaseCollection::class, - $schema['simple'][\Cycle\ORM\SchemaInterface::RELATIONS]['labels'][Relation::SCHEMA][Relation::COLLECTION_TYPE], // phpcs:ignore - ); + \Testo\Assert::same($schema['simple'][\Cycle\ORM\SchemaInterface::RELATIONS]['labels'][Relation::SCHEMA][Relation::COLLECTION_TYPE], BaseCollection::class); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasOneTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasOneTestCase.php index 668e044d..ddc91b4e 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasOneTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasOneTestCase.php @@ -24,7 +24,8 @@ abstract class MorphedHasOneTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -41,29 +42,23 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('label', $schema['tag'][Schema::RELATIONS]); - $this->assertSame(Relation::MORPHED_HAS_ONE, $schema['tag'][Schema::RELATIONS]['label'][Relation::TYPE]); - $this->assertSame('label', $schema['tag'][Schema::RELATIONS]['label'][Relation::TARGET]); + \Testo\Assert::array($schema['tag'][Schema::RELATIONS])->hasKeys('label'); + \Testo\Assert::same($schema['tag'][Schema::RELATIONS]['label'][Relation::TYPE], Relation::MORPHED_HAS_ONE); + \Testo\Assert::same($schema['tag'][Schema::RELATIONS]['label'][Relation::TARGET], 'label'); - $this->assertTrue( - $this->dbal->database('default') - ->getDriver() - ->getSchema('labels') - ->hasColumn('owner_id'), - ); + \Testo\Assert::true($this->dbal->database('default') + ->getDriver() + ->getSchema('labels') + ->hasColumn('owner_id')); - $this->assertTrue( - $this->dbal->database('default') - ->getDriver() - ->getSchema('labels') - ->hasColumn('owner_role'), - ); + \Testo\Assert::true($this->dbal->database('default') + ->getDriver() + ->getSchema('labels') + ->hasColumn('owner_role')); - $this->assertFalse( - $this->dbal->database('default') - ->getDriver() - ->getSchema('labels') - ->hasIndex(['owner_id', 'owner_role']), - ); + \Testo\Assert::false($this->dbal->database('default') + ->getDriver() + ->getSchema('labels') + ->hasIndex(['owner_id', 'owner_role'])); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/RefersToMorphedTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/Morphed/RefersToMorphedTestCase.php index 373f2a35..e2354107 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/RefersToMorphedTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/Morphed/RefersToMorphedTestCase.php @@ -27,7 +27,8 @@ abstract class RefersToMorphedTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelation(ReaderInterface $reader): void { $locator = (new Tokenizer(new TokenizerConfig([ @@ -49,18 +50,12 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('parent', $schema['comment'][Schema::RELATIONS]); - $this->assertSame( - Relation::REFERS_TO_MORPHED, - $schema['comment'][Schema::RELATIONS]['parent'][Relation::TYPE], - ); - $this->assertSame( - MorphedParentInterface::class, - $schema['comment'][Schema::RELATIONS]['parent'][Relation::TARGET], - ); + \Testo\Assert::array($schema['comment'][Schema::RELATIONS])->hasKeys('parent'); + \Testo\Assert::same($schema['comment'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::REFERS_TO_MORPHED); + \Testo\Assert::same($schema['comment'][Schema::RELATIONS]['parent'][Relation::TARGET], MorphedParentInterface::class); // Morphed refers-to stores the outer key and the target role on the source entity. - $this->assertContains('parent_id', $schema['comment'][Schema::COLUMNS]); - $this->assertContains('parent_role', $schema['comment'][Schema::COLUMNS]); + \Testo\Assert::contains($schema['comment'][Schema::COLUMNS], 'parent_id'); + \Testo\Assert::contains($schema['comment'][Schema::COLUMNS], 'parent_role'); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/RefersToTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/RefersToTestCase.php index 86396098..9965c178 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/RefersToTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/Relation/RefersToTestCase.php @@ -24,7 +24,8 @@ abstract class RefersToTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -41,17 +42,14 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertArrayHasKey('parent', $schema['simple'][Schema::RELATIONS]); - $this->assertSame(Relation::REFERS_TO, $schema['simple'][Schema::RELATIONS]['parent'][Relation::TYPE]); - $this->assertSame('simple', $schema['simple'][Schema::RELATIONS]['parent'][Relation::TARGET]); + \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('parent'); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::REFERS_TO); + \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['parent'][Relation::TARGET], 'simple'); - $this->assertSame( - 'NO ACTION', - $this->dbal->database('default') - ->getDriver() - ->getSchema('simples') - ->foreignKey(['parent_id']) - ->getDeleteRule(), - ); + \Testo\Assert::same($this->dbal->database('default') + ->getDriver() + ->getSchema('simples') + ->foreignKey(['parent_id']) + ->getDeleteRule(), 'NO ACTION'); } } diff --git a/tests/Annotated/Functional/Driver/Common/SchemaModifiersTestCase.php b/tests/Annotated/Functional/Driver/Common/SchemaModifiersTestCase.php index 3c23b00f..4bc36894 100644 --- a/tests/Annotated/Functional/Driver/Common/SchemaModifiersTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/SchemaModifiersTestCase.php @@ -29,7 +29,8 @@ abstract class SchemaModifiersTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testModifierAnnotationShouldBeAddedToEntity(ReaderInterface $reader): void { $tokenizer = new Tokenizer( @@ -59,11 +60,11 @@ public function testModifierAnnotationShouldBeAddedToEntity(ReaderInterface $rea $post = $r->getEntity('post'); $modifiers = iterator_to_array($post->getSchemaModifiers()); - $this->assertCount(2, $modifiers); - $this->assertInstanceOf(ParentSegmentSchemaModifier::class, $modifiers[0]); - $this->assertInstanceOf(MapperSegmentSchemaModifier::class, $modifiers[1]); + \Testo\Assert::count($modifiers, 2); + \Testo\Assert::instanceOf($modifiers[0], ParentSegmentSchemaModifier::class); + \Testo\Assert::instanceOf($modifiers[1], MapperSegmentSchemaModifier::class); - $this->assertSame(\stdClass::class, $schema['post'][SchemaInterface::PARENT]); - $this->assertSame(Child::class, $schema['post'][SchemaInterface::MAPPER]); + \Testo\Assert::same($schema['post'][SchemaInterface::PARENT], \stdClass::class); + \Testo\Assert::same($schema['post'][SchemaInterface::MAPPER], Child::class); } } diff --git a/tests/Annotated/Functional/Driver/Common/TableTestCase.php b/tests/Annotated/Functional/Driver/Common/TableTestCase.php index 611a5c3e..e1dd404e 100644 --- a/tests/Annotated/Functional/Driver/Common/TableTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/TableTestCase.php @@ -76,7 +76,8 @@ public static function foreignKeyDirectoriesDataProvider(): \Traversable ]; } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testColumnsRendered(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -84,21 +85,22 @@ public function testColumnsRendered(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - $this->assertTrue($r->hasTable($r->getEntity('withTable'))); + \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - $this->assertTrue($schema->hasColumn('name')); - $this->assertSame('string', $schema->column('status')->getType()); + \Testo\Assert::true($schema->hasColumn('name')); + \Testo\Assert::same($schema->column('status')->getType(), 'string'); - $this->assertTrue($schema->hasColumn('status')); + \Testo\Assert::true($schema->hasColumn('status')); - $this->assertSame('enum', $schema->column('status')->getAbstractType()); - $this->assertSame('active', $schema->column('status')->getDefaultValue()); - $this->assertSame(['active', 'disabled'], $schema->column('status')->getEnumValues()); + \Testo\Assert::same($schema->column('status')->getAbstractType(), 'enum'); + \Testo\Assert::same($schema->column('status')->getDefaultValue(), 'active'); + \Testo\Assert::same($schema->column('status')->getEnumValues(), ['active', 'disabled']); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testColumnWithDifferentColumnNameAndProperty(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -110,12 +112,13 @@ public function testColumnWithDifferentColumnNameAndProperty(ReaderInterface $re new RenderTables(), ], ); - $this->assertArrayHasKey('withTable', $schema); - $this->assertArrayHasKey('status_property', $schema['withTable'][Schema::COLUMNS]); - $this->assertSame('status', $schema['withTable'][Schema::COLUMNS]['status_property']); + \Testo\Assert::array($schema)->hasKeys('withTable'); + \Testo\Assert::array($schema['withTable'][Schema::COLUMNS])->hasKeys('status_property'); + \Testo\Assert::same($schema['withTable'][Schema::COLUMNS]['status_property'], 'status'); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testColumnWithoutColumnName(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -127,11 +130,12 @@ public function testColumnWithoutColumnName(ReaderInterface $reader): void new RenderTables(), ], ); - $this->assertArrayHasKey('withTable', $schema); - $this->assertArrayHasKey('no_column_name', $schema['withTable'][Schema::COLUMNS]); - $this->assertSame('no_column_name', $schema['withTable'][Schema::COLUMNS]['no_column_name']); + \Testo\Assert::array($schema)->hasKeys('withTable'); + \Testo\Assert::array($schema['withTable'][Schema::COLUMNS])->hasKeys('no_column_name'); + \Testo\Assert::same($schema['withTable'][Schema::COLUMNS]['no_column_name'], 'no_column_name'); } + #[\Testo\Test] public function testColumnInTableAnnotationByNumericKey(): void { $reader = new AnnotationReader(); @@ -147,11 +151,12 @@ public function testColumnInTableAnnotationByNumericKey(): void new RenderTables(), ]); - $this->assertArrayHasKey('orderedIdx', $schema); - $this->assertArrayHasKey('other_name', $schema['orderedIdx'][Schema::COLUMNS]); - $this->assertSame('other_name', $schema['orderedIdx'][Schema::COLUMNS]['other_name']); + \Testo\Assert::array($schema)->hasKeys('orderedIdx'); + \Testo\Assert::array($schema['orderedIdx'][Schema::COLUMNS])->hasKeys('other_name'); + \Testo\Assert::same($schema['orderedIdx'][Schema::COLUMNS]['other_name'], 'other_name'); } + #[\Testo\Test] public function testColumnWithPropertyInTableAnnotationByNamedKey(): void { $reader = new AnnotationReader(); @@ -162,11 +167,8 @@ public function testColumnWithPropertyInTableAnnotationByNamedKey(): void $locator = $tokenizer->classLocator(); $r = new Registry($this->dbal); - $this->expectException(AnnotationException::class); - $this->expectExceptionMessage( - 'Can not use name "name1" for Column of the `badEntity` role, because the ' - . '"property" field of the metadata class has already been set to "name2".', - ); + \Testo\Expect::exception(AnnotationException::class)->withMessageContaining('Can not use name "name1" for Column of the `badEntity` role, because the ' + . '"property" field of the metadata class has already been set to "name2".'); (new Compiler())->compile($r, [ new Entities(new TokenizerEntityLocator($locator, $reader), $reader), @@ -175,7 +177,8 @@ public function testColumnWithPropertyInTableAnnotationByNamedKey(): void ]); } - #[DataProvider('singularReadersProvider')] + #[\Testo\Data\DataProvider('singularReadersProvider')] + #[\Testo\Test] public function testCompositePrimaryKey(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -194,14 +197,14 @@ public function testCompositePrimaryKey(ReaderInterface $reader): void $schema = $r->getTableSchema($r->getEntity('compositePost')); - $this->assertEquals(['id', 'user_id'], $schema->getPrimaryKeys()); + \Testo\Assert::equals($schema->getPrimaryKeys(), ['id', 'user_id']); } - #[DataProvider('singularReadersProvider')] + #[\Testo\Data\DataProvider('singularReadersProvider')] + #[\Testo\Test] public function testIndexWithEmptyColumnsShouldThrowAnException(ReaderInterface $reader): void { - $this->expectException(AnnotationException::class); - $this->expectExceptionMessage('Invalid index definition for `compositePost`. Column list can\'t be empty.'); + \Testo\Expect::exception(AnnotationException::class)->withMessageContaining('Invalid index definition for `compositePost`. Column list can\'t be empty.'); $r = new Registry($this->dbal); @@ -217,7 +220,8 @@ public function testIndexWithEmptyColumnsShouldThrowAnException(ReaderInterface (new MergeIndexes($reader))->run($r); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testIndexes(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -228,18 +232,19 @@ public function testIndexes(ReaderInterface $reader): void (new MergeIndexes($reader))->run($r); (new SyncTables())->run($r); - $this->assertTrue($r->hasTable($r->getEntity('withTable'))); + \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - $this->assertTrue($schema->hasIndex(['name'])); - $this->assertTrue($schema->index(['name'])->isUnique()); - $this->assertSame('name_index', $schema->index(['name'])->getName()); + \Testo\Assert::true($schema->hasIndex(['name'])); + \Testo\Assert::true($schema->index(['name'])->isUnique()); + \Testo\Assert::same($schema->index(['name'])->getName(), 'name_index'); - $this->assertTrue($schema->hasIndex(['status'])); + \Testo\Assert::true($schema->hasIndex(['status'])); } - #[DataProvider('singularReadersProvider')] + #[\Testo\Data\DataProvider('singularReadersProvider')] + #[\Testo\Test] public function testOrderedIndexes(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -257,15 +262,16 @@ public function testOrderedIndexes(ReaderInterface $reader): void (new MergeIndexes($reader))->run($r); (new SyncTables())->run($r); - $this->assertTrue($r->hasTable($r->getEntity('orderedIdx'))); + \Testo\Assert::true($r->hasTable($r->getEntity('orderedIdx'))); $schema = $r->getTableSchema($r->getEntity('orderedIdx')); - $this->assertTrue($schema->hasColumn('name')); - $this->assertTrue($schema->hasIndex(['name', 'id DESC'])); + \Testo\Assert::true($schema->hasColumn('name')); + \Testo\Assert::true($schema->hasIndex(['name', 'id DESC'])); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testNamingDefault(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -273,14 +279,15 @@ public function testNamingDefault(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - $this->assertTrue($r->hasTable($r->getEntity('withTable'))); + \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - $this->assertSame('with_tables', $schema->getName()); + \Testo\Assert::same($schema->getName(), 'with_tables'); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testNamingPluralize(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -292,14 +299,15 @@ public function testNamingPluralize(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - $this->assertTrue($r->hasTable($r->getEntity('withTable'))); + \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - $this->assertSame('with_tables', $schema->getName()); + \Testo\Assert::same($schema->getName(), 'with_tables'); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testNamingSingular(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -311,14 +319,15 @@ public function testNamingSingular(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - $this->assertTrue($r->hasTable($r->getEntity('withTable'))); + \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - $this->assertSame('with_table', $schema->getName()); + \Testo\Assert::same($schema->getName(), 'with_table'); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testNamingNone(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -330,14 +339,15 @@ public function testNamingNone(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - $this->assertTrue($r->hasTable($r->getEntity('withTable'))); + \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - $this->assertSame('with_table', $schema->getName()); + \Testo\Assert::same($schema->getName(), 'with_table'); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testReadonlySchema(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -345,14 +355,15 @@ public function testReadonlySchema(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - $this->assertTrue($r->hasTable($r->getEntity('simple'))); + \Testo\Assert::true($r->hasTable($r->getEntity('simple'))); $schema = $r->getTableSchema($r->getEntity('simple')); - $this->assertTrue($schema->column('read_only_column')->isReadonlySchema()); + \Testo\Assert::true($schema->column('read_only_column')->isReadonlySchema()); } - #[DataProvider('foreignKeyDirectoriesDataProvider')] + #[\Testo\Data\DataProvider('foreignKeyDirectoriesDataProvider')] + #[\Testo\Test] public function testForeignKeysAnnotationReader( ReaderInterface $reader, string $directory, @@ -381,12 +392,12 @@ public function testForeignKeysAnnotationReader( $foreignKeys = $registry->getTableSchema($registry->getEntity('from'))->getForeignKeys(); $expectedFk = array_shift($foreignKeys); - $this->assertStringContainsString('from', $expectedFk->getTable()); - $this->assertStringContainsString('to', $expectedFk->getForeignTable()); - $this->assertSame(['inner_key'], $expectedFk->getColumns()); - $this->assertSame([$outerKey], $expectedFk->getForeignKeys()); - $this->assertSame('CASCADE', $expectedFk->getDeleteRule()); - $this->assertSame('CASCADE', $expectedFk->getUpdateRule()); - $this->assertTrue($expectedFk->hasIndex()); + \Testo\Assert::string($expectedFk->getTable())->contains('from'); + \Testo\Assert::string($expectedFk->getForeignTable())->contains('to'); + \Testo\Assert::same($expectedFk->getColumns(), ['inner_key']); + \Testo\Assert::same($expectedFk->getForeignKeys(), [$outerKey]); + \Testo\Assert::same($expectedFk->getDeleteRule(), 'CASCADE'); + \Testo\Assert::same($expectedFk->getUpdateRule(), 'CASCADE'); + \Testo\Assert::true($expectedFk->hasIndex()); } } diff --git a/tests/Annotated/Functional/Driver/Common/TypecastTestCase.php b/tests/Annotated/Functional/Driver/Common/TypecastTestCase.php index 4e8771b7..26964678 100644 --- a/tests/Annotated/Functional/Driver/Common/TypecastTestCase.php +++ b/tests/Annotated/Functional/Driver/Common/TypecastTestCase.php @@ -31,7 +31,8 @@ abstract class TypecastTestCase extends BaseTestCase { - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testEntityWithDefinedTypecastAsString(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -41,13 +42,11 @@ public function testEntityWithDefinedTypecastAsString(ReaderInterface $reader): new MergeColumns($reader), ]); - $this->assertSame( - Typecaster::class, - $schema['simple'][Schema::TYPECAST_HANDLER], - ); + \Testo\Assert::same($schema['simple'][Schema::TYPECAST_HANDLER], Typecaster::class); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testEntityWithDefinedTypecastAsArray(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -57,17 +56,15 @@ public function testEntityWithDefinedTypecastAsArray(ReaderInterface $reader): v new MergeColumns($reader), ]); - $this->assertSame( - [ - Typecaster::class, - UuidTypecaster::class, - 'foo', - ], - $schema['tag'][Schema::TYPECAST_HANDLER], - ); + \Testo\Assert::same($schema['tag'][Schema::TYPECAST_HANDLER], [ + Typecaster::class, + UuidTypecaster::class, + 'foo', + ]); } - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testBackedEnum(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -92,13 +89,10 @@ public function testBackedEnum(ReaderInterface $reader): void new GenerateTypecast(), ]); - $this->assertSame( - [ - 'bid' => 'int', - 'be' => BackedEnum::class, - 'bew' => [BackedEnumWrapper::class, 'typecast'], - ], - $schema['booking'][SchemaInterface::TYPECAST], - ); + \Testo\Assert::same($schema['booking'][SchemaInterface::TYPECAST], [ + 'bid' => 'int', + 'be' => BackedEnum::class, + 'bew' => [BackedEnumWrapper::class, 'typecast'], + ]); } } diff --git a/tests/Annotated/Functional/Driver/MySQL/TableTest.php b/tests/Annotated/Functional/Driver/MySQL/TableTest.php index 6444b69c..2d3bab98 100644 --- a/tests/Annotated/Functional/Driver/MySQL/TableTest.php +++ b/tests/Annotated/Functional/Driver/MySQL/TableTest.php @@ -15,12 +15,11 @@ use PHPUnit\Framework\Attributes\Group; use Spiral\Attributes\AttributeReader; -#[Group('driver')] -#[Group('driver-mysql')] +#[\Testo\Filter\Group('driver', 'driver-mysql')] final class TableTest extends TableTestCase { public const DRIVER = 'mysql'; - + #[\Testo\Test] public function testUnsigned(): void { $reader = new AttributeReader(); @@ -31,15 +30,15 @@ public function testUnsigned(): void $schema = $r->getTableSchema($r->getEntity('label')); - $this->assertTrue($schema->column('unsigned')->isUnsigned()); - $this->assertFalse($schema->column('simple')->isUnsigned()); + \Testo\Assert::true($schema->column('unsigned')->isUnsigned()); + \Testo\Assert::false($schema->column('simple')->isUnsigned()); $schema->save(); - $this->assertTrue($this->dbal->database()->table('labels')->getSchema()->column('unsigned')->isUnsigned()); - $this->assertFalse($this->dbal->database()->table('labels')->getSchema()->column('simple')->isUnsigned()); + \Testo\Assert::true($this->dbal->database()->table('labels')->getSchema()->column('unsigned')->isUnsigned()); + \Testo\Assert::false($this->dbal->database()->table('labels')->getSchema()->column('simple')->isUnsigned()); } - + #[\Testo\Test] public function testZerofill(): void { $reader = new AttributeReader(); @@ -50,15 +49,15 @@ public function testZerofill(): void $schema = $r->getTableSchema($r->getEntity('label')); - $this->assertTrue($schema->column('zerofill')->isZerofill()); - $this->assertFalse($schema->column('simple')->isZerofill()); + \Testo\Assert::true($schema->column('zerofill')->isZerofill()); + \Testo\Assert::false($schema->column('simple')->isZerofill()); $schema->save(); - $this->assertTrue($this->dbal->database()->table('labels')->getSchema()->column('zerofill')->isUnsigned()); - $this->assertFalse($this->dbal->database()->table('labels')->getSchema()->column('simple')->isUnsigned()); + \Testo\Assert::true($this->dbal->database()->table('labels')->getSchema()->column('zerofill')->isUnsigned()); + \Testo\Assert::false($this->dbal->database()->table('labels')->getSchema()->column('simple')->isUnsigned()); } - + #[\Testo\Test] public function testColumnCustomAttributes(): void { $reader = new AttributeReader(); @@ -71,7 +70,7 @@ public function testColumnCustomAttributes(): void $dbSchema = $this->dbal->database()->table('labels')->getSchema(); $attributes = $dbSchema->column('charset_column')->getAttributes(); - $this->assertSame('ascii', $attributes['charset']); - $this->assertSame('ascii_bin', $attributes['collation']); + \Testo\Assert::same($attributes['charset'], 'ascii'); + \Testo\Assert::same($attributes['collation'], 'ascii_bin'); } } diff --git a/tests/Annotated/Functional/Driver/Postgres/GeneratedFieldsTest.php b/tests/Annotated/Functional/Driver/Postgres/GeneratedFieldsTest.php index 2e667859..0f49ebfe 100644 --- a/tests/Annotated/Functional/Driver/Postgres/GeneratedFieldsTest.php +++ b/tests/Annotated/Functional/Driver/Postgres/GeneratedFieldsTest.php @@ -18,13 +18,12 @@ use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; -#[Group('driver')] -#[Group('driver-postgres')] +#[\Testo\Filter\Group('driver', 'driver-postgres')] final class GeneratedFieldsTest extends GeneratedFieldsTestCase { public const DRIVER = 'postgres'; - - #[DataProvider('allReadersProvider')] + #[\Testo\Data\DataProvider('allReadersProvider')] + #[\Testo\Test] public function testSerialGeneratedFields(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ @@ -40,14 +39,11 @@ public function testSerialGeneratedFields(ReaderInterface $reader): void new Entities(new TokenizerEntityLocator($locator, $reader), $reader), ]); - $this->assertSame( - [ - 'id' => GeneratedField::ON_INSERT, - 'smallSerial' => GeneratedField::ON_INSERT, - 'serial' => GeneratedField::ON_INSERT, - 'bigSerial' => GeneratedField::ON_INSERT, - ], - $schema['withGeneratedSerial'][SchemaInterface::GENERATED_FIELDS], - ); + \Testo\Assert::same($schema['withGeneratedSerial'][SchemaInterface::GENERATED_FIELDS], [ + 'id' => GeneratedField::ON_INSERT, + 'smallSerial' => GeneratedField::ON_INSERT, + 'serial' => GeneratedField::ON_INSERT, + 'bigSerial' => GeneratedField::ON_INSERT, + ]); } } diff --git a/tests/Annotated/Unit/Attribute/ColumnTest.php b/tests/Annotated/Unit/Attribute/ColumnTest.php index 897d984f..20b37e83 100644 --- a/tests/Annotated/Unit/Attribute/ColumnTest.php +++ b/tests/Annotated/Unit/Attribute/ColumnTest.php @@ -8,7 +8,7 @@ use Cycle\Annotated\Tests\Unit\Attribute\SingleTable\StringEnum; use PHPUnit\Framework\TestCase; -class ColumnTest extends TestCase +class ColumnTest { public const ENUM_VALUE_A = 'a'; public const ENUM_VALUE_B = 'b'; @@ -60,94 +60,105 @@ class ColumnTest extends TestCase )] private StringEnum $column10 = StringEnum::A; + #[\Testo\Test] public function testOneAttribute(): void { $column = $this->getColumn('column1'); - $this->assertSame(['unsigned' => true], $column->getAttributes()); + \Testo\Assert::same($column->getAttributes(), ['unsigned' => true]); } + #[\Testo\Test] public function testTwoAttributes(): void { $column = $this->getColumn('column2'); - $this->assertSame(['unsigned' => true, 'zerofill' => true], $column->getAttributes()); + \Testo\Assert::same($column->getAttributes(), ['unsigned' => true, 'zerofill' => true]); } + #[\Testo\Test] public function testCustomSizeAttribute(): void { $column = $this->getColumn('column3'); - $this->assertSame(['size' => 128], $column->getAttributes()); + \Testo\Assert::same($column->getAttributes(), ['size' => 128]); } + #[\Testo\Test] public function testDefaultReadonlySchema(): void { $column = $this->getColumn('column1'); - $this->assertFalse($column->isReadonlySchema()); + \Testo\Assert::false($column->isReadonlySchema()); } + #[\Testo\Test] public function testReadonlySchema(): void { $column = $this->getColumn('column4'); - $this->assertTrue($column->isReadonlySchema()); + \Testo\Assert::true($column->isReadonlySchema()); } + #[\Testo\Test] public function testEnumTypeString(): void { $column = $this->getColumn('column5'); - $this->assertSame('enum(a,b)', $column->getType()); + \Testo\Assert::same($column->getType(), 'enum(a,b)'); } + #[\Testo\Test] public function testEnumTypeArray(): void { $column = $this->getColumn('column6'); - $this->assertSame('enum(a,b)', $column->getType()); - $this->assertSame('a', $column->getDefault()); - $this->assertArrayNotHasKey('values', $column->getAttributes()); + \Testo\Assert::same($column->getType(), 'enum(a,b)'); + \Testo\Assert::same($column->getDefault(), 'a'); + \Testo\Assert::array($column->getAttributes())->doesNotHaveKeys('values'); } + #[\Testo\Test] public function testEnumTypeBackedEnum(): void { $column = $this->getColumn('column7'); - $this->assertSame('enum(a,b)', $column->getType()); - $this->assertSame('a', $column->getDefault()); - $this->assertArrayNotHasKey('values', $column->getAttributes()); + \Testo\Assert::same($column->getType(), 'enum(a,b)'); + \Testo\Assert::same($column->getDefault(), 'a'); + \Testo\Assert::array($column->getAttributes())->doesNotHaveKeys('values'); } + #[\Testo\Test] public function testEnumTypeArrayBackedEnum(): void { $column = $this->getColumn('column8'); - $this->assertSame('enum(a,b)', $column->getType()); - $this->assertSame('a', $column->getDefault()); - $this->assertArrayNotHasKey('values', $column->getAttributes()); + \Testo\Assert::same($column->getType(), 'enum(a,b)'); + \Testo\Assert::same($column->getDefault(), 'a'); + \Testo\Assert::array($column->getAttributes())->doesNotHaveKeys('values'); } + #[\Testo\Test] public function testEnumTypeBackedEnumAsDefault(): void { $column = $this->getColumn('column10'); - $this->assertSame('enum(a,b)', $column->getType()); - $this->assertSame('a', $column->getDefault()); - $this->assertArrayNotHasKey('values', $column->getAttributes()); + \Testo\Assert::same($column->getType(), 'enum(a,b)'); + \Testo\Assert::same($column->getDefault(), 'a'); + \Testo\Assert::array($column->getAttributes())->doesNotHaveKeys('values'); } + #[\Testo\Test] public function testCharsetAndCollationAttributes(): void { $column = $this->getColumn('column9'); - $this->assertSame('string', $column->getType()); - $this->assertSame([ + \Testo\Assert::same($column->getType(), 'string'); + \Testo\Assert::same($column->getAttributes(), [ 'length' => 255, 'charset' => 'ascii', 'collation' => 'ascii_bin', - ], $column->getAttributes()); + ]); } private function getColumn(string $field): Column diff --git a/tests/Annotated/Unit/Attribute/SingleTable/SingleTableTest.php b/tests/Annotated/Unit/Attribute/SingleTable/SingleTableTest.php index 63588803..8a49bc52 100644 --- a/tests/Annotated/Unit/Attribute/SingleTable/SingleTableTest.php +++ b/tests/Annotated/Unit/Attribute/SingleTable/SingleTableTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -final class SingleTableTest extends TestCase +final class SingleTableTest { public static function dataBase(): iterable { @@ -21,11 +21,12 @@ public static function dataBase(): iterable yield ['a', StringEnum::A]; } - #[DataProvider('dataBase')] + #[\Testo\Data\DataProvider('dataBase')] + #[\Testo\Test] public function testBase1(?string $expected, mixed $value): void { $attribute = new SingleTable($value); - $this->assertSame($expected, $attribute->getValue()); + \Testo\Assert::same($attribute->getValue(), $expected); } } diff --git a/tests/Annotated/Unit/Locator/TokenizerEmbeddingLocatorTest.php b/tests/Annotated/Unit/Locator/TokenizerEmbeddingLocatorTest.php index 59132fa3..d270c1c5 100644 --- a/tests/Annotated/Unit/Locator/TokenizerEmbeddingLocatorTest.php +++ b/tests/Annotated/Unit/Locator/TokenizerEmbeddingLocatorTest.php @@ -13,7 +13,7 @@ use PHPUnit\Framework\TestCase; use Spiral\Tokenizer\ClassesInterface; -final class TokenizerEmbeddingLocatorTest extends TestCase +final class TokenizerEmbeddingLocatorTest { public static function classesDataProvider(): \Traversable { @@ -33,7 +33,8 @@ public static function classesDataProvider(): \Traversable ]; } - #[DataProvider('classesDataProvider')] + #[\Testo\Data\DataProvider('classesDataProvider')] + #[\Testo\Test] public function testGetEmbeddings(array $expected, array $classes): void { $mock = $this->createMock(ClassesInterface::class); @@ -41,6 +42,6 @@ public function testGetEmbeddings(array $expected, array $classes): void $locator = new TokenizerEmbeddingLocator($mock); - $this->assertEquals($expected, $locator->getEmbeddings()); + \Testo\Assert::equals($locator->getEmbeddings(), $expected); } } diff --git a/tests/Annotated/Unit/Locator/TokenizerEntityLocatorTest.php b/tests/Annotated/Unit/Locator/TokenizerEntityLocatorTest.php index 6c341b1f..ab92d4a1 100644 --- a/tests/Annotated/Unit/Locator/TokenizerEntityLocatorTest.php +++ b/tests/Annotated/Unit/Locator/TokenizerEntityLocatorTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\TestCase; use Spiral\Tokenizer\ClassesInterface; -final class TokenizerEntityLocatorTest extends TestCase +final class TokenizerEntityLocatorTest { public static function classesDataProvider(): \Traversable { @@ -40,7 +40,8 @@ public static function classesDataProvider(): \Traversable ]; } - #[DataProvider('classesDataProvider')] + #[\Testo\Data\DataProvider('classesDataProvider')] + #[\Testo\Test] public function testGetEntities(array $expected, array $classes): void { $mock = $this->createMock(ClassesInterface::class); @@ -48,6 +49,6 @@ public function testGetEntities(array $expected, array $classes): void $locator = new TokenizerEntityLocator($mock); - $this->assertEquals($expected, $locator->getEntities()); + \Testo\Assert::equals($locator->getEntities(), $expected); } } diff --git a/tests/Annotated/Unit/ReaderFactoryTest.php b/tests/Annotated/Unit/ReaderFactoryTest.php index 826c1c2e..9cc11ac0 100644 --- a/tests/Annotated/Unit/ReaderFactoryTest.php +++ b/tests/Annotated/Unit/ReaderFactoryTest.php @@ -11,27 +11,30 @@ use Spiral\Attributes\AttributeReader; use Spiral\Attributes\Composite\MergeReader; -class ReaderFactoryTest extends TestCase +class ReaderFactoryTest { + #[\Testo\Test] public function testCreateFromNull(): void { $reader = ReaderFactory::create(null); - $this->assertInstanceOf(AttributeReader::class, $reader); + \Testo\Assert::instanceOf($reader, AttributeReader::class); } + #[\Testo\Test] public function testCreateFromDoctrineReader(): void { $reader = ReaderFactory::create(new DoctrineAnnotationReader()); - $this->assertInstanceOf(AnnotationReader::class, $reader); + \Testo\Assert::instanceOf($reader, AnnotationReader::class); } + #[\Testo\Test] public function testCreateFromCustomReader(): void { $mergeReader = new MergeReader([]); $reader = ReaderFactory::create($mergeReader); - $this->assertSame($mergeReader, $reader); + \Testo\Assert::same($reader, $mergeReader); } } diff --git a/tests/Annotated/Unit/Utils/EntityUtilsTest.php b/tests/Annotated/Unit/Utils/EntityUtilsTest.php index 07300cb4..2e2d0f35 100644 --- a/tests/Annotated/Unit/Utils/EntityUtilsTest.php +++ b/tests/Annotated/Unit/Utils/EntityUtilsTest.php @@ -13,7 +13,7 @@ use Spiral\Attributes\AttributeReader; use Spiral\Attributes\ReaderInterface; -class EntityUtilsTest extends TestCase +class EntityUtilsTest { public static function findParentDataProvider(): iterable { @@ -46,7 +46,8 @@ public static function findParentDataProvider(): iterable } } - #[DataProvider('findParentDataProvider')] + #[\Testo\Data\DataProvider('findParentDataProvider')] + #[\Testo\Test] public function testFindParent( ReaderInterface $reader, string $child, @@ -57,17 +58,15 @@ public function testFindParent( $actualParent = $entityUtils->findParent($child, $root); - $this->assertEquals($expectedParent, $actualParent); + \Testo\Assert::equals($actualParent, $expectedParent); } + #[\Testo\Test] public function testGetParentException(): void { $entityUtils = new EntityUtils(new AttributeReader()); - $this->expectException(AnnotationException::class); - $this->expectExceptionMessage( - \sprintf('The parent class could not be found for the class `%s`.', Person::class), - ); + \Testo\Expect::exception(AnnotationException::class)->withMessageContaining(\sprintf('The parent class could not be found for the class `%s`.', Person::class)); $entityUtils->getParent(Person::class); } } From ada5abd745e85fe42430018ee028e6682b340efb Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 12:19:56 +0400 Subject: [PATCH 04/12] test: run annotated tests on the cycle/testing harness The harness runs a common test in every driver suite, so the generated per-driver stubs and their generator go, and the copied table and logger helpers give way to the package. CompositePkGeneratedTest now also runs on SQL Server, the other RETURNING driver its docblock names. Assisted-By: Claude Opus 5.5 --- tests/Annotated/Feature/BaseTestCase.php | 42 ++++ .../Common/ChildTest.php} | 21 +- .../Common/CompositePkGeneratedTest.php} | 42 ++-- .../Common/GeneratedFieldsTest.php} | 17 +- .../Feature/Common/GeneratorTest.php | 156 +++++++++++++ .../Common/Inheritance/JoinedTableTest.php} | 104 +++++---- .../Common/Inheritance/SingleTableTest.php} | 170 +++++++------- .../Common/InheritanceTest.php} | 172 +++++++------- .../Common/InvalidTest.php} | 25 +- .../Common/Relation/BelongsToTest.php} | 20 +- .../Common/Relation/CompositeKeysTest.php} | 18 +- .../Common/Relation/EmbeddedTest.php} | 60 ++--- .../Common/Relation/HasManyTest.php} | 36 +-- .../Common/Relation/HasOneTest.php} | 34 +-- .../Feature/Common/Relation/InverseTest.php | 215 ++++++++++++++++++ .../Common/Relation/ManyToManyTest.php} | 25 +- .../Morphed/BelongsToMorphedTest.php} | 22 +- .../Relation/Morphed/MorphedHasManyTest.php} | 34 +-- .../Relation/Morphed/MorphedHasOneTest.php} | 26 ++- .../Relation/Morphed/RefersToMorphedTest.php} | 26 ++- .../Common/Relation/RefersToTest.php} | 22 +- .../Common/SchemaModifiersTest.php} | 25 +- .../Common/TableTest.php} | 166 +++++++------- .../Common/TypecastTest.php} | 29 +-- .../Driver => Feature}/MySQL/TableTest.php | 43 ++-- .../Postgres/GeneratedFieldsTest.php | 27 +-- .../Fixtures/Fixtures1/TestLogger.php | 105 --------- .../Functional/Driver/Common/BaseTestCase.php | 168 -------------- .../Driver/Common/GeneratorTestCase.php | 153 ------------- .../Common/Relation/InverseTestCase.php | 213 ----------------- .../Functional/Driver/MySQL/ChildTest.php | 16 -- .../Driver/MySQL/GeneratedFieldsTest.php | 16 -- .../Functional/Driver/MySQL/GeneratorTest.php | 16 -- .../MySQL/Inheritance/JoinedTableTest.php | 16 -- .../MySQL/Inheritance/SingleTableTest.php | 16 -- .../Driver/MySQL/InheritanceTest.php | 16 -- .../Functional/Driver/MySQL/InvalidTest.php | 16 -- .../Driver/MySQL/Relation/BelongsToTest.php | 16 -- .../MySQL/Relation/CompositeKeysTest.php | 16 -- .../Driver/MySQL/Relation/EmbeddedTest.php | 16 -- .../Driver/MySQL/Relation/HasManyTest.php | 16 -- .../Driver/MySQL/Relation/HasOneTest.php | 16 -- .../Driver/MySQL/Relation/InverseTest.php | 16 -- .../Driver/MySQL/Relation/ManyToManyTest.php | 16 -- .../Relation/Morphed/BelongsToMorphedTest.php | 16 -- .../Relation/Morphed/MorphedHasManyTest.php | 16 -- .../Relation/Morphed/MorphedHasOneTest.php | 16 -- .../Relation/Morphed/RefersToMorphedTest.php | 16 -- .../Driver/MySQL/Relation/RefersToTest.php | 16 -- .../Driver/MySQL/SchemaModifiersTest.php | 16 -- .../Functional/Driver/MySQL/TypecastTest.php | 16 -- .../Functional/Driver/Postgres/ChildTest.php | 16 -- .../Postgres/CompositePkGeneratedTest.php | 15 -- .../Driver/Postgres/GeneratorTest.php | 16 -- .../Postgres/Inheritance/JoinedTableTest.php | 16 -- .../Postgres/Inheritance/SingleTableTest.php | 16 -- .../Driver/Postgres/InheritanceTest.php | 16 -- .../Driver/Postgres/InvalidTest.php | 16 -- .../Postgres/Relation/BelongsToTest.php | 16 -- .../Postgres/Relation/CompositeKeysTest.php | 16 -- .../Driver/Postgres/Relation/EmbeddedTest.php | 16 -- .../Driver/Postgres/Relation/HasManyTest.php | 16 -- .../Driver/Postgres/Relation/HasOneTest.php | 16 -- .../Driver/Postgres/Relation/InverseTest.php | 16 -- .../Postgres/Relation/ManyToManyTest.php | 16 -- .../Relation/Morphed/BelongsToMorphedTest.php | 16 -- .../Relation/Morphed/MorphedHasManyTest.php | 16 -- .../Relation/Morphed/MorphedHasOneTest.php | 16 -- .../Relation/Morphed/RefersToMorphedTest.php | 16 -- .../Driver/Postgres/Relation/RefersToTest.php | 16 -- .../Driver/Postgres/SchemaModifiersTest.php | 16 -- .../Functional/Driver/Postgres/TableTest.php | 16 -- .../Driver/Postgres/TypecastTest.php | 16 -- .../Functional/Driver/SQLServer/ChildTest.php | 16 -- .../Driver/SQLServer/GeneratedFieldsTest.php | 16 -- .../Driver/SQLServer/GeneratorTest.php | 16 -- .../SQLServer/Inheritance/JoinedTableTest.php | 16 -- .../SQLServer/Inheritance/SingleTableTest.php | 16 -- .../Driver/SQLServer/InheritanceTest.php | 16 -- .../Driver/SQLServer/InvalidTest.php | 16 -- .../SQLServer/Relation/BelongsToTest.php | 16 -- .../SQLServer/Relation/CompositeKeysTest.php | 16 -- .../SQLServer/Relation/EmbeddedTest.php | 16 -- .../Driver/SQLServer/Relation/HasManyTest.php | 16 -- .../Driver/SQLServer/Relation/HasOneTest.php | 16 -- .../Driver/SQLServer/Relation/InverseTest.php | 16 -- .../SQLServer/Relation/ManyToManyTest.php | 16 -- .../Relation/Morphed/BelongsToMorphedTest.php | 16 -- .../Relation/Morphed/MorphedHasManyTest.php | 16 -- .../Relation/Morphed/MorphedHasOneTest.php | 16 -- .../Relation/Morphed/RefersToMorphedTest.php | 16 -- .../SQLServer/Relation/RefersToTest.php | 16 -- .../Driver/SQLServer/SchemaModifiersTest.php | 16 -- .../Functional/Driver/SQLServer/TableTest.php | 16 -- .../Driver/SQLServer/TypecastTest.php | 16 -- .../Functional/Driver/SQLite/ChildTest.php | 16 -- .../Driver/SQLite/GeneratedFieldsTest.php | 16 -- .../Driver/SQLite/GeneratorTest.php | 16 -- .../SQLite/Inheritance/JoinedTableTest.php | 16 -- .../SQLite/Inheritance/SingleTableTest.php | 16 -- .../Driver/SQLite/InheritanceTest.php | 16 -- .../Functional/Driver/SQLite/InvalidTest.php | 16 -- .../Driver/SQLite/Relation/BelongsToTest.php | 16 -- .../SQLite/Relation/CompositeKeysTest.php | 16 -- .../Driver/SQLite/Relation/EmbeddedTest.php | 16 -- .../Driver/SQLite/Relation/HasManyTest.php | 16 -- .../Driver/SQLite/Relation/HasOneTest.php | 16 -- .../Driver/SQLite/Relation/InverseTest.php | 16 -- .../Driver/SQLite/Relation/ManyToManyTest.php | 16 -- .../Relation/Morphed/BelongsToMorphedTest.php | 16 -- .../Relation/Morphed/MorphedHasManyTest.php | 16 -- .../Relation/Morphed/MorphedHasOneTest.php | 16 -- .../Relation/Morphed/RefersToMorphedTest.php | 16 -- .../Driver/SQLite/Relation/RefersToTest.php | 16 -- .../Driver/SQLite/SchemaModifiersTest.php | 16 -- .../Functional/Driver/SQLite/TableTest.php | 16 -- .../Functional/Driver/SQLite/TypecastTest.php | 16 -- tests/Annotated/Traits/TableTrait.php | 80 ------- tests/Annotated/Unit/Attribute/ColumnTest.php | 59 ++--- .../Attribute/SingleTable/SingleTableTest.php | 11 +- .../Locator/TokenizerEmbeddingLocatorTest.php | 18 +- .../Locator/TokenizerEntityLocatorTest.php | 18 +- tests/Annotated/Unit/ReaderFactoryTest.php | 15 +- .../Annotated/Unit/Utils/EntityUtilsTest.php | 17 +- tests/Annotated/Util/TableRenderer.php | 193 ---------------- tests/bootstrap.php | 60 ----- tests/docker-compose.yml | 29 --- tests/fix-binlog.sh | 5 - tests/generate.php | 113 --------- tests/install-pgsql-10.sh | 9 - tests/install-sqlsrv.sh | 7 - 131 files changed, 1078 insertions(+), 3163 deletions(-) create mode 100644 tests/Annotated/Feature/BaseTestCase.php rename tests/Annotated/{Functional/Driver/Common/ChildTestCase.php => Feature/Common/ChildTest.php} (80%) rename tests/Annotated/{Functional/Driver/Common/CompositePkGeneratedTestCase.php => Feature/Common/CompositePkGeneratedTest.php} (75%) rename tests/Annotated/{Functional/Driver/Common/GeneratedFieldsTestCase.php => Feature/Common/GeneratedFieldsTest.php} (71%) create mode 100644 tests/Annotated/Feature/Common/GeneratorTest.php rename tests/Annotated/{Functional/Driver/Common/Inheritance/JoinedTableTestCase.php => Feature/Common/Inheritance/JoinedTableTest.php} (63%) rename tests/Annotated/{Functional/Driver/Common/Inheritance/SingleTableTestCase.php => Feature/Common/Inheritance/SingleTableTest.php} (53%) rename tests/Annotated/{Functional/Driver/Common/InheritanceTestCase.php => Feature/Common/InheritanceTest.php} (54%) rename tests/Annotated/{Functional/Driver/Common/InvalidTestCase.php => Feature/Common/InvalidTest.php} (80%) rename tests/Annotated/{Functional/Driver/Common/Relation/BelongsToTestCase.php => Feature/Common/Relation/BelongsToTest.php} (64%) rename tests/Annotated/{Functional/Driver/Common/Relation/CompositeKeysTestCase.php => Feature/Common/Relation/CompositeKeysTest.php} (76%) rename tests/Annotated/{Functional/Driver/Common/Relation/EmbeddedTestCase.php => Feature/Common/Relation/EmbeddedTest.php} (66%) rename tests/Annotated/{Functional/Driver/Common/Relation/HasManyTestCase.php => Feature/Common/Relation/HasManyTest.php} (65%) rename tests/Annotated/{Functional/Driver/Common/Relation/HasOneTestCase.php => Feature/Common/Relation/HasOneTest.php} (66%) create mode 100644 tests/Annotated/Feature/Common/Relation/InverseTest.php rename tests/Annotated/{Functional/Driver/Common/Relation/ManyToManyTestCase.php => Feature/Common/Relation/ManyToManyTest.php} (91%) rename tests/Annotated/{Functional/Driver/Common/Relation/Morphed/BelongsToMorphedTestCase.php => Feature/Common/Relation/Morphed/BelongsToMorphedTest.php} (63%) rename tests/Annotated/{Functional/Driver/Common/Relation/Morphed/MorphedHasManyTestCase.php => Feature/Common/Relation/Morphed/MorphedHasManyTest.php} (53%) rename tests/Annotated/{Functional/Driver/Common/Relation/Morphed/MorphedHasOneTestCase.php => Feature/Common/Relation/Morphed/MorphedHasOneTest.php} (64%) rename tests/Annotated/{Functional/Driver/Common/Relation/Morphed/RefersToMorphedTestCase.php => Feature/Common/Relation/Morphed/RefersToMorphedTest.php} (62%) rename tests/Annotated/{Functional/Driver/Common/Relation/RefersToTestCase.php => Feature/Common/Relation/RefersToTest.php} (65%) rename tests/Annotated/{Functional/Driver/Common/SchemaModifiersTestCase.php => Feature/Common/SchemaModifiersTest.php} (72%) rename tests/Annotated/{Functional/Driver/Common/TableTestCase.php => Feature/Common/TableTest.php} (67%) rename tests/Annotated/{Functional/Driver/Common/TypecastTestCase.php => Feature/Common/TypecastTest.php} (79%) rename tests/Annotated/{Functional/Driver => Feature}/MySQL/TableTest.php (56%) rename tests/Annotated/{Functional/Driver => Feature}/Postgres/GeneratedFieldsTest.php (60%) delete mode 100644 tests/Annotated/Fixtures/Fixtures1/TestLogger.php delete mode 100644 tests/Annotated/Functional/Driver/Common/BaseTestCase.php delete mode 100644 tests/Annotated/Functional/Driver/Common/GeneratorTestCase.php delete mode 100644 tests/Annotated/Functional/Driver/Common/Relation/InverseTestCase.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/ChildTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/GeneratedFieldsTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/GeneratorTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Inheritance/JoinedTableTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Inheritance/SingleTableTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/InheritanceTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/InvalidTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/BelongsToTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/CompositeKeysTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/EmbeddedTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/HasManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/HasOneTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/InverseTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/ManyToManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/Morphed/BelongsToMorphedTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/Morphed/MorphedHasManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/Morphed/MorphedHasOneTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/Morphed/RefersToMorphedTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/Relation/RefersToTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/SchemaModifiersTest.php delete mode 100644 tests/Annotated/Functional/Driver/MySQL/TypecastTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/ChildTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/CompositePkGeneratedTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/GeneratorTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Inheritance/JoinedTableTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Inheritance/SingleTableTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/InheritanceTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/InvalidTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/BelongsToTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/CompositeKeysTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/EmbeddedTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/HasManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/HasOneTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/InverseTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/ManyToManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/Morphed/BelongsToMorphedTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/Morphed/MorphedHasManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/Morphed/MorphedHasOneTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/Morphed/RefersToMorphedTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/Relation/RefersToTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/SchemaModifiersTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/TableTest.php delete mode 100644 tests/Annotated/Functional/Driver/Postgres/TypecastTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/ChildTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/GeneratedFieldsTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/GeneratorTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Inheritance/JoinedTableTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Inheritance/SingleTableTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/InheritanceTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/InvalidTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/BelongsToTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/CompositeKeysTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/EmbeddedTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/HasManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/HasOneTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/InverseTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/ManyToManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/Morphed/BelongsToMorphedTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/Morphed/MorphedHasManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/Morphed/MorphedHasOneTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/Morphed/RefersToMorphedTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/Relation/RefersToTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/SchemaModifiersTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/TableTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLServer/TypecastTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/ChildTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/GeneratedFieldsTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/GeneratorTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Inheritance/JoinedTableTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Inheritance/SingleTableTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/InheritanceTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/InvalidTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/BelongsToTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/CompositeKeysTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/EmbeddedTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/HasManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/HasOneTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/InverseTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/ManyToManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/Morphed/BelongsToMorphedTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/Morphed/MorphedHasManyTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/Morphed/MorphedHasOneTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/Morphed/RefersToMorphedTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/Relation/RefersToTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/SchemaModifiersTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/TableTest.php delete mode 100644 tests/Annotated/Functional/Driver/SQLite/TypecastTest.php delete mode 100644 tests/Annotated/Traits/TableTrait.php delete mode 100644 tests/Annotated/Util/TableRenderer.php delete mode 100644 tests/bootstrap.php delete mode 100644 tests/docker-compose.yml delete mode 100644 tests/fix-binlog.sh delete mode 100644 tests/generate.php delete mode 100644 tests/install-pgsql-10.sh delete mode 100644 tests/install-sqlsrv.sh diff --git a/tests/Annotated/Feature/BaseTestCase.php b/tests/Annotated/Feature/BaseTestCase.php new file mode 100644 index 00000000..29077f8b --- /dev/null +++ b/tests/Annotated/Feature/BaseTestCase.php @@ -0,0 +1,42 @@ + [new AnnotationReader()]; + yield 'Attribute reader' => [new AttributeReader()]; + } + + public static function allReadersProvider(): \Traversable + { + yield from static::singularReadersProvider(); + yield 'Selective reader' => [new SelectiveReader([new AttributeReader(), new AnnotationReader()])]; + } + + #[BeforeTest] + public function initLocator(): void + { + $tokenizer = new Tokenizer(new TokenizerConfig([ + 'directories' => [__DIR__ . '/../Fixtures/Fixtures1'], + 'exclude' => [], + ])); + + $this->locator = $tokenizer->classLocator(); + } +} diff --git a/tests/Annotated/Functional/Driver/Common/ChildTestCase.php b/tests/Annotated/Feature/Common/ChildTest.php similarity index 80% rename from tests/Annotated/Functional/Driver/Common/ChildTestCase.php rename to tests/Annotated/Feature/Common/ChildTest.php index e5089752..f086a075 100644 --- a/tests/Annotated/Functional/Driver/Common/ChildTestCase.php +++ b/tests/Annotated/Feature/Common/ChildTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common; +namespace Cycle\Annotated\Tests\Feature\Common; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -10,6 +10,7 @@ use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Child; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Simple; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Third; @@ -23,12 +24,14 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class ChildTestCase extends BaseTestCase +final class ChildTest extends BaseTestCase { // /** // * @dataProvider allReadersProvider @@ -52,12 +55,12 @@ abstract class ChildTestCase extends BaseTestCase // $this->assertSame([Schema::ROLE => 'simple'], $schema[Third::class]); // } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelationToChild(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures8'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures8'], 'exclude' => [], ])); @@ -78,9 +81,9 @@ public function testRelationToChild(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::array($schema['some'][Schema::RELATIONS])->hasKeys('article'); - \Testo\Assert::same($schema['some'][Schema::RELATIONS]['article'][Relation::TYPE], Relation::HAS_ONE); + Assert::array($schema['some'][Schema::RELATIONS])->hasKeys('article'); + Assert::same($schema['some'][Schema::RELATIONS]['article'][Relation::TYPE], Relation::HAS_ONE); - \Testo\Assert::same($schema['some'][Schema::RELATIONS]['article'][Relation::TARGET], 'post'); + Assert::same($schema['some'][Schema::RELATIONS]['article'][Relation::TARGET], 'post'); } } diff --git a/tests/Annotated/Functional/Driver/Common/CompositePkGeneratedTestCase.php b/tests/Annotated/Feature/Common/CompositePkGeneratedTest.php similarity index 75% rename from tests/Annotated/Functional/Driver/Common/CompositePkGeneratedTestCase.php rename to tests/Annotated/Feature/Common/CompositePkGeneratedTest.php index c2f7552a..fbd5eb33 100644 --- a/tests/Annotated/Functional/Driver/Common/CompositePkGeneratedTestCase.php +++ b/tests/Annotated/Feature/Common/CompositePkGeneratedTest.php @@ -2,12 +2,13 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common; +namespace Cycle\Annotated\Tests\Feature\Common; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures28\Event; use Cycle\ORM\Config\RelationConfig; use Cycle\ORM\EntityManager; @@ -25,10 +26,14 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; +use Cycle\Testing\Database\Attribute\OnlyDriver; +use Cycle\Testing\Database\Driver; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; /** * Composite primary key where one part is application-supplied (uuid) and the @@ -36,29 +41,30 @@ * * Mirrors cycle/orm "Case8" but driven entirely by attributes/annotations. * The round-trip relies on a driver implementing ReturningInterface - * (PostgreSQL, SQL Server), so it lives in those driver suites. + * (PostgreSQL, SQL Server), so it runs only on those drivers. */ -abstract class CompositePkGeneratedTestCase extends BaseTestCase +#[OnlyDriver(Driver::Postgres, Driver::SQLServer)] +final class CompositePkGeneratedTest extends BaseTestCase { /** * The composite PK and the database-generated component must be derived * from the attributes alone. */ - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testCompositePkSchema(ReaderInterface $reader): void { $schema = $this->compile($reader); - \Testo\Assert::same($schema['event'][SchemaInterface::PRIMARY_KEY], ['parentId', 'id']); - \Testo\Assert::same($schema['event'][SchemaInterface::COLUMNS], ['parentId' => 'parent_id', 'id' => 'id', 'payload' => 'payload']); + Assert::same($schema['event'][SchemaInterface::PRIMARY_KEY], ['parentId', 'id']); + Assert::same($schema['event'][SchemaInterface::COLUMNS], ['parentId' => 'parent_id', 'id' => 'id', 'payload' => 'payload']); // Both primary columns are flagged ON_INSERT: the bigserial `id` is // genuinely database-generated, while the app-supplied uuid `parentId` // is auto-flagged purely because it is primary (see Event::$parentId // and Configurator::isOnInsertGeneratedField()). The parentId flag only // echoes the value back via RETURNING — harmless for a uuid string. - \Testo\Assert::same($schema['event'][SchemaInterface::GENERATED_FIELDS], [ + Assert::same($schema['event'][SchemaInterface::GENERATED_FIELDS], [ 'parentId' => GeneratedField::ON_INSERT, 'id' => GeneratedField::ON_INSERT, ]); @@ -69,8 +75,8 @@ public function testCompositePkSchema(ReaderInterface $reader): void * database-generated ids returned on INSERT, and can be fetched back by * the full composite key. */ - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testCreateGeneratesIdAndFetchByCompositePk(ReaderInterface $reader): void { $orm = new ORM( @@ -91,9 +97,9 @@ public function testCreateGeneratesIdAndFetchByCompositePk(ReaderInterface $read (new EntityManager($orm))->persist($first)->persist($second)->run(); // database-generated ids - \Testo\Assert::int($first->id); - \Testo\Assert::int($second->id); - \Testo\Assert::notSame($second->id, $first->id); + Assert::int($first->id); + Assert::int($second->id); + Assert::notSame($second->id, $first->id); // fetch by the full composite key $found = (new Select($orm, Event::class)) @@ -101,15 +107,15 @@ public function testCreateGeneratesIdAndFetchByCompositePk(ReaderInterface $read ->where('id', $second->id) ->fetchOne(); - \Testo\Assert::notNull($found); - \Testo\Assert::same($found->payload, 'second'); - \Testo\Assert::same($found, $second, 'Heap returns the same identity for the composite key.'); + Assert::notNull($found); + Assert::same($found->payload, 'second'); + Assert::same($found, $second, 'Heap returns the same identity for the composite key.'); } private function compile(ReaderInterface $reader): array { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures28'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures28'], 'exclude' => [], ])); diff --git a/tests/Annotated/Functional/Driver/Common/GeneratedFieldsTestCase.php b/tests/Annotated/Feature/Common/GeneratedFieldsTest.php similarity index 71% rename from tests/Annotated/Functional/Driver/Common/GeneratedFieldsTestCase.php rename to tests/Annotated/Feature/Common/GeneratedFieldsTest.php index b4f1f1b6..a41dd551 100644 --- a/tests/Annotated/Functional/Driver/Common/GeneratedFieldsTestCase.php +++ b/tests/Annotated/Feature/Common/GeneratedFieldsTest.php @@ -2,27 +2,30 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common; +namespace Cycle\Annotated\Tests\Feature\Common; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\ORM\Schema\GeneratedField; use Cycle\ORM\SchemaInterface; use Cycle\Schema\Compiler; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class GeneratedFieldsTestCase extends BaseTestCase +final class GeneratedFieldsTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testGeneratedFields(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures25'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures25'], 'exclude' => ['PostgreSQL'], ])); @@ -33,7 +36,7 @@ public function testGeneratedFields(ReaderInterface $reader): void new Entities(new TokenizerEntityLocator($locator, $reader), $reader), ]); - \Testo\Assert::same($schema['withGeneratedFields'][SchemaInterface::GENERATED_FIELDS], [ + Assert::same($schema['withGeneratedFields'][SchemaInterface::GENERATED_FIELDS], [ 'id' => GeneratedField::ON_INSERT, 'createdAt' => GeneratedField::BEFORE_INSERT, 'createdAtGeneratedByDatabase' => GeneratedField::ON_INSERT, diff --git a/tests/Annotated/Feature/Common/GeneratorTest.php b/tests/Annotated/Feature/Common/GeneratorTest.php new file mode 100644 index 00000000..fc1e4e1d --- /dev/null +++ b/tests/Annotated/Feature/Common/GeneratorTest.php @@ -0,0 +1,156 @@ +dbal); + (new Entities(new TokenizerEntityLocator($this->locator)))->run($r); + + Assert::true($r->hasEntity(Simple::class)); + Assert::true($r->hasEntity(WithTable::class)); + Assert::true($r->hasEntity(Complete::class)); + } + + #[Test] + public function testCreateGeneratorsWithDoctrineAnnotationReader(): void + { + $reader = new DoctrineAnnotationReader(); + $r = new Registry($this->dbal); + + (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); + (new MergeColumns($reader))->run($r); + (new RenderTables())->run($r); + (new MergeIndexes($reader))->run($r); + (new SyncTables())->run($r); + + // Entities + Assert::true($r->hasEntity(Simple::class)); + Assert::true($r->hasEntity(WithTable::class)); + Assert::true($r->hasEntity(Complete::class)); + // MergeColumns + $schema = $r->getTableSchema($r->getEntity('withTable')); + Assert::true($schema->hasColumn('name')); + Assert::same($schema->column('status')->getType(), 'string'); + // MergeIndexes + Assert::true($schema->hasIndex(['name'])); + Assert::true($schema->index(['name'])->isUnique()); + Assert::same($schema->index(['name'])->getName(), 'name_index'); + } + + #[Test] + public function testCreateGeneratorsWithCustomMergeReader(): void + { + $reader = new MergeReader([new AnnotationReader(), new AttributeReader()]); + $r = new Registry($this->dbal); + + $tokenizer = new Tokenizer(new TokenizerConfig([ + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures10'], + 'exclude' => [], + ])); + $locator = $tokenizer->classLocator(); + + (new Entities(new TokenizerEntityLocator($locator, $reader), $reader))->run($r); + (new MergeColumns($reader))->run($r); + (new RenderTables())->run($r); + (new MergeIndexes($reader))->run($r); + (new SyncTables())->run($r); + + + Assert::true($r->hasTable($r->getEntity('MergedMeta'))); + $schema = $r->getTableSchema($r->getEntity('MergedMeta')); + Assert::true($schema->hasColumn('name')); + Assert::true($schema->hasIndex(['name', 'id DESC'])); + } + + #[DataProvider('allReadersProvider')] + #[Test] + public function testLocateAll(ReaderInterface $reader): void + { + $r = new Registry($this->dbal); + (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); + + Assert::true($r->hasEntity(Simple::class)); + Assert::true($r->hasEntity(WithTable::class)); + Assert::true($r->hasEntity(Complete::class)); + } + + #[DataProvider('allReadersProvider')] + #[Test] + public function testSimpleSchema(ReaderInterface $reader): void + { + $r = new Registry($this->dbal); + (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); + + Assert::true($r->hasEntity(Simple::class)); + Assert::true($r->hasEntity('simple')); + + Assert::same($r->getEntity('simple')->getMapper(), null); + Assert::same($r->getEntity('simple')->getRepository(), null); + + Assert::true($r->hasTable($r->getEntity('simple'))); + Assert::same($r->getDatabase($r->getEntity('simple')), 'default'); + Assert::same($r->getTable($r->getEntity('simple')), 'simples'); + + Assert::true($r->getEntity('simple')->getFields()->has('id')); + Assert::same($r->getEntity('simple')->getFields()->get('id')->getColumn(), 'id'); + } + + #[DataProvider('allReadersProvider')] + #[Test] + public function testCompleteSchema(ReaderInterface $reader): void + { + $r = new Registry($this->dbal); + (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); + + Assert::true($r->hasEntity(Complete::class)); + Assert::true($r->hasEntity('eComplete')); + + Assert::same($r->getEntity('eComplete')->getMapper(), CompleteMapper::class); + Assert::same($r->getEntity('eComplete')->getRepository(), CompleteRepository::class); + Assert::same($r->getEntity('eComplete')->getSource(), TestSource::class); + Assert::same($r->getEntity('eComplete')->getScope(), SomeConstrain::class); + + Assert::true($r->hasTable($r->getEntity('eComplete'))); + Assert::same($r->getDatabase($r->getEntity('eComplete')), 'secondary'); + Assert::same($r->getTable($r->getEntity('eComplete')), 'complete_data'); + + Assert::true($r->getEntity('eComplete')->getFields()->has('id')); + Assert::true($r->getEntity('eComplete')->getFields()->has('name')); + + Assert::same($r->getEntity('eComplete')->getFields()->get('name')->getColumn(), 'username'); + + Assert::false($r->getEntity('eComplete')->getFields()->has('ignored')); + } +} diff --git a/tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php b/tests/Annotated/Feature/Common/Inheritance/JoinedTableTest.php similarity index 63% rename from tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php rename to tests/Annotated/Feature/Common/Inheritance/JoinedTableTest.php index 30b213f1..49c8b301 100644 --- a/tests/Annotated/Functional/Driver/Common/Inheritance/JoinedTableTestCase.php +++ b/tests/Annotated/Feature/Common/Inheritance/JoinedTableTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Inheritance; +namespace Cycle\Annotated\Tests\Feature\Common\Inheritance; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -11,9 +11,8 @@ use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; use Cycle\Annotated\TableInheritance; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures16\Executive; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; -use Cycle\Annotated\Tests\Traits\TableTrait; use Cycle\Database\Schema\AbstractForeignKey; use Cycle\Database\Schema\AbstractIndex; use Cycle\ORM\EntityManager; @@ -27,17 +26,18 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; -abstract class JoinedTableTestCase extends BaseTestCase +final class JoinedTableTest extends BaseTestCase { - use TableTrait; - - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testTableInheritance(ReaderInterface $reader): void { $this->orm = $this->orm->with(new Schema($this->compile($reader))); @@ -58,17 +58,17 @@ public function testTableInheritance(ReaderInterface $reader): void $this->orm->getHeap()->clean(); $loadedExecutive = $this->orm->getRepository(Executive::class)->findByPK($executive->getFooId()); - \Testo\Assert::instanceOf($loadedExecutive, Executive::class); - \Testo\Assert::same($loadedExecutive->getName(), 'executive'); - \Testo\Assert::same($loadedExecutive->getSalary(), 50000); - \Testo\Assert::same($loadedExecutive->hidden, 'secret'); - \Testo\Assert::same($loadedExecutive->bonus, 15000); - \Testo\Assert::same($loadedExecutive->getType(), 'executive'); - \Testo\Assert::same($loadedExecutive->proxyFieldWithAnnotation, 'value'); + Assert::instanceOf($loadedExecutive, Executive::class); + Assert::same($loadedExecutive->getName(), 'executive'); + Assert::same($loadedExecutive->getSalary(), 50000); + Assert::same($loadedExecutive->hidden, 'secret'); + Assert::same($loadedExecutive->bonus, 15000); + Assert::same($loadedExecutive->getType(), 'executive'); + Assert::same($loadedExecutive->proxyFieldWithAnnotation, 'value'); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testAddForeignKeys(ReaderInterface $reader): void { $this->orm = $this->orm->with(new Schema($this->compile($reader))); @@ -79,38 +79,38 @@ public function testAddForeignKeys(ReaderInterface $reader): void $externalSuppliersFk = $db->table('external_suppliers')->getForeignKeys(); // simple case. Supplier -> Person - \Testo\Assert::count($suppliersFk, 1); - \Testo\Assert::instanceOf(reset($suppliersFk), AbstractForeignKey::class); - \Testo\Assert::same(reset($suppliersFk)->getForeignTable(), 'people'); - \Testo\Assert::same(reset($suppliersFk)->getForeignKeys(), ['id']); - \Testo\Assert::same(reset($suppliersFk)->getColumns(), ['id']); + Assert::count($suppliersFk, 1); + Assert::instanceOf(reset($suppliersFk), AbstractForeignKey::class); + Assert::same(reset($suppliersFk)->getForeignTable(), 'people'); + Assert::same(reset($suppliersFk)->getForeignKeys(), ['id']); + Assert::same(reset($suppliersFk)->getColumns(), ['id']); // Executive -> Employee (STI) -> Person - \Testo\Assert::count($executivesFk, 1); - \Testo\Assert::instanceOf(reset($executivesFk), AbstractForeignKey::class); - \Testo\Assert::same(reset($executivesFk)->getForeignTable(), 'people'); - \Testo\Assert::same(reset($executivesFk)->getForeignKeys(), ['id']); - \Testo\Assert::same(reset($executivesFk)->getColumns(), ['id']); + Assert::count($executivesFk, 1); + Assert::instanceOf(reset($executivesFk), AbstractForeignKey::class); + Assert::same(reset($executivesFk)->getForeignTable(), 'people'); + Assert::same(reset($executivesFk)->getForeignKeys(), ['id']); + Assert::same(reset($executivesFk)->getColumns(), ['id']); // ExternalSupplier -> Supplier (JTI) -> Person. With outerKey - \Testo\Assert::count($externalSuppliersFk, 1); - \Testo\Assert::instanceOf(reset($externalSuppliersFk), AbstractForeignKey::class); - \Testo\Assert::same(reset($externalSuppliersFk)->getForeignTable(), 'suppliers'); - \Testo\Assert::same(reset($externalSuppliersFk)->getForeignKeys(), ['custom_id']); - \Testo\Assert::same(reset($externalSuppliersFk)->getColumns(), ['id']); + Assert::count($externalSuppliersFk, 1); + Assert::instanceOf(reset($externalSuppliersFk), AbstractForeignKey::class); + Assert::same(reset($externalSuppliersFk)->getForeignTable(), 'suppliers'); + Assert::same(reset($externalSuppliersFk)->getForeignKeys(), ['custom_id']); + Assert::same(reset($externalSuppliersFk)->getColumns(), ['id']); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testNotAddForeignKey(ReaderInterface $reader): void { $this->orm = $this->orm->with(new Schema($this->compile($reader))); - \Testo\Assert::count($this->dbal->database()->table('buyers')->getForeignKeys(), 0); + Assert::count($this->dbal->database()->table('buyers')->getForeignKeys(), 0); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testAddIndex(ReaderInterface $reader): void { $this->orm = $this->orm->with(new Schema($this->compile($reader))); @@ -121,38 +121,36 @@ public function testAddIndex(ReaderInterface $reader): void $indexes = array_filter($indexes, fn(AbstractIndex $index) => $index->getColumns() !== ['id']); // one index added automatically, one added manual - \Testo\Assert::count($indexes, 2); + Assert::count($indexes, 2); - \Testo\Assert::true($this->dbal->database()->table('suppliers')->hasIndex(['index_id'])); - \Testo\Assert::true($this->dbal->database()->table('suppliers')->hasIndex(['custom_id'])); + Assert::true($this->dbal->database()->table('suppliers')->hasIndex(['index_id'])); + Assert::true($this->dbal->database()->table('suppliers')->hasIndex(['custom_id'])); - \Testo\Assert::true(reset($indexes)->isUnique()); - \Testo\Assert::true(end($indexes)->isUnique()); + Assert::true(reset($indexes)->isUnique()); + Assert::true(end($indexes)->isUnique()); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testJtiParentColumns(ReaderInterface $reader): void { $schema = $this->compile($reader, 'Fixtures21'); - \Testo\Assert::notBlank($schema); + Assert::notBlank($schema); - \Testo\Assert::array($schema['person'])->hasKeys(SchemaInterface::COLUMNS); + Assert::array($schema['person'])->hasKeys(SchemaInterface::COLUMNS); // assert that parent doesn't have jti columns - \Testo\Assert::equals($schema['person'][SchemaInterface::COLUMNS], [ + Assert::equals($schema['person'][SchemaInterface::COLUMNS], [ 'id' => 'id', 'name' => 'name', 'type' => 'type', ]); } - #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + #[BeforeTest] + public function createTables(): void { - parent::setUp(); - $this->makeTable( table: 'people', columns: [ @@ -215,7 +213,7 @@ private function compile(ReaderInterface $reader, string $fixtures = 'Fixtures16 { $tokenizer = new Tokenizer( new TokenizerConfig([ - 'directories' => [sprintf(__DIR__ . '/../../../../Fixtures/%s', $fixtures)], + 'directories' => [sprintf(__DIR__ . '/../../../Fixtures/%s', $fixtures)], 'exclude' => [], ]), ); diff --git a/tests/Annotated/Functional/Driver/Common/Inheritance/SingleTableTestCase.php b/tests/Annotated/Feature/Common/Inheritance/SingleTableTest.php similarity index 53% rename from tests/Annotated/Functional/Driver/Common/Inheritance/SingleTableTestCase.php rename to tests/Annotated/Feature/Common/Inheritance/SingleTableTest.php index 92081f91..263d9bbd 100644 --- a/tests/Annotated/Functional/Driver/Common/Inheritance/SingleTableTestCase.php +++ b/tests/Annotated/Feature/Common/Inheritance/SingleTableTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Inheritance; +namespace Cycle\Annotated\Tests\Feature\Common\Inheritance; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -11,12 +11,11 @@ use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; use Cycle\Annotated\TableInheritance; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures16\Ceo; use Cycle\Annotated\Tests\Fixtures\Fixtures16\Customer; use Cycle\Annotated\Tests\Fixtures\Fixtures16\Employee; use Cycle\Annotated\Tests\Fixtures\Fixtures16\Person; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; -use Cycle\Annotated\Tests\Traits\TableTrait; use Cycle\ORM\EntityManager; use Cycle\ORM\Mapper\Mapper; use Cycle\ORM\Relation; @@ -33,28 +32,29 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Lifecycle\BeforeTest; +use Testo\Test; -abstract class SingleTableTestCase extends BaseTestCase +final class SingleTableTest extends BaseTestCase { - use TableTrait; - public static function columnDeclarationDataProvider(): \Traversable { // Declaration via Column in the property - yield [__DIR__ . '/../../../../Fixtures/Fixtures23/STIWithPropertyColumn', 'STIWithPropertyColumn']; + yield [__DIR__ . '/../../../Fixtures/Fixtures23/STIWithPropertyColumn', 'STIWithPropertyColumn']; // Declaration via Column in the class - yield [__DIR__ . '/../../../../Fixtures/Fixtures23/STIWithClassColumn', 'STIWithClassColumn']; + yield [__DIR__ . '/../../../Fixtures/Fixtures23/STIWithClassColumn', 'STIWithClassColumn']; // Declaration via Table in the class - yield [__DIR__ . '/../../../../Fixtures/Fixtures23/STIWithTableColumn', 'STIWithTableColumn']; + yield [__DIR__ . '/../../../Fixtures/Fixtures23/STIWithTableColumn', 'STIWithTableColumn']; // Declaration via columns in the Entity - yield [__DIR__ . '/../../../../Fixtures/Fixtures23/STIWithEntityColumn', 'STIWithEntityColumn']; + yield [__DIR__ . '/../../../Fixtures/Fixtures23/STIWithEntityColumn', 'STIWithEntityColumn']; } /** @@ -62,8 +62,8 @@ public static function columnDeclarationDataProvider(): \Traversable */ public static function columnDeclarationWithReadersDataProvider(): \Traversable { - $readers = \iterator_to_array(static::allReadersProvider(), false); - $declarations = \iterator_to_array(static::columnDeclarationDataProvider()); + $readers = \iterator_to_array(self::allReadersProvider(), false); + $declarations = \iterator_to_array(self::columnDeclarationDataProvider()); foreach ($readers as $reader) { foreach ($declarations as $declaration) { yield \array_merge($declaration, $reader); @@ -71,13 +71,13 @@ public static function columnDeclarationWithReadersDataProvider(): \Traversable } } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testTableInheritance(ReaderInterface $reader): void { $tokenizer = new Tokenizer( new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures16'], + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures16'], 'exclude' => [], ]), ); @@ -135,43 +135,43 @@ public function testTableInheritance(ReaderInterface $reader): void $this->orm->getHeap()->clean(); - \Testo\Assert::notNull($person->getFooId()); + Assert::notNull($person->getFooId()); $loadedPerson = $this->orm->getRepository(Person::class)->findByPK($person->getFooId()); - \Testo\Assert::instanceOf($loadedPerson, Person::class); - \Testo\Assert::same($loadedPerson->name, 'baz'); - \Testo\Assert::false(isset($loadedPerson->preferences)); - \Testo\Assert::false(isset($loadedPerson->salary)); + Assert::instanceOf($loadedPerson, Person::class); + Assert::same($loadedPerson->name, 'baz'); + Assert::false(isset($loadedPerson->preferences)); + Assert::false(isset($loadedPerson->salary)); - \Testo\Assert::notNull($employee->getFooId()); + Assert::notNull($employee->getFooId()); $loadedEmployee = $this->orm->getRepository(Person::class)->findByPK($employee->getFooId()); - \Testo\Assert::instanceOf($loadedEmployee, Employee::class); - \Testo\Assert::same($loadedEmployee->name, 'foo'); - \Testo\Assert::same($loadedEmployee->salary, 12500); - \Testo\Assert::same($loadedEmployee->bar, 'test'); - \Testo\Assert::false(isset($loadedEmployee->preferences)); + Assert::instanceOf($loadedEmployee, Employee::class); + Assert::same($loadedEmployee->name, 'foo'); + Assert::same($loadedEmployee->salary, 12500); + Assert::same($loadedEmployee->bar, 'test'); + Assert::false(isset($loadedEmployee->preferences)); - \Testo\Assert::notNull($customer->getFooId()); + Assert::notNull($customer->getFooId()); $loadedCustomer = $this->orm->getRepository(Person::class)->findByPK($customer->getFooId()); - \Testo\Assert::instanceOf($loadedCustomer, Customer::class); - \Testo\Assert::same($loadedCustomer->name, 'baz'); - \Testo\Assert::same($loadedCustomer->preferences, 'private'); - \Testo\Assert::false(isset($loadedCustomer->salary)); + Assert::instanceOf($loadedCustomer, Customer::class); + Assert::same($loadedCustomer->name, 'baz'); + Assert::same($loadedCustomer->preferences, 'private'); + Assert::false(isset($loadedCustomer->salary)); - \Testo\Assert::notNull($ceo->getFooId()); + Assert::notNull($ceo->getFooId()); $loadedCeo = $this->orm->getRepository(Ceo::class)->findByPK($ceo->getFooId()); - \Testo\Assert::instanceOf($loadedCeo, Ceo::class); - \Testo\Assert::same($loadedCeo->name, 'ceo'); - \Testo\Assert::same($loadedCeo->salary, 150000); - \Testo\Assert::same($loadedCeo->stocks, 1000); + Assert::instanceOf($loadedCeo, Ceo::class); + Assert::same($loadedCeo->name, 'ceo'); + Assert::same($loadedCeo->salary, 150000); + Assert::same($loadedCeo->stocks, 1000); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testTableInheritanceSchema(ReaderInterface $reader): void { $tokenizer = new Tokenizer( new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures20'], + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures20'], 'exclude' => [], ]), ); @@ -193,18 +193,18 @@ public function testTableInheritanceSchema(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::notBlank($schema); + Assert::notBlank($schema); - \Testo\Assert::array($schema['person'])->hasKeys(SchemaInterface::CHILDREN); - \Testo\Assert::array($schema['person'])->hasKeys(SchemaInterface::DISCRIMINATOR); - \Testo\Assert::same($schema['person'][SchemaInterface::DISCRIMINATOR], 'type'); + Assert::array($schema['person'])->hasKeys(SchemaInterface::CHILDREN); + Assert::array($schema['person'])->hasKeys(SchemaInterface::DISCRIMINATOR); + Assert::same($schema['person'][SchemaInterface::DISCRIMINATOR], 'type'); - \Testo\Assert::array($schema['buyer'])->hasKeys(SchemaInterface::PARENT); - \Testo\Assert::array($schema['buyer'])->hasKeys(SchemaInterface::PARENT_KEY); + Assert::array($schema['buyer'])->hasKeys(SchemaInterface::PARENT); + Assert::array($schema['buyer'])->hasKeys(SchemaInterface::PARENT_KEY); } - #[\Testo\Data\DataProvider('columnDeclarationWithReadersDataProvider')] - #[\Testo\Test] + #[DataProvider('columnDeclarationWithReadersDataProvider')] + #[Test] public function testSingleTableInheritanceWithDifferentColumnDeclaration( string $directory, string $namespace, @@ -234,41 +234,41 @@ public function testSingleTableInheritanceWithDifferentColumnDeclaration( new GenerateTypecast(), ]); - \Testo\Assert::notBlank($schema); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::ENTITY], \sprintf( + Assert::notBlank($schema); + Assert::same($schema['baseEvent'][SchemaInterface::ENTITY], \sprintf( 'Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\BaseEvent', $namespace, )); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::MAPPER], Mapper::class); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::SOURCE], Source::class); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::REPOSITORY], Repository::class); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::DATABASE], 'default'); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::TABLE], 'base_events'); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::PRIMARY_KEY], ['id']); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::FIND_BY_KEYS], ['id']); - \Testo\Assert::count($schema['baseEvent'][SchemaInterface::COLUMNS], 4); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['id'], 'id'); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['action'], 'action'); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['object_id'], 'object_id'); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['object_type'], 'object_type'); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::TYPE], Relation::BELONGS_TO_MORPHED); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::TARGET], \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\EventEmitterInterface', $namespace)); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::LOAD], Relation::LOAD_PROMISE); - \Testo\Assert::true($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::CASCADE]); - \Testo\Assert::true($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::NULLABLE]); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::OUTER_KEY], ['id']); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::INNER_KEY], 'object_id'); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::MORPH_KEY], 'object_type'); - \Testo\Assert::count($schema['baseEvent'][SchemaInterface::CHILDREN], 2); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::CHILDREN]['comment.created'], \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentCreated', $namespace)); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::CHILDREN]['comment.updated'], \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentUpdated', $namespace)); - \Testo\Assert::null($schema['baseEvent'][SchemaInterface::SCOPE]); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::TYPECAST]['id'], 'int'); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::TYPECAST]['object_id'], 'int'); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::SCHEMA], []); - \Testo\Assert::same($schema['baseEvent'][SchemaInterface::DISCRIMINATOR], 'action'); - \Testo\Assert::null($schema['baseEvent'][SchemaInterface::TYPECAST_HANDLER]); - \Testo\Assert::same($schema['comment'], [ + Assert::same($schema['baseEvent'][SchemaInterface::MAPPER], Mapper::class); + Assert::same($schema['baseEvent'][SchemaInterface::SOURCE], Source::class); + Assert::same($schema['baseEvent'][SchemaInterface::REPOSITORY], Repository::class); + Assert::same($schema['baseEvent'][SchemaInterface::DATABASE], 'default'); + Assert::same($schema['baseEvent'][SchemaInterface::TABLE], 'base_events'); + Assert::same($schema['baseEvent'][SchemaInterface::PRIMARY_KEY], ['id']); + Assert::same($schema['baseEvent'][SchemaInterface::FIND_BY_KEYS], ['id']); + Assert::count($schema['baseEvent'][SchemaInterface::COLUMNS], 4); + Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['id'], 'id'); + Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['action'], 'action'); + Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['object_id'], 'object_id'); + Assert::same($schema['baseEvent'][SchemaInterface::COLUMNS]['object_type'], 'object_type'); + Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::TYPE], Relation::BELONGS_TO_MORPHED); + Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::TARGET], \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\EventEmitterInterface', $namespace)); + Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::LOAD], Relation::LOAD_PROMISE); + Assert::true($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::CASCADE]); + Assert::true($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::NULLABLE]); + Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::OUTER_KEY], ['id']); + Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::INNER_KEY], 'object_id'); + Assert::same($schema['baseEvent'][SchemaInterface::RELATIONS]['object'][Relation::SCHEMA][Relation::MORPH_KEY], 'object_type'); + Assert::count($schema['baseEvent'][SchemaInterface::CHILDREN], 2); + Assert::same($schema['baseEvent'][SchemaInterface::CHILDREN]['comment.created'], \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentCreated', $namespace)); + Assert::same($schema['baseEvent'][SchemaInterface::CHILDREN]['comment.updated'], \sprintf('Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentUpdated', $namespace)); + Assert::null($schema['baseEvent'][SchemaInterface::SCOPE]); + Assert::same($schema['baseEvent'][SchemaInterface::TYPECAST]['id'], 'int'); + Assert::same($schema['baseEvent'][SchemaInterface::TYPECAST]['object_id'], 'int'); + Assert::same($schema['baseEvent'][SchemaInterface::SCHEMA], []); + Assert::same($schema['baseEvent'][SchemaInterface::DISCRIMINATOR], 'action'); + Assert::null($schema['baseEvent'][SchemaInterface::TYPECAST_HANDLER]); + Assert::same($schema['comment'], [ SchemaInterface::ENTITY => \sprintf( 'Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\Comment', $namespace, @@ -300,13 +300,13 @@ public function testSingleTableInheritanceWithDifferentColumnDeclaration( 'id' => GeneratedField::ON_INSERT, ], ]); - \Testo\Assert::same($schema['commentCreated'], [ + Assert::same($schema['commentCreated'], [ SchemaInterface::ENTITY => \sprintf( 'Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentCreated', $namespace, ), ]); - \Testo\Assert::same($schema['commentUpdated'], [ + Assert::same($schema['commentUpdated'], [ SchemaInterface::ENTITY => \sprintf( 'Cycle\Annotated\Tests\Fixtures\Fixtures23\%s\CommentUpdated', $namespace, @@ -314,11 +314,9 @@ public function testSingleTableInheritanceWithDifferentColumnDeclaration( ]); } - #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void + #[BeforeTest] + public function createTables(): void { - parent::setUp(); - $this->makeTable('people', [ 'id' => 'primary', 'type' => 'string', diff --git a/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php b/tests/Annotated/Feature/Common/InheritanceTest.php similarity index 54% rename from tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php rename to tests/Annotated/Feature/Common/InheritanceTest.php index 066df6a8..43b18434 100644 --- a/tests/Annotated/Functional/Driver/Common/InheritanceTestCase.php +++ b/tests/Annotated/Feature/Common/InheritanceTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common; +namespace Cycle\Annotated\Tests\Feature\Common; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -11,6 +11,7 @@ use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; use Cycle\Annotated\TableInheritance; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures16\Ceo; use Cycle\Annotated\Tests\Fixtures\Fixtures16\Customer; use Cycle\Annotated\Tests\Fixtures\Fixtures16\Employee; @@ -43,22 +44,24 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; +use Cycle\Testing\ORM\Schema\ClassList; use Spiral\Attributes\AttributeReader; use Spiral\Attributes\ReaderInterface; -use Spiral\Tokenizer\ClassesInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class InheritanceTestCase extends BaseTestCase +final class InheritanceTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testTableInheritance(ReaderInterface $reader): void { $tokenizer = new Tokenizer( new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures16'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures16'], 'exclude' => [__DIR__ . '/Fixtures16/CatWithoutParent.php'], ]), ); @@ -89,17 +92,17 @@ public function testTableInheritance(ReaderInterface $reader): void // Beaver - Separate table // Tool - \Testo\Assert::array($schema)->hasKeys('tool'); + Assert::array($schema)->hasKeys('tool'); // Person - \Testo\Assert::count($schema['person'][SchemaInterface::CHILDREN], 3); - \Testo\Assert::equals($schema['person'][SchemaInterface::CHILDREN], [ + Assert::count($schema['person'][SchemaInterface::CHILDREN], 3); + Assert::equals($schema['person'][SchemaInterface::CHILDREN], [ 'employee' => Employee::class, 'foo_customer' => Customer::class, 'ceo' => Ceo::class, ]); - \Testo\Assert::same($schema['person'][SchemaInterface::DISCRIMINATOR], 'type'); - \Testo\Assert::equals($schema['person'][SchemaInterface::COLUMNS], [ + Assert::same($schema['person'][SchemaInterface::DISCRIMINATOR], 'type'); + Assert::equals($schema['person'][SchemaInterface::COLUMNS], [ 'foo_id' => 'id', 'name' => 'name', 'type' => 'type', @@ -111,58 +114,58 @@ public function testTableInheritance(ReaderInterface $reader): void 'tool_id' => 'tool_id', // 'teethAmount' => 'teeth_amount', // Not child ]); - $this->assertEmpty($schema['person'][SchemaInterface::PARENT] ?? null); - $this->assertEmpty($schema['person'][SchemaInterface::PARENT_KEY] ?? null); - \Testo\Assert::same($schema['person'][SchemaInterface::TABLE], 'people'); - \Testo\Assert::count($schema['person'][SchemaInterface::RELATIONS], 1); + Assert::blank($schema['person'][SchemaInterface::PARENT] ?? null); + Assert::blank($schema['person'][SchemaInterface::PARENT_KEY] ?? null); + Assert::same($schema['person'][SchemaInterface::TABLE], 'people'); + Assert::count($schema['person'][SchemaInterface::RELATIONS], 1); // Employee - \Testo\Assert::array($schema)->hasKeys('employee'); - \Testo\Assert::count($schema['employee'], 1); - \Testo\Assert::same($schema['employee'][SchemaInterface::ENTITY], Employee::class); - \Testo\Assert::null($schema['employee'][SchemaInterface::TABLE] ?? null); - \Testo\Assert::count($schema['employee'][SchemaInterface::RELATIONS] ?? [], 0); + Assert::array($schema)->hasKeys('employee'); + Assert::count($schema['employee'], 1); + Assert::same($schema['employee'][SchemaInterface::ENTITY], Employee::class); + Assert::null($schema['employee'][SchemaInterface::TABLE] ?? null); + Assert::count($schema['employee'][SchemaInterface::RELATIONS] ?? [], 0); // Customer - \Testo\Assert::array($schema)->hasKeys('customer'); - \Testo\Assert::count($schema['customer'], 1); - \Testo\Assert::same($schema['customer'][SchemaInterface::ENTITY], Customer::class); - \Testo\Assert::null($schema['customer'][SchemaInterface::TABLE] ?? null); - \Testo\Assert::count($schema['customer'][SchemaInterface::RELATIONS] ?? [], 0); + Assert::array($schema)->hasKeys('customer'); + Assert::count($schema['customer'], 1); + Assert::same($schema['customer'][SchemaInterface::ENTITY], Customer::class); + Assert::null($schema['customer'][SchemaInterface::TABLE] ?? null); + Assert::count($schema['customer'][SchemaInterface::RELATIONS] ?? [], 0); // Executive - \Testo\Assert::same($schema['executive'][SchemaInterface::PARENT], 'employee'); - \Testo\Assert::same($schema['executive'][SchemaInterface::PARENT_KEY], 'foo_id'); - \Testo\Assert::same($schema['executive'][SchemaInterface::TABLE], 'executives'); - \Testo\Assert::equals($schema['executive'][SchemaInterface::COLUMNS], [ + Assert::same($schema['executive'][SchemaInterface::PARENT], 'employee'); + Assert::same($schema['executive'][SchemaInterface::PARENT_KEY], 'foo_id'); + Assert::same($schema['executive'][SchemaInterface::TABLE], 'executives'); + Assert::equals($schema['executive'][SchemaInterface::COLUMNS], [ 'bonus' => 'bonus', 'proxyFieldWithAnnotation' => 'proxy', 'foo_id' => 'id', 'hidden' => 'hidden', 'added_tool_id' => 'added_tool_id', ]); - \Testo\Assert::count($schema['executive'][SchemaInterface::RELATIONS], 1); + Assert::count($schema['executive'][SchemaInterface::RELATIONS], 1); // Executive2 - \Testo\Assert::same($schema['executive2'][SchemaInterface::PARENT], 'executive'); - \Testo\Assert::same($schema['executive2'][SchemaInterface::PARENT_KEY], 'foo_id'); - \Testo\Assert::equals($schema['executive2'][SchemaInterface::COLUMNS], ['foo_id' => 'id']); - \Testo\Assert::count($schema['executive2'][SchemaInterface::RELATIONS], 0); + Assert::same($schema['executive2'][SchemaInterface::PARENT], 'executive'); + Assert::same($schema['executive2'][SchemaInterface::PARENT_KEY], 'foo_id'); + Assert::equals($schema['executive2'][SchemaInterface::COLUMNS], ['foo_id' => 'id']); + Assert::count($schema['executive2'][SchemaInterface::RELATIONS], 0); // Ceo - \Testo\Assert::array($schema)->hasKeys('ceo'); - \Testo\Assert::count($schema['ceo'], 1); - \Testo\Assert::same($schema['ceo'][SchemaInterface::ENTITY], Ceo::class); - \Testo\Assert::null($schema['ceo'][SchemaInterface::TABLE] ?? null); - \Testo\Assert::count($schema['ceo'][SchemaInterface::RELATIONS] ?? [], 0); + Assert::array($schema)->hasKeys('ceo'); + Assert::count($schema['ceo'], 1); + Assert::same($schema['ceo'][SchemaInterface::ENTITY], Ceo::class); + Assert::null($schema['ceo'][SchemaInterface::TABLE] ?? null); + Assert::count($schema['ceo'][SchemaInterface::RELATIONS] ?? [], 0); // Beaver - $this->assertEmpty($schema['beaver'][SchemaInterface::DISCRIMINATOR] ?? null); - $this->assertEmpty($schema['beaver'][SchemaInterface::PARENT] ?? null); - $this->assertEmpty($schema['beaver'][SchemaInterface::PARENT_KEY] ?? null); - $this->assertEmpty($schema['beaver'][SchemaInterface::CHILDREN] ?? null); - \Testo\Assert::same($schema['beaver'][SchemaInterface::TABLE], 'beavers'); - \Testo\Assert::equals($schema['beaver'][SchemaInterface::COLUMNS], [ + Assert::blank($schema['beaver'][SchemaInterface::DISCRIMINATOR] ?? null); + Assert::blank($schema['beaver'][SchemaInterface::PARENT] ?? null); + Assert::blank($schema['beaver'][SchemaInterface::PARENT_KEY] ?? null); + Assert::blank($schema['beaver'][SchemaInterface::CHILDREN] ?? null); + Assert::same($schema['beaver'][SchemaInterface::TABLE], 'beavers'); + Assert::equals($schema['beaver'][SchemaInterface::COLUMNS], [ 'teethAmount' => 'teeth_amount', 'foo_id' => 'id', 'name' => 'name', @@ -170,23 +173,15 @@ public function testTableInheritance(ReaderInterface $reader): void 'hidden' => 'hidden', 'tool_id' => 'tool_id', ]); - \Testo\Assert::count($schema['beaver'][SchemaInterface::RELATIONS] ?? [], 1); + Assert::count($schema['beaver'][SchemaInterface::RELATIONS] ?? [], 1); } - #[\Testo\Test] + #[Test] public function testTableInheritanceWithIncorrectClassesOrder(): void { $r = new Registry($this->dbal); $reader = new AttributeReader(); - $locator = $this->createMock(ClassesInterface::class); - $locator - ->method('getClasses') - ->willReturn([ - new \ReflectionClass(Employee::class), - new \ReflectionClass(Executive::class), - new \ReflectionClass(Person::class), - new \ReflectionClass(Tool::class), - ]); + $locator = new ClassList(Employee::class, Executive::class, Person::class, Tool::class); $schema = (new Compiler())->compile($r, [ new Embeddings(new TokenizerEmbeddingLocator($locator, $reader), $reader), @@ -202,37 +197,37 @@ public function testTableInheritanceWithIncorrectClassesOrder(): void new GenerateTypecast(), ]); - \Testo\Assert::same($schema['executive'][SchemaInterface::TABLE], 'executives'); - \Testo\Assert::null($schema['employee'][SchemaInterface::TABLE] ?? null); - \Testo\Assert::same($schema['person'][SchemaInterface::TABLE], 'people'); + Assert::same($schema['executive'][SchemaInterface::TABLE], 'executives'); + Assert::null($schema['employee'][SchemaInterface::TABLE] ?? null); + Assert::same($schema['person'][SchemaInterface::TABLE], 'people'); } - #[\Testo\Test] + #[Test] public function testJtiChildDoesNotInheritBelongsToColumn(): void { $schema = $this->compileWithClasses([BtTarget::class, BtParent::class, BtJoined::class]); // BtParent owns the BelongsTo + its FK column - \Testo\Assert::array($schema['btParent'][SchemaInterface::COLUMNS])->hasKeys('target_id'); - \Testo\Assert::count($schema['btParent'][SchemaInterface::RELATIONS], 1); + Assert::array($schema['btParent'][SchemaInterface::COLUMNS])->hasKeys('target_id'); + Assert::count($schema['btParent'][SchemaInterface::RELATIONS], 1); // JTI child must not duplicate the BelongsTo FK column nor inherit the relation - \Testo\Assert::array($schema['btJoined'][SchemaInterface::COLUMNS])->doesNotHaveKeys('target_id'); - \Testo\Assert::count($schema['btJoined'][SchemaInterface::RELATIONS] ?? [], 0); + Assert::array($schema['btJoined'][SchemaInterface::COLUMNS])->doesNotHaveKeys('target_id'); + Assert::count($schema['btJoined'][SchemaInterface::RELATIONS] ?? [], 0); } - #[\Testo\Test] + #[Test] public function testStiChildOwnRelationMergesIntoParent(): void { $schema = $this->compileWithClasses([StTarget::class, StParent::class, StChild::class]); // Relation declared on the STI child must end up on the parent after merge - \Testo\Assert::array($schema['stParent'][SchemaInterface::COLUMNS])->hasKeys('target_id'); - \Testo\Assert::count($schema['stParent'][SchemaInterface::RELATIONS], 1); - \Testo\Assert::array($schema['stParent'][SchemaInterface::RELATIONS])->hasKeys('target'); + Assert::array($schema['stParent'][SchemaInterface::COLUMNS])->hasKeys('target_id'); + Assert::count($schema['stParent'][SchemaInterface::RELATIONS], 1); + Assert::array($schema['stParent'][SchemaInterface::RELATIONS])->hasKeys('target'); } - #[\Testo\Test] + #[Test] public function testSeparateEntityExtendingStiChildKeepsInheritedRelation(): void { $schema = $this->compileWithClasses([ @@ -243,29 +238,29 @@ public function testSeparateEntityExtendingStiChildKeepsInheritedRelation(): voi ]); // Separate entity (no Inheritance attr) extending an STI child must keep ancestor relations - $this->assertEmpty($schema['soSeparate'][SchemaInterface::PARENT] ?? null); - \Testo\Assert::notNull($schema['soSeparate'][SchemaInterface::TABLE] ?? null); - \Testo\Assert::array($schema['soSeparate'][SchemaInterface::COLUMNS])->hasKeys('target_id'); - \Testo\Assert::array($schema['soSeparate'][SchemaInterface::COLUMNS])->hasKeys('extra'); - \Testo\Assert::count($schema['soSeparate'][SchemaInterface::RELATIONS] ?? [], 1); - \Testo\Assert::array($schema['soSeparate'][SchemaInterface::RELATIONS])->hasKeys('target'); + Assert::blank($schema['soSeparate'][SchemaInterface::PARENT] ?? null); + Assert::notNull($schema['soSeparate'][SchemaInterface::TABLE] ?? null); + Assert::array($schema['soSeparate'][SchemaInterface::COLUMNS])->hasKeys('target_id'); + Assert::array($schema['soSeparate'][SchemaInterface::COLUMNS])->hasKeys('extra'); + Assert::count($schema['soSeparate'][SchemaInterface::RELATIONS] ?? [], 1); + Assert::array($schema['soSeparate'][SchemaInterface::RELATIONS])->hasKeys('target'); } - #[\Testo\Test] + #[Test] public function testJtiChildDoesNotInheritRelationFromTrait(): void { $schema = $this->compileWithClasses([TrTarget::class, TrParent::class, TrJti::class]); // Trait-declared relation belongs to the entity that uses the trait - \Testo\Assert::array($schema['trParent'][SchemaInterface::COLUMNS])->hasKeys('target_id'); - \Testo\Assert::count($schema['trParent'][SchemaInterface::RELATIONS], 1); + Assert::array($schema['trParent'][SchemaInterface::COLUMNS])->hasKeys('target_id'); + Assert::count($schema['trParent'][SchemaInterface::RELATIONS], 1); // JTI child must not duplicate the trait's relation columns - \Testo\Assert::array($schema['trJti'][SchemaInterface::COLUMNS])->doesNotHaveKeys('target_id'); - \Testo\Assert::count($schema['trJti'][SchemaInterface::RELATIONS] ?? [], 0); + Assert::array($schema['trJti'][SchemaInterface::COLUMNS])->doesNotHaveKeys('target_id'); + Assert::count($schema['trJti'][SchemaInterface::RELATIONS] ?? [], 0); } - #[\Testo\Test] + #[Test] public function testJtiGrandchildDoesNotInheritMidLevelRelation(): void { $schema = $this->compileWithClasses([ @@ -276,12 +271,12 @@ public function testJtiGrandchildDoesNotInheritMidLevelRelation(): void ]); // Relation declared on the JTI middle entity stays on the middle table - \Testo\Assert::array($schema['jgMid'][SchemaInterface::COLUMNS])->hasKeys('target_id'); - \Testo\Assert::count($schema['jgMid'][SchemaInterface::RELATIONS], 1); + Assert::array($schema['jgMid'][SchemaInterface::COLUMNS])->hasKeys('target_id'); + Assert::count($schema['jgMid'][SchemaInterface::RELATIONS], 1); // JTI grandchild must not duplicate the middle entity's relation column - \Testo\Assert::array($schema['jgLeaf'][SchemaInterface::COLUMNS])->doesNotHaveKeys('target_id'); - \Testo\Assert::count($schema['jgLeaf'][SchemaInterface::RELATIONS] ?? [], 0); + Assert::array($schema['jgLeaf'][SchemaInterface::COLUMNS])->doesNotHaveKeys('target_id'); + Assert::count($schema['jgLeaf'][SchemaInterface::RELATIONS] ?? [], 0); } /** @@ -290,10 +285,7 @@ public function testJtiGrandchildDoesNotInheritMidLevelRelation(): void private function compileWithClasses(array $classes): array { $reader = new AttributeReader(); - $locator = $this->createMock(ClassesInterface::class); - $locator->method('getClasses')->willReturn( - \array_map(static fn(string $c) => new \ReflectionClass($c), $classes), - ); + $locator = new ClassList(...$classes); return (new Compiler())->compile(new Registry($this->dbal), [ new Embeddings(new TokenizerEmbeddingLocator($locator, $reader), $reader), diff --git a/tests/Annotated/Functional/Driver/Common/InvalidTestCase.php b/tests/Annotated/Feature/Common/InvalidTest.php similarity index 80% rename from tests/Annotated/Functional/Driver/Common/InvalidTestCase.php rename to tests/Annotated/Feature/Common/InvalidTest.php index 3a108dbd..757cc5d0 100644 --- a/tests/Annotated/Functional/Driver/Common/InvalidTestCase.php +++ b/tests/Annotated/Feature/Common/InvalidTest.php @@ -2,13 +2,14 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common; +namespace Cycle\Annotated\Tests\Feature\Common; use Cycle\Annotated\Entities; use Cycle\Annotated\Exception\AnnotationException; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Schema\Compiler; use Cycle\Schema\Exception\RelationException; use Cycle\Schema\Generator\GenerateRelations; @@ -19,20 +20,22 @@ use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Generator\ValidateEntities; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\AnnotationReader; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Data\DataProvider; +use Testo\Expect; +use Testo\Test; -abstract class InvalidTestCase extends BaseTestCase +final class InvalidTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testInvalidRelation(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures3'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures3'], 'exclude' => [], ])); @@ -40,7 +43,7 @@ public function testInvalidRelation(ReaderInterface $reader): void $r = new Registry($this->dbal); - \Testo\Expect::exception(RelationException::class); + Expect::exception(RelationException::class); (new Compiler())->compile($r, [ new Entities(new TokenizerEntityLocator($locator, $reader), $reader), @@ -56,18 +59,18 @@ public function testInvalidRelation(ReaderInterface $reader): void ]); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testNotDefinedColumnTypeShouldThrowAnException(ReaderInterface $reader): void { $message = $reader instanceof AnnotationReader ? 'Too few arguments to function Cycle\Annotated\Annotation\Column::__construct(), 0 passed' : 'Some of required arguments [`type`] is missed on `Cycle\Annotated\Tests\Fixtures\Fixtures4\User.id.`'; - \Testo\Expect::exception(AnnotationException::class)->withMessageContaining($message); + Expect::exception(AnnotationException::class)->withMessageContaining($message); $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures4'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures4'], 'exclude' => [], ])); diff --git a/tests/Annotated/Functional/Driver/Common/Relation/BelongsToTestCase.php b/tests/Annotated/Feature/Common/Relation/BelongsToTest.php similarity index 64% rename from tests/Annotated/Functional/Driver/Common/Relation/BelongsToTestCase.php rename to tests/Annotated/Feature/Common/Relation/BelongsToTest.php index c7f2ddb0..8ddf06a5 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/BelongsToTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/BelongsToTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation; +namespace Cycle\Annotated\Tests\Feature\Common\Relation; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\ORM\Relation; use Cycle\ORM\Schema; use Cycle\Schema\Compiler; @@ -19,13 +19,15 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class BelongsToTestCase extends BaseTestCase +final class BelongsToTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -42,8 +44,8 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::array($schema['eComplete'][Schema::RELATIONS])->hasKeys('parent'); - \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::BELONGS_TO); - \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TARGET], 'simple'); + Assert::array($schema['eComplete'][Schema::RELATIONS])->hasKeys('parent'); + Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::BELONGS_TO); + Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TARGET], 'simple'); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/CompositeKeysTestCase.php b/tests/Annotated/Feature/Common/Relation/CompositeKeysTest.php similarity index 76% rename from tests/Annotated/Functional/Driver/Common/Relation/CompositeKeysTestCase.php rename to tests/Annotated/Feature/Common/Relation/CompositeKeysTest.php index 0fad1a78..d2d42643 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/CompositeKeysTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/CompositeKeysTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation; +namespace Cycle\Annotated\Tests\Feature\Common\Relation; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -10,7 +10,7 @@ use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Schema\Compiler; use Cycle\Schema\Generator\GenerateRelations; use Cycle\Schema\Generator\GenerateTypecast; @@ -19,19 +19,21 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class CompositeKeysTestCase extends BaseTestCase +final class CompositeKeysTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelationToChild(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [dirname(__DIR__) . '/../../../Fixtures/Fixtures14'], + 'directories' => [dirname(__DIR__) . '/../../Fixtures/Fixtures14'], 'exclude' => [], ])); @@ -52,6 +54,6 @@ public function testRelationToChild(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::true(true, 'No exceptions thrown.'); + Assert::true(true, 'No exceptions thrown.'); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/EmbeddedTestCase.php b/tests/Annotated/Feature/Common/Relation/EmbeddedTest.php similarity index 66% rename from tests/Annotated/Functional/Driver/Common/Relation/EmbeddedTestCase.php rename to tests/Annotated/Feature/Common/Relation/EmbeddedTest.php index d1d630ac..5cedd5d0 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/EmbeddedTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/EmbeddedTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation; +namespace Cycle\Annotated\Tests\Feature\Common\Relation; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -10,8 +10,8 @@ use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures26\CityTypecast; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; use Cycle\ORM\Relation; use Cycle\ORM\Schema; use Cycle\Schema\Compiler; @@ -22,19 +22,21 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class EmbeddedTestCase extends BaseTestCase +final class EmbeddedTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelation(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures6'], + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures6'], 'exclude' => [], ])); @@ -55,20 +57,20 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('address'); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TYPE], Relation::EMBEDDED); + Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('address'); + Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TYPE], Relation::EMBEDDED); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TARGET], 'user:address:address'); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::LOAD], Relation::LOAD_EAGER); - \Testo\Assert::true($r->getTableSchema($r->getEntity('user'))->hasIndex(['address_zipcode'])); + Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TARGET], 'user:address:address'); + Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::LOAD], Relation::LOAD_EAGER); + Assert::true($r->getTableSchema($r->getEntity('user'))->hasIndex(['address_zipcode'])); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelationLazyLoad(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures7'], + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures7'], 'exclude' => [], ])); @@ -89,20 +91,20 @@ public function testRelationLazyLoad(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('address'); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TYPE], Relation::EMBEDDED); + Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('address'); + Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TYPE], Relation::EMBEDDED); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TARGET], 'user:address:address'); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::LOAD], Relation::LOAD_PROMISE); - \Testo\Assert::true($r->getTableSchema($r->getEntity('user:address:address'))->hasIndex(['address_zipcode'])); + Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::TARGET], 'user:address:address'); + Assert::same($schema['user'][Schema::RELATIONS]['address'][Relation::LOAD], Relation::LOAD_PROMISE); + Assert::true($r->getTableSchema($r->getEntity('user:address:address'))->hasIndex(['address_zipcode'])); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testEmbeddedPrefix(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures6'], + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures6'], 'exclude' => [], ])); @@ -138,16 +140,16 @@ public function testEmbeddedPrefix(ReaderInterface $reader): void 'id' => 'id', ]; - \Testo\Assert::same($schema['user:address:address'][Schema::COLUMNS], $address); - \Testo\Assert::same($schema['user:address:workAddress'][Schema::COLUMNS], $workAddress); + Assert::same($schema['user:address:address'][Schema::COLUMNS], $address); + Assert::same($schema['user:address:workAddress'][Schema::COLUMNS], $workAddress); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testEmbeddedTypecast(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures26'], + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures26'], 'exclude' => [], ])); @@ -168,6 +170,6 @@ public function testEmbeddedTypecast(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::same($schema['user:address:address'][Schema::TYPECAST_HANDLER][0], CityTypecast::class); + Assert::same($schema['user:address:address'][Schema::TYPECAST_HANDLER][0], CityTypecast::class); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/HasManyTestCase.php b/tests/Annotated/Feature/Common/Relation/HasManyTest.php similarity index 65% rename from tests/Annotated/Functional/Driver/Common/Relation/HasManyTestCase.php rename to tests/Annotated/Feature/Common/Relation/HasManyTest.php index e86fb354..e6c01d62 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/HasManyTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/HasManyTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation; +namespace Cycle\Annotated\Tests\Feature\Common\Relation; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\ORM\Relation; use Cycle\ORM\SchemaInterface; use Cycle\ORM\SchemaInterface as Schema; @@ -20,16 +20,18 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\AttributeReader; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class HasManyTestCase extends BaseTestCase +final class HasManyTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -49,19 +51,19 @@ public function testRelation(ReaderInterface $reader): void ], ); - \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('many'); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::TYPE], Relation::HAS_MANY); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::TARGET], 'withTable'); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::WHERE], ['id' => ['>=' => 1]]); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::ORDER_BY], ['id' => 'DESC']); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::COLLECTION_TYPE], 'bar'); + Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('many'); + Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::TYPE], Relation::HAS_MANY); + Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::TARGET], 'withTable'); + Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::WHERE], ['id' => ['>=' => 1]]); + Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::ORDER_BY], ['id' => 'DESC']); + Assert::same($schema['simple'][Schema::RELATIONS]['many'][Relation::SCHEMA][Relation::COLLECTION_TYPE], 'bar'); } - #[\Testo\Test] + #[Test] public function testInnerOuterKeys(): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures18'], + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures18'], 'exclude' => [], ])); $reader = new AttributeReader(); @@ -94,9 +96,9 @@ public function testInnerOuterKeys(): void foreach ($checks as [$name, $innerKey, $outerKey]) { $relation = $schema['booking_reservation'][SchemaInterface::RELATIONS][$name]; - \Testo\Assert::same($relation[Relation::TYPE], Relation::HAS_MANY, "$name: relation type"); - \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::INNER_KEY], (array) $innerKey, "$name: Inner Key"); - \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::OUTER_KEY], (array) $outerKey, "$name: Outer Key"); + Assert::same($relation[Relation::TYPE], Relation::HAS_MANY, "$name: relation type"); + Assert::same((array) $relation[Relation::SCHEMA][Relation::INNER_KEY], (array) $innerKey, "$name: Inner Key"); + Assert::same((array) $relation[Relation::SCHEMA][Relation::OUTER_KEY], (array) $outerKey, "$name: Outer Key"); } } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/HasOneTestCase.php b/tests/Annotated/Feature/Common/Relation/HasOneTest.php similarity index 66% rename from tests/Annotated/Functional/Driver/Common/Relation/HasOneTestCase.php rename to tests/Annotated/Feature/Common/Relation/HasOneTest.php index f2100e4f..5ae98b24 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/HasOneTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/HasOneTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation; +namespace Cycle\Annotated\Tests\Feature\Common\Relation; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\ORM\Relation; use Cycle\ORM\SchemaInterface; use Cycle\Schema\Compiler; @@ -19,16 +19,18 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\AttributeReader; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class HasOneTestCase extends BaseTestCase +final class HasOneTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -45,18 +47,18 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::array($schema['simple'][SchemaInterface::RELATIONS])->hasKeys('one'); - \Testo\Assert::same($schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::TYPE], Relation::HAS_ONE); - \Testo\Assert::same($schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::TARGET], 'eComplete'); - \Testo\Assert::same($schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::LOAD], Relation::LOAD_PROMISE); + Assert::array($schema['simple'][SchemaInterface::RELATIONS])->hasKeys('one'); + Assert::same($schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::TYPE], Relation::HAS_ONE); + Assert::same($schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::TARGET], 'eComplete'); + Assert::same($schema['simple'][SchemaInterface::RELATIONS]['one'][Relation::LOAD], Relation::LOAD_PROMISE); } - #[\Testo\Test] + #[Test] public function testInnerOuterKeys(): void { $tokenizer = new Tokenizer( new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures18'], + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures18'], 'exclude' => [], ]), ); @@ -91,10 +93,10 @@ public function testInnerOuterKeys(): void foreach ($checks as [$name, $innerKey, $outerKey]) { $relation = $schema['booking'][SchemaInterface::RELATIONS][$name]; - \Testo\Assert::same($relation[Relation::TYPE], Relation::HAS_ONE, "$name: relation type"); - \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::INNER_KEY], (array) $innerKey, "$name: Inner Key"); - \Testo\Assert::same((array) $relation[Relation::SCHEMA][Relation::OUTER_KEY], (array) $outerKey, "$name: Outer Key"); + Assert::same($relation[Relation::TYPE], Relation::HAS_ONE, "$name: relation type"); + Assert::same((array) $relation[Relation::SCHEMA][Relation::INNER_KEY], (array) $innerKey, "$name: Inner Key"); + Assert::same((array) $relation[Relation::SCHEMA][Relation::OUTER_KEY], (array) $outerKey, "$name: Outer Key"); } - \Testo\Assert::array($schema['booking'][SchemaInterface::COLUMNS])->doesNotHaveKeys('id_reservation'); + Assert::array($schema['booking'][SchemaInterface::COLUMNS])->doesNotHaveKeys('id_reservation'); } } diff --git a/tests/Annotated/Feature/Common/Relation/InverseTest.php b/tests/Annotated/Feature/Common/Relation/InverseTest.php new file mode 100644 index 00000000..6dbce47a --- /dev/null +++ b/tests/Annotated/Feature/Common/Relation/InverseTest.php @@ -0,0 +1,215 @@ + [__DIR__ . '/../../../Fixtures/Fixtures2'], + 'exclude' => [], + ])); + + $locator = $tokenizer->classLocator(); + + $r = new Registry($this->dbal); + + $schema = (new Compiler())->compile($r, [ + new Entities(new TokenizerEntityLocator($locator, $reader), $reader), + new ResetTables(), + new MergeColumns($reader), + new GenerateRelations(), + new ValidateEntities(), + new RenderTables(), + new RenderRelations(), + new MergeIndexes($reader), + new SyncTables(), + new GenerateTypecast(), + ]); + + Assert::array($schema['eComplete'][Schema::RELATIONS])->hasKeys('parent'); + Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::BELONGS_TO); + Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TARGET], 'simple'); + + Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('child'); + Assert::same($schema['simple'][Schema::RELATIONS]['child'][Relation::TYPE], Relation::HAS_ONE); + Assert::same($schema['simple'][Schema::RELATIONS]['child'][Relation::TARGET], 'eComplete'); + } + + #[DataProvider('allReadersProvider')] + #[Test] + public function testBelongsToMany(ReaderInterface $reader): void + { + $tokenizer = new Tokenizer(new TokenizerConfig([ + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures2'], + 'exclude' => [], + ])); + + $locator = $tokenizer->classLocator(); + + $r = new Registry($this->dbal); + + $schema = (new Compiler())->compile($r, [ + new Entities(new TokenizerEntityLocator($locator, $reader), $reader), + new ResetTables(), + new MergeColumns($reader), + new GenerateRelations(), + new ValidateEntities(), + new RenderTables(), + new RenderRelations(), + new MergeIndexes($reader), + new SyncTables(), + new GenerateTypecast(), + ]); + + Assert::array($schema['eComplete'][Schema::RELATIONS])->hasKeys('uncles'); + Assert::same($schema['eComplete'][Schema::RELATIONS]['uncles'][Relation::TYPE], Relation::BELONGS_TO); + Assert::same($schema['eComplete'][Schema::RELATIONS]['uncles'][Relation::TARGET], 'simple'); + + Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('stepKids'); + Assert::same($schema['simple'][Schema::RELATIONS]['stepKids'][Relation::TYPE], Relation::HAS_MANY); + Assert::same($schema['simple'][Schema::RELATIONS]['stepKids'][Relation::TARGET], 'eComplete'); + } + + #[DataProvider('allReadersProvider')] + #[Test] + public function testHasOne(ReaderInterface $reader): void + { + $tokenizer = new Tokenizer(new TokenizerConfig([ + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures2'], + 'exclude' => [], + ])); + + $locator = $tokenizer->classLocator(); + + $r = new Registry($this->dbal); + + $schema = (new Compiler())->compile($r, [ + new Entities(new TokenizerEntityLocator($locator, $reader), $reader), + new ResetTables(), + new MergeColumns($reader), + new GenerateRelations(), + new ValidateEntities(), + new RenderTables(), + new RenderRelations(), + new MergeIndexes($reader), + new SyncTables(), + new GenerateTypecast(), + ]); + + Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('simple'); + Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TYPE], Relation::HAS_ONE); + Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TARGET], 'simple'); + + Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('user'); + Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TYPE], Relation::BELONGS_TO); + Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TARGET], 'user'); + } + + #[DataProvider('allReadersProvider')] + #[Test] + public function testHasOneInverseLoad(ReaderInterface $reader): void + { + $tokenizer = new Tokenizer(new TokenizerConfig([ + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures5'], + 'exclude' => [], + ])); + + $locator = $tokenizer->classLocator(); + + $r = new Registry($this->dbal); + + $schema = (new Compiler())->compile($r, [ + new Entities(new TokenizerEntityLocator($locator, $reader), $reader), + new ResetTables(), + new MergeColumns($reader), + new GenerateRelations(), + new ValidateEntities(), + new RenderTables(), + new RenderRelations(), + new MergeIndexes($reader), + new SyncTables(), + new GenerateTypecast(), + ]); + + Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('simple'); + Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TYPE], Relation::HAS_ONE); + Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TARGET], 'simple'); + + Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::LOAD], Relation::LOAD_EAGER); + + Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('user'); + Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TYPE], Relation::BELONGS_TO); + Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TARGET], 'user'); + + Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::LOAD], Relation::LOAD_PROMISE); + } + + #[DataProvider('allReadersProvider')] + #[Test] + public function testBelongsTo(ReaderInterface $reader): void + { + $tokenizer = new Tokenizer(new TokenizerConfig([ + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures2'], + 'exclude' => [], + ])); + + $locator = $tokenizer->classLocator(); + + $r = new Registry($this->dbal); + + $schema = (new Compiler())->compile($r, [ + new Entities(new TokenizerEntityLocator($locator, $reader), $reader), + new ResetTables(), + new MergeColumns($reader), + new GenerateRelations(), + new ValidateEntities(), + new RenderTables(), + new RenderRelations(), + new MergeIndexes($reader), + new SyncTables(), + new GenerateTypecast(), + ]); + + Assert::array($schema['mark'][Schema::RELATIONS])->hasKeys('owner'); + Assert::same($schema['mark'][Schema::RELATIONS]['owner'][Relation::TYPE], Relation::BELONGS_TO_MORPHED); + Assert::same($schema['mark'][Schema::RELATIONS]['owner'][Relation::TARGET], MarkedInterface::class); + + Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('mark'); + Assert::same($schema['user'][Schema::RELATIONS]['mark'][Relation::TYPE], Relation::MORPHED_HAS_ONE); + Assert::same($schema['user'][Schema::RELATIONS]['mark'][Relation::TARGET], 'mark'); + + Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('mark'); + Assert::same($schema['simple'][Schema::RELATIONS]['mark'][Relation::TYPE], Relation::MORPHED_HAS_ONE); + Assert::same($schema['simple'][Schema::RELATIONS]['mark'][Relation::TARGET], 'mark'); + } +} diff --git a/tests/Annotated/Functional/Driver/Common/Relation/ManyToManyTestCase.php b/tests/Annotated/Feature/Common/Relation/ManyToManyTest.php similarity index 91% rename from tests/Annotated/Functional/Driver/Common/Relation/ManyToManyTestCase.php rename to tests/Annotated/Feature/Common/Relation/ManyToManyTest.php index 545a179e..60f4987c 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/ManyToManyTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/ManyToManyTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation; +namespace Cycle\Annotated\Tests\Feature\Common\Relation; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Collection\BaseCollection; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; use Cycle\Database\Schema\AbstractTable; use Cycle\ORM\Relation; use Cycle\ORM\SchemaInterface; @@ -22,22 +22,21 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\AttributeReader; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Data\DataProvider; +use Testo\Test; -use function PHPUnit\Framework\assertCount; - -abstract class ManyToManyTestCase extends BaseTestCase +final class ManyToManyTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testPivotPrimaryKeys(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures15'], + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures15'], 'exclude' => [], ])); @@ -74,8 +73,8 @@ public function testPivotPrimaryKeys(ReaderInterface $reader): void \Testo\Assert::count($table->getIndexes(), 1); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -109,12 +108,12 @@ public function testRelation(ReaderInterface $reader): void \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['tags'][Relation::SCHEMA][Relation::COLLECTION_TYPE], BaseCollection::class); } - #[\Testo\Test] + #[Test] public function testInnerOuterKeys(): void { $tokenizer = new Tokenizer( new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures18'], + 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures18'], 'exclude' => [], ]), ); diff --git a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/BelongsToMorphedTestCase.php b/tests/Annotated/Feature/Common/Relation/Morphed/BelongsToMorphedTest.php similarity index 63% rename from tests/Annotated/Functional/Driver/Common/Relation/Morphed/BelongsToMorphedTestCase.php rename to tests/Annotated/Feature/Common/Relation/Morphed/BelongsToMorphedTest.php index 83c78781..36e71f33 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/BelongsToMorphedTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/Morphed/BelongsToMorphedTest.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation\Morphed; +namespace Cycle\Annotated\Tests\Feature\Common\Relation\Morphed; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Constrain\SomeConstrain; use Cycle\Annotated\Tests\Fixtures\Fixtures1\LabelledInterface; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; use Cycle\ORM\Relation; use Cycle\ORM\SchemaInterface as Schema; use Cycle\Schema\Compiler; @@ -21,13 +21,15 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class BelongsToMorphedTestCase extends BaseTestCase +final class BelongsToMorphedTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -44,11 +46,11 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::array($schema['label'][Schema::RELATIONS])->hasKeys('owner'); - \Testo\Assert::same($schema['label'][Schema::RELATIONS]['owner'][Relation::TYPE], Relation::BELONGS_TO_MORPHED); + Assert::array($schema['label'][Schema::RELATIONS])->hasKeys('owner'); + Assert::same($schema['label'][Schema::RELATIONS]['owner'][Relation::TYPE], Relation::BELONGS_TO_MORPHED); - \Testo\Assert::same($schema['label'][Schema::RELATIONS]['owner'][Relation::TARGET], LabelledInterface::class); + Assert::same($schema['label'][Schema::RELATIONS]['owner'][Relation::TARGET], LabelledInterface::class); - \Testo\Assert::same($schema['label'][Schema::SCOPE], SomeConstrain::class); + Assert::same($schema['label'][Schema::SCOPE], SomeConstrain::class); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasManyTestCase.php b/tests/Annotated/Feature/Common/Relation/Morphed/MorphedHasManyTest.php similarity index 53% rename from tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasManyTestCase.php rename to tests/Annotated/Feature/Common/Relation/Morphed/MorphedHasManyTest.php index d164b58c..6233beb1 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasManyTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/Morphed/MorphedHasManyTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation\Morphed; +namespace Cycle\Annotated\Tests\Feature\Common\Relation\Morphed; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Collection\BaseCollection; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; use Cycle\ORM\Relation; use Cycle\ORM\Schema; use Cycle\Schema\Compiler; @@ -20,13 +20,15 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class MorphedHasManyTestCase extends BaseTestCase +final class MorphedHasManyTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -43,30 +45,30 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('labels'); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['labels'][Relation::TYPE], Relation::MORPHED_HAS_MANY); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['labels'][Relation::TARGET], 'label'); + Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('labels'); + Assert::same($schema['simple'][Schema::RELATIONS]['labels'][Relation::TYPE], Relation::MORPHED_HAS_MANY); + Assert::same($schema['simple'][Schema::RELATIONS]['labels'][Relation::TARGET], 'label'); - \Testo\Assert::array($schema['withTable'][Schema::RELATIONS])->hasKeys('labels'); - \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['labels'][Relation::TYPE], Relation::MORPHED_HAS_MANY); + Assert::array($schema['withTable'][Schema::RELATIONS])->hasKeys('labels'); + Assert::same($schema['withTable'][Schema::RELATIONS]['labels'][Relation::TYPE], Relation::MORPHED_HAS_MANY); - \Testo\Assert::same($schema['withTable'][Schema::RELATIONS]['labels'][Relation::TARGET], 'label'); + Assert::same($schema['withTable'][Schema::RELATIONS]['labels'][Relation::TARGET], 'label'); - \Testo\Assert::true($this->dbal->database('default') + Assert::true($this->dbal->database('default') ->getDriver() ->getSchema('labels') ->hasColumn('owner_id')); - \Testo\Assert::true($this->dbal->database('default') + Assert::true($this->dbal->database('default') ->getDriver() ->getSchema('labels') ->hasColumn('owner_role')); - \Testo\Assert::false($this->dbal->database('default') + Assert::false($this->dbal->database('default') ->getDriver() ->getSchema('labels') ->hasIndex(['owner_id', 'owner_role'])); - \Testo\Assert::same($schema['simple'][\Cycle\ORM\SchemaInterface::RELATIONS]['labels'][Relation::SCHEMA][Relation::COLLECTION_TYPE], BaseCollection::class); + Assert::same($schema['simple'][\Cycle\ORM\SchemaInterface::RELATIONS]['labels'][Relation::SCHEMA][Relation::COLLECTION_TYPE], BaseCollection::class); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasOneTestCase.php b/tests/Annotated/Feature/Common/Relation/Morphed/MorphedHasOneTest.php similarity index 64% rename from tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasOneTestCase.php rename to tests/Annotated/Feature/Common/Relation/Morphed/MorphedHasOneTest.php index ddc91b4e..f24dd130 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/MorphedHasOneTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/Morphed/MorphedHasOneTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation\Morphed; +namespace Cycle\Annotated\Tests\Feature\Common\Relation\Morphed; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\ORM\Relation; use Cycle\ORM\Schema; use Cycle\Schema\Compiler; @@ -19,13 +19,15 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class MorphedHasOneTestCase extends BaseTestCase +final class MorphedHasOneTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -42,21 +44,21 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::array($schema['tag'][Schema::RELATIONS])->hasKeys('label'); - \Testo\Assert::same($schema['tag'][Schema::RELATIONS]['label'][Relation::TYPE], Relation::MORPHED_HAS_ONE); - \Testo\Assert::same($schema['tag'][Schema::RELATIONS]['label'][Relation::TARGET], 'label'); + Assert::array($schema['tag'][Schema::RELATIONS])->hasKeys('label'); + Assert::same($schema['tag'][Schema::RELATIONS]['label'][Relation::TYPE], Relation::MORPHED_HAS_ONE); + Assert::same($schema['tag'][Schema::RELATIONS]['label'][Relation::TARGET], 'label'); - \Testo\Assert::true($this->dbal->database('default') + Assert::true($this->dbal->database('default') ->getDriver() ->getSchema('labels') ->hasColumn('owner_id')); - \Testo\Assert::true($this->dbal->database('default') + Assert::true($this->dbal->database('default') ->getDriver() ->getSchema('labels') ->hasColumn('owner_role')); - \Testo\Assert::false($this->dbal->database('default') + Assert::false($this->dbal->database('default') ->getDriver() ->getSchema('labels') ->hasIndex(['owner_id', 'owner_role'])); diff --git a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/RefersToMorphedTestCase.php b/tests/Annotated/Feature/Common/Relation/Morphed/RefersToMorphedTest.php similarity index 62% rename from tests/Annotated/Functional/Driver/Common/Relation/Morphed/RefersToMorphedTestCase.php rename to tests/Annotated/Feature/Common/Relation/Morphed/RefersToMorphedTest.php index e2354107..d023fa3a 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/Morphed/RefersToMorphedTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/Morphed/RefersToMorphedTest.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation\Morphed; +namespace Cycle\Annotated\Tests\Feature\Common\Relation\Morphed; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\RefersToMorphed\MorphedParentInterface; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; use Cycle\ORM\Relation; use Cycle\ORM\SchemaInterface as Schema; use Cycle\Schema\Compiler; @@ -20,19 +20,21 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class RefersToMorphedTestCase extends BaseTestCase +final class RefersToMorphedTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelation(ReaderInterface $reader): void { $locator = (new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../../Fixtures/RefersToMorphed'], + 'directories' => [__DIR__ . '/../../../../Fixtures/RefersToMorphed'], 'exclude' => [], ])))->classLocator(); @@ -50,12 +52,12 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::array($schema['comment'][Schema::RELATIONS])->hasKeys('parent'); - \Testo\Assert::same($schema['comment'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::REFERS_TO_MORPHED); - \Testo\Assert::same($schema['comment'][Schema::RELATIONS]['parent'][Relation::TARGET], MorphedParentInterface::class); + Assert::array($schema['comment'][Schema::RELATIONS])->hasKeys('parent'); + Assert::same($schema['comment'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::REFERS_TO_MORPHED); + Assert::same($schema['comment'][Schema::RELATIONS]['parent'][Relation::TARGET], MorphedParentInterface::class); // Morphed refers-to stores the outer key and the target role on the source entity. - \Testo\Assert::contains($schema['comment'][Schema::COLUMNS], 'parent_id'); - \Testo\Assert::contains($schema['comment'][Schema::COLUMNS], 'parent_role'); + Assert::contains($schema['comment'][Schema::COLUMNS], 'parent_id'); + Assert::contains($schema['comment'][Schema::COLUMNS], 'parent_role'); } } diff --git a/tests/Annotated/Functional/Driver/Common/Relation/RefersToTestCase.php b/tests/Annotated/Feature/Common/Relation/RefersToTest.php similarity index 65% rename from tests/Annotated/Functional/Driver/Common/Relation/RefersToTestCase.php rename to tests/Annotated/Feature/Common/Relation/RefersToTest.php index 9965c178..66694906 100644 --- a/tests/Annotated/Functional/Driver/Common/Relation/RefersToTestCase.php +++ b/tests/Annotated/Feature/Common/Relation/RefersToTest.php @@ -2,13 +2,13 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common\Relation; +namespace Cycle\Annotated\Tests\Feature\Common\Relation; use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; -use Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\ORM\Relation; use Cycle\ORM\Schema; use Cycle\Schema\Compiler; @@ -19,13 +19,15 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class RefersToTestCase extends BaseTestCase +final class RefersToTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testRelation(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -42,11 +44,11 @@ public function testRelation(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('parent'); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::REFERS_TO); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['parent'][Relation::TARGET], 'simple'); + Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('parent'); + Assert::same($schema['simple'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::REFERS_TO); + Assert::same($schema['simple'][Schema::RELATIONS]['parent'][Relation::TARGET], 'simple'); - \Testo\Assert::same($this->dbal->database('default') + Assert::same($this->dbal->database('default') ->getDriver() ->getSchema('simples') ->foreignKey(['parent_id']) diff --git a/tests/Annotated/Functional/Driver/Common/SchemaModifiersTestCase.php b/tests/Annotated/Feature/Common/SchemaModifiersTest.php similarity index 72% rename from tests/Annotated/Functional/Driver/Common/SchemaModifiersTestCase.php rename to tests/Annotated/Feature/Common/SchemaModifiersTest.php index 4bc36894..07f77cdc 100644 --- a/tests/Annotated/Functional/Driver/Common/SchemaModifiersTestCase.php +++ b/tests/Annotated/Feature/Common/SchemaModifiersTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common; +namespace Cycle\Annotated\Tests\Feature\Common; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -10,6 +10,7 @@ use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Child; use Cycle\Annotated\Tests\Fixtures\Fixtures17\MapperSegmentSchemaModifier; use Cycle\Annotated\Tests\Fixtures\Fixtures17\ParentSegmentSchemaModifier; @@ -22,20 +23,22 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class SchemaModifiersTestCase extends BaseTestCase +final class SchemaModifiersTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testModifierAnnotationShouldBeAddedToEntity(ReaderInterface $reader): void { $tokenizer = new Tokenizer( new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures17'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures17'], 'exclude' => [], ]), ); @@ -60,11 +63,11 @@ public function testModifierAnnotationShouldBeAddedToEntity(ReaderInterface $rea $post = $r->getEntity('post'); $modifiers = iterator_to_array($post->getSchemaModifiers()); - \Testo\Assert::count($modifiers, 2); - \Testo\Assert::instanceOf($modifiers[0], ParentSegmentSchemaModifier::class); - \Testo\Assert::instanceOf($modifiers[1], MapperSegmentSchemaModifier::class); + Assert::count($modifiers, 2); + Assert::instanceOf($modifiers[0], ParentSegmentSchemaModifier::class); + Assert::instanceOf($modifiers[1], MapperSegmentSchemaModifier::class); - \Testo\Assert::same($schema['post'][SchemaInterface::PARENT], \stdClass::class); - \Testo\Assert::same($schema['post'][SchemaInterface::MAPPER], Child::class); + Assert::same($schema['post'][SchemaInterface::PARENT], \stdClass::class); + Assert::same($schema['post'][SchemaInterface::MAPPER], Child::class); } } diff --git a/tests/Annotated/Functional/Driver/Common/TableTestCase.php b/tests/Annotated/Feature/Common/TableTest.php similarity index 67% rename from tests/Annotated/Functional/Driver/Common/TableTestCase.php rename to tests/Annotated/Feature/Common/TableTest.php index e1dd404e..d5737448 100644 --- a/tests/Annotated/Functional/Driver/Common/TableTestCase.php +++ b/tests/Annotated/Feature/Common/TableTest.php @@ -2,28 +2,32 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common; +namespace Cycle\Annotated\Tests\Feature\Common; use Cycle\Annotated\Entities; use Cycle\Annotated\Exception\AnnotationException; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\ORM\Schema; use Cycle\Schema\Compiler; use Cycle\Schema\Generator\ForeignKeys; use Cycle\Schema\Generator\RenderTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\AnnotationReader; use Spiral\Attributes\AttributeReader; use Spiral\Attributes\Composite\SelectiveReader; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Expect; +use Testo\Test; -abstract class TableTestCase extends BaseTestCase +final class TableTest extends BaseTestCase { public static function foreignKeyDirectoriesDataProvider(): \Traversable { @@ -76,8 +80,8 @@ public static function foreignKeyDirectoriesDataProvider(): \Traversable ]; } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testColumnsRendered(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -85,22 +89,22 @@ public function testColumnsRendered(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); + Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - \Testo\Assert::true($schema->hasColumn('name')); - \Testo\Assert::same($schema->column('status')->getType(), 'string'); + Assert::true($schema->hasColumn('name')); + Assert::same($schema->column('status')->getType(), 'string'); - \Testo\Assert::true($schema->hasColumn('status')); + Assert::true($schema->hasColumn('status')); - \Testo\Assert::same($schema->column('status')->getAbstractType(), 'enum'); - \Testo\Assert::same($schema->column('status')->getDefaultValue(), 'active'); - \Testo\Assert::same($schema->column('status')->getEnumValues(), ['active', 'disabled']); + Assert::same($schema->column('status')->getAbstractType(), 'enum'); + Assert::same($schema->column('status')->getDefaultValue(), 'active'); + Assert::same($schema->column('status')->getEnumValues(), ['active', 'disabled']); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testColumnWithDifferentColumnNameAndProperty(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -112,13 +116,13 @@ public function testColumnWithDifferentColumnNameAndProperty(ReaderInterface $re new RenderTables(), ], ); - \Testo\Assert::array($schema)->hasKeys('withTable'); - \Testo\Assert::array($schema['withTable'][Schema::COLUMNS])->hasKeys('status_property'); - \Testo\Assert::same($schema['withTable'][Schema::COLUMNS]['status_property'], 'status'); + Assert::array($schema)->hasKeys('withTable'); + Assert::array($schema['withTable'][Schema::COLUMNS])->hasKeys('status_property'); + Assert::same($schema['withTable'][Schema::COLUMNS]['status_property'], 'status'); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testColumnWithoutColumnName(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -130,17 +134,17 @@ public function testColumnWithoutColumnName(ReaderInterface $reader): void new RenderTables(), ], ); - \Testo\Assert::array($schema)->hasKeys('withTable'); - \Testo\Assert::array($schema['withTable'][Schema::COLUMNS])->hasKeys('no_column_name'); - \Testo\Assert::same($schema['withTable'][Schema::COLUMNS]['no_column_name'], 'no_column_name'); + Assert::array($schema)->hasKeys('withTable'); + Assert::array($schema['withTable'][Schema::COLUMNS])->hasKeys('no_column_name'); + Assert::same($schema['withTable'][Schema::COLUMNS]['no_column_name'], 'no_column_name'); } - #[\Testo\Test] + #[Test] public function testColumnInTableAnnotationByNumericKey(): void { $reader = new AnnotationReader(); $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures9'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures9'], 'exclude' => [], ])); $locator = $tokenizer->classLocator(); @@ -151,23 +155,23 @@ public function testColumnInTableAnnotationByNumericKey(): void new RenderTables(), ]); - \Testo\Assert::array($schema)->hasKeys('orderedIdx'); - \Testo\Assert::array($schema['orderedIdx'][Schema::COLUMNS])->hasKeys('other_name'); - \Testo\Assert::same($schema['orderedIdx'][Schema::COLUMNS]['other_name'], 'other_name'); + Assert::array($schema)->hasKeys('orderedIdx'); + Assert::array($schema['orderedIdx'][Schema::COLUMNS])->hasKeys('other_name'); + Assert::same($schema['orderedIdx'][Schema::COLUMNS]['other_name'], 'other_name'); } - #[\Testo\Test] + #[Test] public function testColumnWithPropertyInTableAnnotationByNamedKey(): void { $reader = new AnnotationReader(); $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures11'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures11'], 'exclude' => [], ])); $locator = $tokenizer->classLocator(); $r = new Registry($this->dbal); - \Testo\Expect::exception(AnnotationException::class)->withMessageContaining('Can not use name "name1" for Column of the `badEntity` role, because the ' + Expect::exception(AnnotationException::class)->withMessageContaining('Can not use name "name1" for Column of the `badEntity` role, because the ' . '"property" field of the metadata class has already been set to "name2".'); (new Compiler())->compile($r, [ @@ -177,14 +181,14 @@ public function testColumnWithPropertyInTableAnnotationByNamedKey(): void ]); } - #[\Testo\Data\DataProvider('singularReadersProvider')] - #[\Testo\Test] + #[DataProvider('singularReadersProvider')] + #[Test] public function testCompositePrimaryKey(ReaderInterface $reader): void { $r = new Registry($this->dbal); $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures12'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures12'], 'exclude' => [], ])); $locator = $tokenizer->classLocator(); @@ -197,19 +201,19 @@ public function testCompositePrimaryKey(ReaderInterface $reader): void $schema = $r->getTableSchema($r->getEntity('compositePost')); - \Testo\Assert::equals($schema->getPrimaryKeys(), ['id', 'user_id']); + Assert::equals($schema->getPrimaryKeys(), ['id', 'user_id']); } - #[\Testo\Data\DataProvider('singularReadersProvider')] - #[\Testo\Test] + #[DataProvider('singularReadersProvider')] + #[Test] public function testIndexWithEmptyColumnsShouldThrowAnException(ReaderInterface $reader): void { - \Testo\Expect::exception(AnnotationException::class)->withMessageContaining('Invalid index definition for `compositePost`. Column list can\'t be empty.'); + Expect::exception(AnnotationException::class)->withMessageContaining('Invalid index definition for `compositePost`. Column list can\'t be empty.'); $r = new Registry($this->dbal); $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures13'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures13'], 'exclude' => [], ])); $locator = $tokenizer->classLocator(); @@ -220,8 +224,8 @@ public function testIndexWithEmptyColumnsShouldThrowAnException(ReaderInterface (new MergeIndexes($reader))->run($r); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testIndexes(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -232,23 +236,23 @@ public function testIndexes(ReaderInterface $reader): void (new MergeIndexes($reader))->run($r); (new SyncTables())->run($r); - \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); + Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - \Testo\Assert::true($schema->hasIndex(['name'])); - \Testo\Assert::true($schema->index(['name'])->isUnique()); - \Testo\Assert::same($schema->index(['name'])->getName(), 'name_index'); + Assert::true($schema->hasIndex(['name'])); + Assert::true($schema->index(['name'])->isUnique()); + Assert::same($schema->index(['name'])->getName(), 'name_index'); - \Testo\Assert::true($schema->hasIndex(['status'])); + Assert::true($schema->hasIndex(['status'])); } - #[\Testo\Data\DataProvider('singularReadersProvider')] - #[\Testo\Test] + #[DataProvider('singularReadersProvider')] + #[Test] public function testOrderedIndexes(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures9'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures9'], 'exclude' => [], ])); @@ -262,16 +266,16 @@ public function testOrderedIndexes(ReaderInterface $reader): void (new MergeIndexes($reader))->run($r); (new SyncTables())->run($r); - \Testo\Assert::true($r->hasTable($r->getEntity('orderedIdx'))); + Assert::true($r->hasTable($r->getEntity('orderedIdx'))); $schema = $r->getTableSchema($r->getEntity('orderedIdx')); - \Testo\Assert::true($schema->hasColumn('name')); - \Testo\Assert::true($schema->hasIndex(['name', 'id DESC'])); + Assert::true($schema->hasColumn('name')); + Assert::true($schema->hasIndex(['name', 'id DESC'])); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testNamingDefault(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -279,15 +283,15 @@ public function testNamingDefault(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); + Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - \Testo\Assert::same($schema->getName(), 'with_tables'); + Assert::same($schema->getName(), 'with_tables'); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testNamingPluralize(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -299,15 +303,15 @@ public function testNamingPluralize(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); + Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - \Testo\Assert::same($schema->getName(), 'with_tables'); + Assert::same($schema->getName(), 'with_tables'); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testNamingSingular(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -319,15 +323,15 @@ public function testNamingSingular(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); + Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - \Testo\Assert::same($schema->getName(), 'with_table'); + Assert::same($schema->getName(), 'with_table'); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testNamingNone(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -339,15 +343,15 @@ public function testNamingNone(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - \Testo\Assert::true($r->hasTable($r->getEntity('withTable'))); + Assert::true($r->hasTable($r->getEntity('withTable'))); $schema = $r->getTableSchema($r->getEntity('withTable')); - \Testo\Assert::same($schema->getName(), 'with_table'); + Assert::same($schema->getName(), 'with_table'); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testReadonlySchema(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -355,15 +359,15 @@ public function testReadonlySchema(ReaderInterface $reader): void (new MergeColumns($reader))->run($r); (new RenderTables())->run($r); - \Testo\Assert::true($r->hasTable($r->getEntity('simple'))); + Assert::true($r->hasTable($r->getEntity('simple'))); $schema = $r->getTableSchema($r->getEntity('simple')); - \Testo\Assert::true($schema->column('read_only_column')->isReadonlySchema()); + Assert::true($schema->column('read_only_column')->isReadonlySchema()); } - #[\Testo\Data\DataProvider('foreignKeyDirectoriesDataProvider')] - #[\Testo\Test] + #[DataProvider('foreignKeyDirectoriesDataProvider')] + #[Test] public function testForeignKeysAnnotationReader( ReaderInterface $reader, string $directory, @@ -371,7 +375,7 @@ public function testForeignKeysAnnotationReader( ): void { $tokenizer = new Tokenizer( new TokenizerConfig([ - 'directories' => [dirname(__DIR__, 3) . $directory], + 'directories' => [dirname(__DIR__, 2) . $directory], 'exclude' => [], ]), ); @@ -392,12 +396,12 @@ public function testForeignKeysAnnotationReader( $foreignKeys = $registry->getTableSchema($registry->getEntity('from'))->getForeignKeys(); $expectedFk = array_shift($foreignKeys); - \Testo\Assert::string($expectedFk->getTable())->contains('from'); - \Testo\Assert::string($expectedFk->getForeignTable())->contains('to'); - \Testo\Assert::same($expectedFk->getColumns(), ['inner_key']); - \Testo\Assert::same($expectedFk->getForeignKeys(), [$outerKey]); - \Testo\Assert::same($expectedFk->getDeleteRule(), 'CASCADE'); - \Testo\Assert::same($expectedFk->getUpdateRule(), 'CASCADE'); - \Testo\Assert::true($expectedFk->hasIndex()); + Assert::string($expectedFk->getTable())->contains('from'); + Assert::string($expectedFk->getForeignTable())->contains('to'); + Assert::same($expectedFk->getColumns(), ['inner_key']); + Assert::same($expectedFk->getForeignKeys(), [$outerKey]); + Assert::same($expectedFk->getDeleteRule(), 'CASCADE'); + Assert::same($expectedFk->getUpdateRule(), 'CASCADE'); + Assert::true($expectedFk->hasIndex()); } } diff --git a/tests/Annotated/Functional/Driver/Common/TypecastTestCase.php b/tests/Annotated/Feature/Common/TypecastTest.php similarity index 79% rename from tests/Annotated/Functional/Driver/Common/TypecastTestCase.php rename to tests/Annotated/Feature/Common/TypecastTest.php index 26964678..c8f324c5 100644 --- a/tests/Annotated/Functional/Driver/Common/TypecastTestCase.php +++ b/tests/Annotated/Feature/Common/TypecastTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Common; +namespace Cycle\Annotated\Tests\Feature\Common; use Cycle\Annotated\Embeddings; use Cycle\Annotated\Entities; @@ -10,6 +10,7 @@ use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; use Cycle\Annotated\MergeIndexes; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Typecast\Typecaster; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Typecast\UuidTypecaster; use Cycle\Annotated\Tests\Fixtures\Fixtures19\BackedEnum; @@ -24,15 +25,17 @@ use Cycle\Schema\Generator\ResetTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; -abstract class TypecastTestCase extends BaseTestCase +final class TypecastTest extends BaseTestCase { - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testEntityWithDefinedTypecastAsString(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -42,11 +45,11 @@ public function testEntityWithDefinedTypecastAsString(ReaderInterface $reader): new MergeColumns($reader), ]); - \Testo\Assert::same($schema['simple'][Schema::TYPECAST_HANDLER], Typecaster::class); + Assert::same($schema['simple'][Schema::TYPECAST_HANDLER], Typecaster::class); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testEntityWithDefinedTypecastAsArray(ReaderInterface $reader): void { $r = new Registry($this->dbal); @@ -56,19 +59,19 @@ public function testEntityWithDefinedTypecastAsArray(ReaderInterface $reader): v new MergeColumns($reader), ]); - \Testo\Assert::same($schema['tag'][Schema::TYPECAST_HANDLER], [ + Assert::same($schema['tag'][Schema::TYPECAST_HANDLER], [ Typecaster::class, UuidTypecaster::class, 'foo', ]); } - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testBackedEnum(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures19'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures19'], 'exclude' => [], ])); @@ -89,7 +92,7 @@ public function testBackedEnum(ReaderInterface $reader): void new GenerateTypecast(), ]); - \Testo\Assert::same($schema['booking'][SchemaInterface::TYPECAST], [ + Assert::same($schema['booking'][SchemaInterface::TYPECAST], [ 'bid' => 'int', 'be' => BackedEnum::class, 'bew' => [BackedEnumWrapper::class, 'typecast'], diff --git a/tests/Annotated/Functional/Driver/MySQL/TableTest.php b/tests/Annotated/Feature/MySQL/TableTest.php similarity index 56% rename from tests/Annotated/Functional/Driver/MySQL/TableTest.php rename to tests/Annotated/Feature/MySQL/TableTest.php index 2d3bab98..4de3aa9b 100644 --- a/tests/Annotated/Functional/Driver/MySQL/TableTest.php +++ b/tests/Annotated/Feature/MySQL/TableTest.php @@ -2,24 +2,25 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\MySQL; +namespace Cycle\Annotated\Tests\Feature\MySQL; -// phpcs:ignore use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; use Cycle\Annotated\MergeColumns; -use Cycle\Annotated\Tests\Functional\Driver\Common\TableTestCase; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\Schema\Generator\RenderTables; use Cycle\Schema\Generator\SyncTables; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\Group; use Spiral\Attributes\AttributeReader; +use Testo\Assert; +use Testo\Test; -#[\Testo\Filter\Group('driver', 'driver-mysql')] -final class TableTest extends TableTestCase +/** + * MySQL-only column options: unsigned, zerofill, charset and collation. + */ +final class TableTest extends BaseTestCase { - public const DRIVER = 'mysql'; - #[\Testo\Test] + #[Test] public function testUnsigned(): void { $reader = new AttributeReader(); @@ -30,15 +31,16 @@ public function testUnsigned(): void $schema = $r->getTableSchema($r->getEntity('label')); - \Testo\Assert::true($schema->column('unsigned')->isUnsigned()); - \Testo\Assert::false($schema->column('simple')->isUnsigned()); + Assert::true($schema->column('unsigned')->isUnsigned()); + Assert::false($schema->column('simple')->isUnsigned()); $schema->save(); - \Testo\Assert::true($this->dbal->database()->table('labels')->getSchema()->column('unsigned')->isUnsigned()); - \Testo\Assert::false($this->dbal->database()->table('labels')->getSchema()->column('simple')->isUnsigned()); + Assert::true($this->dbal->database()->table('labels')->getSchema()->column('unsigned')->isUnsigned()); + Assert::false($this->dbal->database()->table('labels')->getSchema()->column('simple')->isUnsigned()); } - #[\Testo\Test] + + #[Test] public function testZerofill(): void { $reader = new AttributeReader(); @@ -49,15 +51,16 @@ public function testZerofill(): void $schema = $r->getTableSchema($r->getEntity('label')); - \Testo\Assert::true($schema->column('zerofill')->isZerofill()); - \Testo\Assert::false($schema->column('simple')->isZerofill()); + Assert::true($schema->column('zerofill')->isZerofill()); + Assert::false($schema->column('simple')->isZerofill()); $schema->save(); - \Testo\Assert::true($this->dbal->database()->table('labels')->getSchema()->column('zerofill')->isUnsigned()); - \Testo\Assert::false($this->dbal->database()->table('labels')->getSchema()->column('simple')->isUnsigned()); + Assert::true($this->dbal->database()->table('labels')->getSchema()->column('zerofill')->isUnsigned()); + Assert::false($this->dbal->database()->table('labels')->getSchema()->column('simple')->isUnsigned()); } - #[\Testo\Test] + + #[Test] public function testColumnCustomAttributes(): void { $reader = new AttributeReader(); @@ -70,7 +73,7 @@ public function testColumnCustomAttributes(): void $dbSchema = $this->dbal->database()->table('labels')->getSchema(); $attributes = $dbSchema->column('charset_column')->getAttributes(); - \Testo\Assert::same($attributes['charset'], 'ascii'); - \Testo\Assert::same($attributes['collation'], 'ascii_bin'); + Assert::same($attributes['charset'], 'ascii'); + Assert::same($attributes['collation'], 'ascii_bin'); } } diff --git a/tests/Annotated/Functional/Driver/Postgres/GeneratedFieldsTest.php b/tests/Annotated/Feature/Postgres/GeneratedFieldsTest.php similarity index 60% rename from tests/Annotated/Functional/Driver/Postgres/GeneratedFieldsTest.php rename to tests/Annotated/Feature/Postgres/GeneratedFieldsTest.php index 0f49ebfe..431cd277 100644 --- a/tests/Annotated/Functional/Driver/Postgres/GeneratedFieldsTest.php +++ b/tests/Annotated/Feature/Postgres/GeneratedFieldsTest.php @@ -2,32 +2,33 @@ declare(strict_types=1); -namespace Cycle\Annotated\Tests\Functional\Driver\Postgres; +namespace Cycle\Annotated\Tests\Feature\Postgres; -// phpcs:ignore use Cycle\Annotated\Entities; use Cycle\Annotated\Locator\TokenizerEntityLocator; -use Cycle\Annotated\Tests\Functional\Driver\Common\GeneratedFieldsTestCase; +use Cycle\Annotated\Tests\Feature\BaseTestCase; use Cycle\ORM\Schema\GeneratedField; use Cycle\ORM\SchemaInterface; use Cycle\Schema\Compiler; use Cycle\Schema\Registry; -use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\Attributes\Group; use Spiral\Attributes\ReaderInterface; use Spiral\Tokenizer\Config\TokenizerConfig; use Spiral\Tokenizer\Tokenizer; - -#[\Testo\Filter\Group('driver', 'driver-postgres')] -final class GeneratedFieldsTest extends GeneratedFieldsTestCase +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; + +/** + * Postgres serial columns (smallserial, serial, bigserial) are generated on insert. + */ +final class GeneratedFieldsTest extends BaseTestCase { - public const DRIVER = 'postgres'; - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] + #[DataProvider('allReadersProvider')] + #[Test] public function testSerialGeneratedFields(ReaderInterface $reader): void { $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures25/PostgreSQL'], + 'directories' => [__DIR__ . '/../../Fixtures/Fixtures25/PostgreSQL'], 'exclude' => [], ])); @@ -39,7 +40,7 @@ public function testSerialGeneratedFields(ReaderInterface $reader): void new Entities(new TokenizerEntityLocator($locator, $reader), $reader), ]); - \Testo\Assert::same($schema['withGeneratedSerial'][SchemaInterface::GENERATED_FIELDS], [ + Assert::same($schema['withGeneratedSerial'][SchemaInterface::GENERATED_FIELDS], [ 'id' => GeneratedField::ON_INSERT, 'smallSerial' => GeneratedField::ON_INSERT, 'serial' => GeneratedField::ON_INSERT, diff --git a/tests/Annotated/Fixtures/Fixtures1/TestLogger.php b/tests/Annotated/Fixtures/Fixtures1/TestLogger.php deleted file mode 100644 index 03840cf4..00000000 --- a/tests/Annotated/Fixtures/Fixtures1/TestLogger.php +++ /dev/null @@ -1,105 +0,0 @@ -countWrites = 0; - $this->countReads = 0; - } - - public function countWriteQueries(): int - { - return $this->countWrites; - } - - public function countReadQueries(): int - { - return $this->countReads; - } - - public function log($level, $message, array $context = []): void - { - if (!empty($context['query'])) { - $sql = strtolower($context['query']); - if ( - strpos($sql, 'insert') === 0 - || strpos($sql, 'update') === 0 - || strpos($sql, 'delete') === 0 - ) { - $this->countWrites++; - } else { - if (!$this->isPostgresSystemQuery($sql)) { - $this->countReads++; - } - } - } - - if (!$this->display) { - 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"; - } else { - if ($this->isPostgresSystemQuery($message)) { - echo " \n> \033[90m" . $message . "\033[0m"; - - return; - } - - if (strpos($message, 'SELECT') === 0) { - echo " \n> \033[32m" . $message . "\033[0m"; - } elseif (strpos($message, 'INSERT') === 0) { - echo " \n> \033[36m" . $message . "\033[0m"; - } else { - echo " \n> \033[33m" . $message . "\033[0m"; - } - } - } - - public function display(): void - { - $this->display = true; - } - - public function hide(): void - { - $this->display = false; - } - - protected function isPostgresSystemQuery(string $query): bool - { - $query = strtolower($query); - return (bool) ( - strpos($query, 'tc.constraint_name') - || strpos($query, 'pg_indexes') - || strpos($query, 'tc.constraint_name') - || strpos($query, 'pg_constraint') - || strpos($query, 'information_schema') - || strpos($query, 'pg_class') - ) - - - - ; - } -} diff --git a/tests/Annotated/Functional/Driver/Common/BaseTestCase.php b/tests/Annotated/Functional/Driver/Common/BaseTestCase.php deleted file mode 100644 index 40288eb2..00000000 --- a/tests/Annotated/Functional/Driver/Common/BaseTestCase.php +++ /dev/null @@ -1,168 +0,0 @@ - [new AnnotationReader()]; - yield 'Attribute reader' => [new AttributeReader()]; - } - - public static function allReadersProvider(): \Traversable - { - yield from static::singularReadersProvider(); - yield 'Selective reader' => [new SelectiveReader([new AttributeReader(), new AnnotationReader()])]; - } - - public function getDriver(): Driver - { - if (isset(static::$driverCache[static::DRIVER])) { - return static::$driverCache[static::DRIVER]; - } - - $config = self::$config[static::DRIVER]; - if (!isset($this->driver)) { - $this->driver = $config->driver::create($config); - } - - $this->driver->setProfiling(true); - - return static::$driverCache[static::DRIVER] = $this->driver; - } - - /** - * Init all we need. - */ - #[\Testo\Lifecycle\BeforeTest] - public function setUp(): void - { - $this->dbal = new DatabaseManager(new DatabaseConfig(['default' => 'default'])); - $this->dbal->addDatabase(new Database( - 'default', - '', - $this->getDriver(), - )); - - $this->dbal->addDatabase(new Database( - 'secondary', - 'secondary_', - $this->getDriver(), - )); - - $this->logger = new TestLogger(); - $this->getDriver()->setLogger($this->logger); - - if (self::$config['debug']) { - $this->logger->display(); - } - - $this->logger = new TestLogger(); - $this->getDriver()->setLogger($this->logger); - - if (self::$config['debug']) { - $this->logger->display(); - } - - $this->orm = new ORM(new Factory( - $this->dbal, - RelationConfig::getDefault(), - ), new Schema([])); - - $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures1'], - 'exclude' => [], - ])); - - $this->locator = $tokenizer->classLocator(); - } - - /** - * Cleanup. - */ - #[\Testo\Lifecycle\AfterTest] - public function tearDown(): void - { - $this->disableProfiling(); - $this->dropDatabase($this->dbal->database('default')); - } - - protected function getDatabase(): Database - { - return $this->dbal->database('default'); - } - - protected function dropDatabase(?Database $database = null): void - { - if (empty($database)) { - 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(); - } - } - - /** - * For debug purposes only. - */ - protected function enableProfiling(): void - { - $this->logger->display(); - } - - /** - * For debug purposes only. - */ - protected function disableProfiling(): void - { - $this->logger->hide(); - } -} diff --git a/tests/Annotated/Functional/Driver/Common/GeneratorTestCase.php b/tests/Annotated/Functional/Driver/Common/GeneratorTestCase.php deleted file mode 100644 index 5795f41d..00000000 --- a/tests/Annotated/Functional/Driver/Common/GeneratorTestCase.php +++ /dev/null @@ -1,153 +0,0 @@ -dbal); - (new Entities(new TokenizerEntityLocator($this->locator)))->run($r); - - \Testo\Assert::true($r->hasEntity(Simple::class)); - \Testo\Assert::true($r->hasEntity(WithTable::class)); - \Testo\Assert::true($r->hasEntity(Complete::class)); - } - - #[\Testo\Test] - public function testCreateGeneratorsWithDoctrineAnnotationReader(): void - { - $reader = new DoctrineAnnotationReader(); - $r = new Registry($this->dbal); - - (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); - (new MergeColumns($reader))->run($r); - (new RenderTables())->run($r); - (new MergeIndexes($reader))->run($r); - (new SyncTables())->run($r); - - // Entities - \Testo\Assert::true($r->hasEntity(Simple::class)); - \Testo\Assert::true($r->hasEntity(WithTable::class)); - \Testo\Assert::true($r->hasEntity(Complete::class)); - // MergeColumns - $schema = $r->getTableSchema($r->getEntity('withTable')); - \Testo\Assert::true($schema->hasColumn('name')); - \Testo\Assert::same($schema->column('status')->getType(), 'string'); - // MergeIndexes - \Testo\Assert::true($schema->hasIndex(['name'])); - \Testo\Assert::true($schema->index(['name'])->isUnique()); - \Testo\Assert::same($schema->index(['name'])->getName(), 'name_index'); - } - - #[\Testo\Test] - public function testCreateGeneratorsWithCustomMergeReader(): void - { - $reader = new MergeReader([new AnnotationReader(), new AttributeReader()]); - $r = new Registry($this->dbal); - - $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../Fixtures/Fixtures10'], - 'exclude' => [], - ])); - $locator = $tokenizer->classLocator(); - - (new Entities(new TokenizerEntityLocator($locator, $reader), $reader))->run($r); - (new MergeColumns($reader))->run($r); - (new RenderTables())->run($r); - (new MergeIndexes($reader))->run($r); - (new SyncTables())->run($r); - - - \Testo\Assert::true($r->hasTable($r->getEntity('MergedMeta'))); - $schema = $r->getTableSchema($r->getEntity('MergedMeta')); - \Testo\Assert::true($schema->hasColumn('name')); - \Testo\Assert::true($schema->hasIndex(['name', 'id DESC'])); - } - - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] - public function testLocateAll(ReaderInterface $reader): void - { - $r = new Registry($this->dbal); - (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); - - \Testo\Assert::true($r->hasEntity(Simple::class)); - \Testo\Assert::true($r->hasEntity(WithTable::class)); - \Testo\Assert::true($r->hasEntity(Complete::class)); - } - - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] - public function testSimpleSchema(ReaderInterface $reader): void - { - $r = new Registry($this->dbal); - (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); - - \Testo\Assert::true($r->hasEntity(Simple::class)); - \Testo\Assert::true($r->hasEntity('simple')); - - \Testo\Assert::same($r->getEntity('simple')->getMapper(), null); - \Testo\Assert::same($r->getEntity('simple')->getRepository(), null); - - \Testo\Assert::true($r->hasTable($r->getEntity('simple'))); - \Testo\Assert::same($r->getDatabase($r->getEntity('simple')), 'default'); - \Testo\Assert::same($r->getTable($r->getEntity('simple')), 'simples'); - - \Testo\Assert::true($r->getEntity('simple')->getFields()->has('id')); - \Testo\Assert::same($r->getEntity('simple')->getFields()->get('id')->getColumn(), 'id'); - } - - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] - public function testCompleteSchema(ReaderInterface $reader): void - { - $r = new Registry($this->dbal); - (new Entities(new TokenizerEntityLocator($this->locator, $reader), $reader))->run($r); - - \Testo\Assert::true($r->hasEntity(Complete::class)); - \Testo\Assert::true($r->hasEntity('eComplete')); - - \Testo\Assert::same($r->getEntity('eComplete')->getMapper(), CompleteMapper::class); - \Testo\Assert::same($r->getEntity('eComplete')->getRepository(), CompleteRepository::class); - \Testo\Assert::same($r->getEntity('eComplete')->getSource(), TestSource::class); - \Testo\Assert::same($r->getEntity('eComplete')->getScope(), SomeConstrain::class); - - \Testo\Assert::true($r->hasTable($r->getEntity('eComplete'))); - \Testo\Assert::same($r->getDatabase($r->getEntity('eComplete')), 'secondary'); - \Testo\Assert::same($r->getTable($r->getEntity('eComplete')), 'complete_data'); - - \Testo\Assert::true($r->getEntity('eComplete')->getFields()->has('id')); - \Testo\Assert::true($r->getEntity('eComplete')->getFields()->has('name')); - - \Testo\Assert::same($r->getEntity('eComplete')->getFields()->get('name')->getColumn(), 'username'); - - \Testo\Assert::false($r->getEntity('eComplete')->getFields()->has('ignored')); - } -} diff --git a/tests/Annotated/Functional/Driver/Common/Relation/InverseTestCase.php b/tests/Annotated/Functional/Driver/Common/Relation/InverseTestCase.php deleted file mode 100644 index 7f3640f0..00000000 --- a/tests/Annotated/Functional/Driver/Common/Relation/InverseTestCase.php +++ /dev/null @@ -1,213 +0,0 @@ - [__DIR__ . '/../../../../Fixtures/Fixtures2'], - 'exclude' => [], - ])); - - $locator = $tokenizer->classLocator(); - - $r = new Registry($this->dbal); - - $schema = (new Compiler())->compile($r, [ - new Entities(new TokenizerEntityLocator($locator, $reader), $reader), - new ResetTables(), - new MergeColumns($reader), - new GenerateRelations(), - new ValidateEntities(), - new RenderTables(), - new RenderRelations(), - new MergeIndexes($reader), - new SyncTables(), - new GenerateTypecast(), - ]); - - \Testo\Assert::array($schema['eComplete'][Schema::RELATIONS])->hasKeys('parent'); - \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TYPE], Relation::BELONGS_TO); - \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['parent'][Relation::TARGET], 'simple'); - - \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('child'); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['child'][Relation::TYPE], Relation::HAS_ONE); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['child'][Relation::TARGET], 'eComplete'); - } - - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] - public function testBelongsToMany(ReaderInterface $reader): void - { - $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures2'], - 'exclude' => [], - ])); - - $locator = $tokenizer->classLocator(); - - $r = new Registry($this->dbal); - - $schema = (new Compiler())->compile($r, [ - new Entities(new TokenizerEntityLocator($locator, $reader), $reader), - new ResetTables(), - new MergeColumns($reader), - new GenerateRelations(), - new ValidateEntities(), - new RenderTables(), - new RenderRelations(), - new MergeIndexes($reader), - new SyncTables(), - new GenerateTypecast(), - ]); - - \Testo\Assert::array($schema['eComplete'][Schema::RELATIONS])->hasKeys('uncles'); - \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['uncles'][Relation::TYPE], Relation::BELONGS_TO); - \Testo\Assert::same($schema['eComplete'][Schema::RELATIONS]['uncles'][Relation::TARGET], 'simple'); - - \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('stepKids'); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['stepKids'][Relation::TYPE], Relation::HAS_MANY); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['stepKids'][Relation::TARGET], 'eComplete'); - } - - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] - public function testHasOne(ReaderInterface $reader): void - { - $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures2'], - 'exclude' => [], - ])); - - $locator = $tokenizer->classLocator(); - - $r = new Registry($this->dbal); - - $schema = (new Compiler())->compile($r, [ - new Entities(new TokenizerEntityLocator($locator, $reader), $reader), - new ResetTables(), - new MergeColumns($reader), - new GenerateRelations(), - new ValidateEntities(), - new RenderTables(), - new RenderRelations(), - new MergeIndexes($reader), - new SyncTables(), - new GenerateTypecast(), - ]); - - \Testo\Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('simple'); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TYPE], Relation::HAS_ONE); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TARGET], 'simple'); - - \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('user'); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TYPE], Relation::BELONGS_TO); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TARGET], 'user'); - } - - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] - public function testHasOneInverseLoad(ReaderInterface $reader): void - { - $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures5'], - 'exclude' => [], - ])); - - $locator = $tokenizer->classLocator(); - - $r = new Registry($this->dbal); - - $schema = (new Compiler())->compile($r, [ - new Entities(new TokenizerEntityLocator($locator, $reader), $reader), - new ResetTables(), - new MergeColumns($reader), - new GenerateRelations(), - new ValidateEntities(), - new RenderTables(), - new RenderRelations(), - new MergeIndexes($reader), - new SyncTables(), - new GenerateTypecast(), - ]); - - \Testo\Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('simple'); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TYPE], Relation::HAS_ONE); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::TARGET], 'simple'); - - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['simple'][Relation::LOAD], Relation::LOAD_EAGER); - - \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('user'); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TYPE], Relation::BELONGS_TO); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::TARGET], 'user'); - - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['user'][Relation::LOAD], Relation::LOAD_PROMISE); - } - - #[\Testo\Data\DataProvider('allReadersProvider')] - #[\Testo\Test] - public function testBelongsTo(ReaderInterface $reader): void - { - $tokenizer = new Tokenizer(new TokenizerConfig([ - 'directories' => [__DIR__ . '/../../../../Fixtures/Fixtures2'], - 'exclude' => [], - ])); - - $locator = $tokenizer->classLocator(); - - $r = new Registry($this->dbal); - - $schema = (new Compiler())->compile($r, [ - new Entities(new TokenizerEntityLocator($locator, $reader), $reader), - new ResetTables(), - new MergeColumns($reader), - new GenerateRelations(), - new ValidateEntities(), - new RenderTables(), - new RenderRelations(), - new MergeIndexes($reader), - new SyncTables(), - new GenerateTypecast(), - ]); - - \Testo\Assert::array($schema['mark'][Schema::RELATIONS])->hasKeys('owner'); - \Testo\Assert::same($schema['mark'][Schema::RELATIONS]['owner'][Relation::TYPE], Relation::BELONGS_TO_MORPHED); - \Testo\Assert::same($schema['mark'][Schema::RELATIONS]['owner'][Relation::TARGET], MarkedInterface::class); - - \Testo\Assert::array($schema['user'][Schema::RELATIONS])->hasKeys('mark'); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['mark'][Relation::TYPE], Relation::MORPHED_HAS_ONE); - \Testo\Assert::same($schema['user'][Schema::RELATIONS]['mark'][Relation::TARGET], 'mark'); - - \Testo\Assert::array($schema['simple'][Schema::RELATIONS])->hasKeys('mark'); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['mark'][Relation::TYPE], Relation::MORPHED_HAS_ONE); - \Testo\Assert::same($schema['simple'][Schema::RELATIONS]['mark'][Relation::TARGET], 'mark'); - } -} diff --git a/tests/Annotated/Functional/Driver/MySQL/ChildTest.php b/tests/Annotated/Functional/Driver/MySQL/ChildTest.php deleted file mode 100644 index c12aaaee..00000000 --- a/tests/Annotated/Functional/Driver/MySQL/ChildTest.php +++ /dev/null @@ -1,16 +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/Annotated/Unit/Attribute/ColumnTest.php b/tests/Annotated/Unit/Attribute/ColumnTest.php index 20b37e83..1f1ec71b 100644 --- a/tests/Annotated/Unit/Attribute/ColumnTest.php +++ b/tests/Annotated/Unit/Attribute/ColumnTest.php @@ -6,9 +6,11 @@ use Cycle\Annotated\Annotation\Column; use Cycle\Annotated\Tests\Unit\Attribute\SingleTable\StringEnum; -use PHPUnit\Framework\TestCase; +use Testo\Assert; +use Testo\Test; -class ColumnTest +#[Test] +final class ColumnTest { public const ENUM_VALUE_A = 'a'; public const ENUM_VALUE_B = 'b'; @@ -60,101 +62,90 @@ class ColumnTest )] private StringEnum $column10 = StringEnum::A; - #[\Testo\Test] public function testOneAttribute(): void { $column = $this->getColumn('column1'); - \Testo\Assert::same($column->getAttributes(), ['unsigned' => true]); + Assert::same($column->getAttributes(), ['unsigned' => true]); } - #[\Testo\Test] public function testTwoAttributes(): void { $column = $this->getColumn('column2'); - \Testo\Assert::same($column->getAttributes(), ['unsigned' => true, 'zerofill' => true]); + Assert::same($column->getAttributes(), ['unsigned' => true, 'zerofill' => true]); } - #[\Testo\Test] public function testCustomSizeAttribute(): void { $column = $this->getColumn('column3'); - \Testo\Assert::same($column->getAttributes(), ['size' => 128]); + Assert::same($column->getAttributes(), ['size' => 128]); } - #[\Testo\Test] public function testDefaultReadonlySchema(): void { $column = $this->getColumn('column1'); - \Testo\Assert::false($column->isReadonlySchema()); + Assert::false($column->isReadonlySchema()); } - #[\Testo\Test] public function testReadonlySchema(): void { $column = $this->getColumn('column4'); - \Testo\Assert::true($column->isReadonlySchema()); + Assert::true($column->isReadonlySchema()); } - #[\Testo\Test] public function testEnumTypeString(): void { $column = $this->getColumn('column5'); - \Testo\Assert::same($column->getType(), 'enum(a,b)'); + Assert::same($column->getType(), 'enum(a,b)'); } - #[\Testo\Test] public function testEnumTypeArray(): void { $column = $this->getColumn('column6'); - \Testo\Assert::same($column->getType(), 'enum(a,b)'); - \Testo\Assert::same($column->getDefault(), 'a'); - \Testo\Assert::array($column->getAttributes())->doesNotHaveKeys('values'); + Assert::same($column->getType(), 'enum(a,b)'); + Assert::same($column->getDefault(), 'a'); + Assert::array($column->getAttributes())->doesNotHaveKeys('values'); } - #[\Testo\Test] public function testEnumTypeBackedEnum(): void { $column = $this->getColumn('column7'); - \Testo\Assert::same($column->getType(), 'enum(a,b)'); - \Testo\Assert::same($column->getDefault(), 'a'); - \Testo\Assert::array($column->getAttributes())->doesNotHaveKeys('values'); + Assert::same($column->getType(), 'enum(a,b)'); + Assert::same($column->getDefault(), 'a'); + Assert::array($column->getAttributes())->doesNotHaveKeys('values'); } - #[\Testo\Test] public function testEnumTypeArrayBackedEnum(): void { $column = $this->getColumn('column8'); - \Testo\Assert::same($column->getType(), 'enum(a,b)'); - \Testo\Assert::same($column->getDefault(), 'a'); - \Testo\Assert::array($column->getAttributes())->doesNotHaveKeys('values'); + Assert::same($column->getType(), 'enum(a,b)'); + Assert::same($column->getDefault(), 'a'); + Assert::array($column->getAttributes())->doesNotHaveKeys('values'); } - #[\Testo\Test] public function testEnumTypeBackedEnumAsDefault(): void { $column = $this->getColumn('column10'); - \Testo\Assert::same($column->getType(), 'enum(a,b)'); - \Testo\Assert::same($column->getDefault(), 'a'); - \Testo\Assert::array($column->getAttributes())->doesNotHaveKeys('values'); + Assert::same($column->getType(), 'enum(a,b)'); + Assert::same($column->getDefault(), 'a'); + Assert::array($column->getAttributes())->doesNotHaveKeys('values'); } - #[\Testo\Test] public function testCharsetAndCollationAttributes(): void { $column = $this->getColumn('column9'); - \Testo\Assert::same($column->getType(), 'string'); - \Testo\Assert::same($column->getAttributes(), [ + Assert::same($column->getType(), 'string'); + Assert::same($column->getAttributes(), [ 'length' => 255, 'charset' => 'ascii', 'collation' => 'ascii_bin', @@ -163,7 +154,7 @@ public function testCharsetAndCollationAttributes(): void private function getColumn(string $field): Column { - $ref = new \ReflectionClass(static::class); + $ref = new \ReflectionClass(self::class); return $ref->getProperty($field)->getAttributes(Column::class)[0]->newInstance(); } } diff --git a/tests/Annotated/Unit/Attribute/SingleTable/SingleTableTest.php b/tests/Annotated/Unit/Attribute/SingleTable/SingleTableTest.php index 8a49bc52..a7208651 100644 --- a/tests/Annotated/Unit/Attribute/SingleTable/SingleTableTest.php +++ b/tests/Annotated/Unit/Attribute/SingleTable/SingleTableTest.php @@ -5,9 +5,11 @@ namespace Cycle\Annotated\Tests\Unit\Attribute\SingleTable; use Cycle\Annotated\Annotation\Inheritance\SingleTable; -use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\TestCase; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; +#[Test] final class SingleTableTest { public static function dataBase(): iterable @@ -21,12 +23,11 @@ public static function dataBase(): iterable yield ['a', StringEnum::A]; } - #[\Testo\Data\DataProvider('dataBase')] - #[\Testo\Test] + #[DataProvider('dataBase')] public function testBase1(?string $expected, mixed $value): void { $attribute = new SingleTable($value); - \Testo\Assert::same($attribute->getValue(), $expected); + Assert::same($attribute->getValue(), $expected); } } diff --git a/tests/Annotated/Unit/Locator/TokenizerEmbeddingLocatorTest.php b/tests/Annotated/Unit/Locator/TokenizerEmbeddingLocatorTest.php index d270c1c5..3b6e5240 100644 --- a/tests/Annotated/Unit/Locator/TokenizerEmbeddingLocatorTest.php +++ b/tests/Annotated/Unit/Locator/TokenizerEmbeddingLocatorTest.php @@ -9,10 +9,12 @@ use Cycle\Annotated\Locator\TokenizerEmbeddingLocator; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Child; use Cycle\Annotated\Tests\Fixtures\Fixtures7\Address; -use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\TestCase; -use Spiral\Tokenizer\ClassesInterface; +use Cycle\Testing\ORM\Schema\ClassList; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; +#[Test] final class TokenizerEmbeddingLocatorTest { public static function classesDataProvider(): \Traversable @@ -33,15 +35,13 @@ public static function classesDataProvider(): \Traversable ]; } - #[\Testo\Data\DataProvider('classesDataProvider')] - #[\Testo\Test] + #[DataProvider('classesDataProvider')] public function testGetEmbeddings(array $expected, array $classes): void { - $mock = $this->createMock(ClassesInterface::class); - $mock->method('getClasses')->willReturn($classes); + $source = new ClassList(...\array_keys($classes)); - $locator = new TokenizerEmbeddingLocator($mock); + $locator = new TokenizerEmbeddingLocator($source); - \Testo\Assert::equals($locator->getEmbeddings(), $expected); + Assert::equals($locator->getEmbeddings(), $expected); } } diff --git a/tests/Annotated/Unit/Locator/TokenizerEntityLocatorTest.php b/tests/Annotated/Unit/Locator/TokenizerEntityLocatorTest.php index ab92d4a1..d2f9cfe7 100644 --- a/tests/Annotated/Unit/Locator/TokenizerEntityLocatorTest.php +++ b/tests/Annotated/Unit/Locator/TokenizerEntityLocatorTest.php @@ -12,10 +12,12 @@ use Cycle\Annotated\Tests\Fixtures\Fixtures1\Typecast\Typecaster; use Cycle\Annotated\Tests\Fixtures\Fixtures1\Typecast\UuidTypecaster; use Cycle\Annotated\Tests\Fixtures\Fixtures1\WithTable; -use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\TestCase; -use Spiral\Tokenizer\ClassesInterface; +use Cycle\Testing\ORM\Schema\ClassList; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Test; +#[Test] final class TokenizerEntityLocatorTest { public static function classesDataProvider(): \Traversable @@ -40,15 +42,13 @@ public static function classesDataProvider(): \Traversable ]; } - #[\Testo\Data\DataProvider('classesDataProvider')] - #[\Testo\Test] + #[DataProvider('classesDataProvider')] public function testGetEntities(array $expected, array $classes): void { - $mock = $this->createMock(ClassesInterface::class); - $mock->method('getClasses')->willReturn($classes); + $source = new ClassList(...\array_keys($classes)); - $locator = new TokenizerEntityLocator($mock); + $locator = new TokenizerEntityLocator($source); - \Testo\Assert::equals($locator->getEntities(), $expected); + Assert::equals($locator->getEntities(), $expected); } } diff --git a/tests/Annotated/Unit/ReaderFactoryTest.php b/tests/Annotated/Unit/ReaderFactoryTest.php index 9cc11ac0..308898a2 100644 --- a/tests/Annotated/Unit/ReaderFactoryTest.php +++ b/tests/Annotated/Unit/ReaderFactoryTest.php @@ -6,35 +6,34 @@ use Cycle\Annotated\ReaderFactory; use Doctrine\Common\Annotations\AnnotationReader as DoctrineAnnotationReader; -use PHPUnit\Framework\TestCase; use Spiral\Attributes\AnnotationReader; use Spiral\Attributes\AttributeReader; use Spiral\Attributes\Composite\MergeReader; +use Testo\Assert; +use Testo\Test; -class ReaderFactoryTest +#[Test] +final class ReaderFactoryTest { - #[\Testo\Test] public function testCreateFromNull(): void { $reader = ReaderFactory::create(null); - \Testo\Assert::instanceOf($reader, AttributeReader::class); + Assert::instanceOf($reader, AttributeReader::class); } - #[\Testo\Test] public function testCreateFromDoctrineReader(): void { $reader = ReaderFactory::create(new DoctrineAnnotationReader()); - \Testo\Assert::instanceOf($reader, AnnotationReader::class); + Assert::instanceOf($reader, AnnotationReader::class); } - #[\Testo\Test] public function testCreateFromCustomReader(): void { $mergeReader = new MergeReader([]); $reader = ReaderFactory::create($mergeReader); - \Testo\Assert::same($reader, $mergeReader); + Assert::same($reader, $mergeReader); } } diff --git a/tests/Annotated/Unit/Utils/EntityUtilsTest.php b/tests/Annotated/Unit/Utils/EntityUtilsTest.php index 2e2d0f35..c7cde20f 100644 --- a/tests/Annotated/Unit/Utils/EntityUtilsTest.php +++ b/tests/Annotated/Unit/Utils/EntityUtilsTest.php @@ -7,13 +7,16 @@ use Cycle\Annotated\Exception\AnnotationException; use Cycle\Annotated\Tests\Fixtures\Fixtures22\Attributed\Person; use Cycle\Annotated\Utils\EntityUtils; -use PHPUnit\Framework\Attributes\DataProvider; -use PHPUnit\Framework\TestCase; use Spiral\Attributes\AnnotationReader; use Spiral\Attributes\AttributeReader; use Spiral\Attributes\ReaderInterface; +use Testo\Assert; +use Testo\Data\DataProvider; +use Testo\Expect; +use Testo\Test; -class EntityUtilsTest +#[Test] +final class EntityUtilsTest { public static function findParentDataProvider(): iterable { @@ -46,8 +49,7 @@ public static function findParentDataProvider(): iterable } } - #[\Testo\Data\DataProvider('findParentDataProvider')] - #[\Testo\Test] + #[DataProvider('findParentDataProvider')] public function testFindParent( ReaderInterface $reader, string $child, @@ -58,15 +60,14 @@ public function testFindParent( $actualParent = $entityUtils->findParent($child, $root); - \Testo\Assert::equals($actualParent, $expectedParent); + Assert::equals($actualParent, $expectedParent); } - #[\Testo\Test] public function testGetParentException(): void { $entityUtils = new EntityUtils(new AttributeReader()); - \Testo\Expect::exception(AnnotationException::class)->withMessageContaining(\sprintf('The parent class could not be found for the class `%s`.', Person::class)); + Expect::exception(AnnotationException::class)->withMessageContaining(\sprintf('The parent class could not be found for the class `%s`.', Person::class)); $entityUtils->getParent(Person::class); } } diff --git a/tests/Annotated/Util/TableRenderer.php b/tests/Annotated/Util/TableRenderer.php deleted file mode 100644 index c87a1afb..00000000 --- a/tests/Annotated/Util/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/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index eb42c44b..00000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,60 +0,0 @@ - new Config\SQLiteDriverConfig( - queryCache: true, - ), - 'mysql' => new Config\MySQLDriverConfig( - connection: new Config\MySQL\TcpConnectionConfig( - database: 'spiral', - host: '127.0.0.1', - port: 13306, - user: 'root', - password: 'YourStrong!Passw0rd', - ), - queryCache: true, - ), - 'postgres' => new Config\PostgresDriverConfig( - connection: new Config\Postgres\TcpConnectionConfig( - database: 'spiral', - host: '127.0.0.1', - port: 15432, - user: 'postgres', - password: 'YourStrong!Passw0rd', - ), - schema: 'public', - queryCache: true, - ), - 'sqlserver' => new Config\SQLServerDriverConfig( - connection: new Config\SQLServer\TcpConnectionConfig( - database: 'tempdb', - host: '127.0.0.1', - port: 11433, - trustServerCertificate: true, - user: 'SA', - password: 'YourStrong!Passw0rd', - ), - queryCache: true, - ), -]; - -$db = getenv('DB') ?: null; -\Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase::$config = [ - 'debug' => false, - 'strict' => true, - 'benchmark' => 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 9c4b5111..00000000 --- a/tests/docker-compose.yml +++ /dev/null @@ -1,29 +0,0 @@ -version: "3" - -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/fix-binlog.sh b/tests/fix-binlog.sh deleted file mode 100644 index 3a6dee32..00000000 --- a/tests/fix-binlog.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -set -ex -sed -i '/\[mysqld\]/a\ -binlog_format = MIXED' /etc/mysql/my.cnf -sudo service mysql restart \ No newline at end of file diff --git a/tests/generate.php b/tests/generate.php deleted file mode 100644 index 3558c773..00000000 --- a/tests/generate.php +++ /dev/null @@ -1,113 +0,0 @@ - [__DIR__ . '/Annotated/Functional/Driver/Common'], - 'exclude' => [], -])); - -$databases = [ - 'sqlite' => [ - 'namespace' => 'Cycle\Annotated\Tests\Functional\Driver\SQLite', - 'directory' => __DIR__ . '/Annotated/Functional/Driver/SQLite/', - ], - 'mysql' => [ - 'namespace' => 'Cycle\Annotated\Tests\Functional\Driver\MySQL', - 'directory' => __DIR__ . '/Annotated/Functional/Driver/MySQL/', - ], - 'postgres' => [ - 'namespace' => 'Cycle\Annotated\Tests\Functional\Driver\Postgres', - 'directory' => __DIR__ . '/Annotated/Functional/Driver/Postgres/', - ], - 'sqlserver' => [ - 'namespace' => 'Cycle\Annotated\Tests\Functional\Driver\SQLServer', - 'directory' => __DIR__ . '/Annotated/Functional/Driver/SQLServer/', - ], -]; - -echo "Generating test classes for all database types...\n"; - -$classes = $tokenizer->classLocator()->getClasses(\Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase::class); - -foreach ($classes as $baseClass) { - foreach ($baseClass->getMethods() as $method) { - if ($method->isAbstract()) { - echo "Skip class {$baseClass->getName()} with abstract methods.\n"; - continue 2; - } - } - - if ( - !$baseClass->isAbstract() - // Has abstract methods - || $baseClass->getName() == \Cycle\Annotated\Tests\Functional\Driver\Common\BaseTestCase::class - ) { - continue; - } - - echo "Found {$baseClass->getName()}\n"; - - $path = str_replace( - [str_replace('\\', '/', __DIR__), 'Annotated/Functional/Driver/Common/'], - '', - str_replace('\\', '/', \str_replace('TestCase', 'Test', $baseClass->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\\Annotated\\Tests\\Functional\\Driver\\Common', - $details['namespace'], - $baseClass->getNamespaceName(), - ); - - if (!is_dir($dir)) { - mkdir($dir, recursive: true); - } - - file_put_contents( - $filename, - sprintf( - <<getName(), - $driver, - \str_replace('TestCase', 'Test', $baseClass->getShortName()), - $baseClass->getShortName(), - $driver, - ), - ); - } -} diff --git a/tests/install-pgsql-10.sh b/tests/install-pgsql-10.sh deleted file mode 100644 index 2653213e..00000000 --- a/tests/install-pgsql-10.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash -set -ex -# from Doctrine -sudo service postgresql stop -sudo apt-get remove -q 'postgresql-*' -sudo apt-get update -q -sudo apt-get install -q postgresql-10 postgresql-client-10 -sudo cp /etc/postgresql/{9.6,10}/main/pg_hba.conf -sudo service postgresql restart \ No newline at end of file diff --git a/tests/install-sqlsrv.sh b/tests/install-sqlsrv.sh deleted file mode 100644 index fd2d6871..00000000 --- a/tests/install-sqlsrv.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -ex -curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - -curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list -sudo apt-get update - -sudo ACCEPT_EULA=Y apt-get install -qy msodbcsql17 mssql-tools From a46bab9bba0cf0282eaec7b98097d26ba49a1767 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 12:19:56 +0400 Subject: [PATCH 05/12] build: run the test suite with Testo ci: run each server driver in its own job docs: describe running the tests in the README Server drivers run on the lowest and highest supported PHP only, to keep the job count down; the full PHP matrix still runs Unit and SQLite. Assisted-By: Claude Opus 5.5 --- .github/workflows/main.yml | 79 ++++++++++++++++++++++++++++++-------- README.md | 14 +++++++ composer.json | 14 ++++--- phpunit.xml | 23 ----------- 4 files changed, 85 insertions(+), 45 deletions(-) delete mode 100644 phpunit.xml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4ed2a1e4..d8649856 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,7 +14,7 @@ concurrency: jobs: test: - name: Test PHP ${{ matrix.php-version }} (${{ matrix.dependencies }}) + name: Unit + SQLite, PHP ${{ matrix.php-version }} (${{ matrix.dependencies }}) runs-on: ubuntu-latest strategy: fail-fast: false @@ -22,44 +22,89 @@ jobs: php-version: ['8.2', '8.3', '8.4', '8.5'] dependencies: [lowest, 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 - run: | - cd tests - docker compose up -d - cd .. - - name: Setup PHP ${{ matrix.php-version }} uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-version }} coverage: pcov - tools: pecl - extensions: mbstring, pdo, pdo_sqlite, pdo_pgsql, pdo_sqlsrv, pdo_mysql + extensions: mbstring, pdo, pdo_sqlite - name: Validate composer.json run: composer validate --ansi --strict + # TODO(cycle/testing): switch to the released package - name: Install dependencies with composer uses: ramsey/composer-install@v4 with: dependency-versions: ${{ matrix.dependencies }} - - name: Execute Tests - run: vendor/bin/phpunit --coverage-clover=coverage.clover + - name: Execute tests + run: composer test:unit && composer test:sqlite -- --coverage-clover=runtime/clover.xml + + - name: Upload coverage to Codecov + continue-on-error: true # if is fork + uses: codecov/codecov-action@v7 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./runtime/clover.xml + flags: sqlite + + database: + name: ${{ matrix.driver }}, PHP ${{ matrix.php-version }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-version: ['8.2', '8.5'] + driver: [mysql, postgres, sqlserver] + include: + - driver: mysql + extensions: pdo_mysql + - driver: postgres + extensions: pdo_pgsql + - driver: sqlserver + extensions: sqlsrv, pdo_sqlsrv + env: + DB_REQUIRED: 1 + steps: + - name: Install ODBC driver + if: matrix.driver == 'sqlserver' + 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 PHP ${{ matrix.php-version }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + coverage: pcov + tools: pecl + extensions: mbstring, pdo, ${{ matrix.extensions }} + + # TODO(cycle/testing): switch to the released package + - name: Install dependencies with composer + uses: ramsey/composer-install@v4 + + - name: Start the database + run: composer db:up -- ${{ matrix.driver }} + + - name: Execute tests + run: composer test:${{ matrix.driver }} -- --coverage-clover=runtime/clover.xml - name: Upload coverage to Codecov continue-on-error: true # if is fork uses: codecov/codecov-action@v7 with: token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage.clover + files: ./runtime/clover.xml + flags: ${{ matrix.driver }} diff --git a/README.md b/README.md index 0a5f0c64..3319b923 100644 --- a/README.md +++ b/README.md @@ -371,3 +371,17 @@ composer require --dev llm/skills ``` Querying and persisting the mapped entities is covered by the `cycle-orm` skill that comes with [cycle/orm](https://github.com/cycle/orm). + +## Testing + +The tests run on [Testo](https://github.com/php-testo/testo) through the shared [cycle/testing](https://github.com/cycle/testing) harness: `tests/Annotated/Unit` needs no database, and `tests/Annotated/Feature` runs once per database driver. + +```bash +composer test:unit # no database +composer test:sqlite # in-memory SQLite, no docker +composer db:up # MySQL, Postgres and SQL Server in docker +composer test # every suite; a driver whose server is down is skipped +composer db:down +``` + +`composer test:mysql`, `test:postgres` and `test:sqlserver` run one driver. diff --git a/composer.json b/composer.json index 82feb673..da909fac 100644 --- a/composer.json +++ b/composer.json @@ -60,11 +60,8 @@ "cycle/testing": "1.x-dev", "doctrine/annotations": "^2.0.2", "llm/skills": "^1.20", - "phpunit/phpunit": "^11.5", "roxblnfk/unpoly": "^1.8", - "testo/testo": "^0.10.60", - "testo/bridge-rector": "^0.3.6", - "rector/rector": "^2.8" + "testo/testo": "^0.10.60" }, "suggest": { "llm/skills": "To sync the cycle-orm-attributes AI skill into your project" @@ -85,7 +82,14 @@ "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" + "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", + "test": "testo", + "test:mysql": "testo --suite=Feature/MySQL --suite=Acceptance/MySQL --suite=Regression/MySQL", + "test:postgres": "testo --suite=Feature/Postgres --suite=Acceptance/Postgres --suite=Regression/Postgres", + "test:sqlite": "testo --suite=Feature/SQLite --suite=Acceptance/SQLite --suite=Regression/SQLite", + "test:sqlserver": "testo --suite=Feature/SQLServer --suite=Acceptance/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 d3e3efdc..00000000 --- a/phpunit.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - src/ - - - - - ./tests/ - - - From 1bb9f26205de6e4fb5098658ef8a8755eda77873 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 15:51:10 +0400 Subject: [PATCH 06/12] build: install cycle/testing from its repository Assisted-By: Claude Opus 5.5 --- .github/workflows/main.yml | 2 -- composer.json | 9 +++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d8649856..c8a5f8ae 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,7 +37,6 @@ jobs: - name: Validate composer.json run: composer validate --ansi --strict - # TODO(cycle/testing): switch to the released package - name: Install dependencies with composer uses: ramsey/composer-install@v4 with: @@ -91,7 +90,6 @@ jobs: tools: pecl extensions: mbstring, pdo, ${{ matrix.extensions }} - # TODO(cycle/testing): switch to the released package - name: Install dependencies with composer uses: ramsey/composer-install@v4 diff --git a/composer.json b/composer.json index da909fac..c56ae63c 100644 --- a/composer.json +++ b/composer.json @@ -38,11 +38,8 @@ ], "repositories": [ { - "type": "path", - "url": "../../testing", - "options": { - "symlink": true - } + "type": "vcs", + "url": "https://github.com/cycle/testing" } ], "require": { @@ -57,7 +54,7 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.8", "buggregator/trap": "^1.20", - "cycle/testing": "1.x-dev", + "cycle/testing": "^0.1", "doctrine/annotations": "^2.0.2", "llm/skills": "^1.20", "roxblnfk/unpoly": "^1.8", From 13a869a839f24e13b7e24abb9ae2c665feda59ac Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 15:58:03 +0400 Subject: [PATCH 07/12] ci: collect coverage from the unit tests too The PHP matrix job ran the Unit suite without coverage, so Codecov lost the lines only unit tests reach. Assisted-By: Claude Opus 5.5 --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c8a5f8ae..9f117280 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,7 +43,9 @@ jobs: dependency-versions: ${{ matrix.dependencies }} - name: Execute tests - run: composer test:unit && composer test:sqlite -- --coverage-clover=runtime/clover.xml + env: + DB_DRIVERS: sqlite + run: composer test -- --coverage-clover=runtime/clover.xml - name: Upload coverage to Codecov continue-on-error: true # if is fork From 86ac22fe6e65c7a7b287a106e64801f7bf6b4ad3 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 16:31:59 +0400 Subject: [PATCH 08/12] test: move the test suites up to tests/ Assisted-By: Claude Opus 5.5 --- README.md | 2 +- composer.json | 2 +- testo.php | 4 ++-- tests/{Annotated => }/Feature/BaseTestCase.php | 0 tests/{Annotated => }/Feature/Common/ChildTest.php | 0 .../Feature/Common/CompositePkGeneratedTest.php | 0 tests/{Annotated => }/Feature/Common/GeneratedFieldsTest.php | 0 tests/{Annotated => }/Feature/Common/GeneratorTest.php | 0 .../Feature/Common/Inheritance/JoinedTableTest.php | 0 .../Feature/Common/Inheritance/SingleTableTest.php | 0 tests/{Annotated => }/Feature/Common/InheritanceTest.php | 0 tests/{Annotated => }/Feature/Common/InvalidTest.php | 0 .../{Annotated => }/Feature/Common/Relation/BelongsToTest.php | 0 .../Feature/Common/Relation/CompositeKeysTest.php | 0 .../{Annotated => }/Feature/Common/Relation/EmbeddedTest.php | 0 tests/{Annotated => }/Feature/Common/Relation/HasManyTest.php | 0 tests/{Annotated => }/Feature/Common/Relation/HasOneTest.php | 0 tests/{Annotated => }/Feature/Common/Relation/InverseTest.php | 0 .../Feature/Common/Relation/ManyToManyTest.php | 0 .../Feature/Common/Relation/Morphed/BelongsToMorphedTest.php | 0 .../Feature/Common/Relation/Morphed/MorphedHasManyTest.php | 0 .../Feature/Common/Relation/Morphed/MorphedHasOneTest.php | 0 .../Feature/Common/Relation/Morphed/RefersToMorphedTest.php | 0 .../{Annotated => }/Feature/Common/Relation/RefersToTest.php | 0 tests/{Annotated => }/Feature/Common/SchemaModifiersTest.php | 0 tests/{Annotated => }/Feature/Common/TableTest.php | 0 tests/{Annotated => }/Feature/Common/TypecastTest.php | 0 tests/{Annotated => }/Feature/MySQL/TableTest.php | 0 .../{Annotated => }/Feature/Postgres/GeneratedFieldsTest.php | 0 tests/{Annotated => }/Fixtures/Fixtures1/AnotherClass.php | 0 tests/{Annotated => }/Fixtures/Fixtures1/Child.php | 0 .../Fixtures/Fixtures1/Collection/BaseCollection.php | 0 tests/{Annotated => }/Fixtures/Fixtures1/Complete.php | 0 tests/{Annotated => }/Fixtures/Fixtures1/CompleteMapper.php | 0 .../Fixtures/Fixtures1/Constrain/SomeConstrain.php | 0 tests/{Annotated => }/Fixtures/Fixtures1/Label.php | 0 .../{Annotated => }/Fixtures/Fixtures1/LabelledInterface.php | 0 .../Fixtures/Fixtures1/Repository/CompleteRepository.php | 0 tests/{Annotated => }/Fixtures/Fixtures1/Simple.php | 0 .../{Annotated => }/Fixtures/Fixtures1/Source/TestSource.php | 0 tests/{Annotated => }/Fixtures/Fixtures1/Tag.php | 0 tests/{Annotated => }/Fixtures/Fixtures1/Tag/Context.php | 0 tests/{Annotated => }/Fixtures/Fixtures1/Third.php | 0 .../Fixtures/Fixtures1/Typecast/Typecaster.php | 0 .../Fixtures/Fixtures1/Typecast/UuidTypecaster.php | 0 tests/{Annotated => }/Fixtures/Fixtures1/WithTable.php | 0 tests/{Annotated => }/Fixtures/Fixtures10/MergedMetadata.php | 0 tests/{Annotated => }/Fixtures/Fixtures11/BadEntity.php | 0 tests/{Annotated => }/Fixtures/Fixtures12/CompositePost.php | 0 tests/{Annotated => }/Fixtures/Fixtures13/CompositePost.php | 0 tests/{Annotated => }/Fixtures/Fixtures14/Article.php | 0 tests/{Annotated => }/Fixtures/Fixtures14/Post.php | 0 tests/{Annotated => }/Fixtures/Fixtures14/Some.php | 0 tests/{Annotated => }/Fixtures/Fixtures14/Tag.php | 0 tests/{Annotated => }/Fixtures/Fixtures15/Context.php | 0 tests/{Annotated => }/Fixtures/Fixtures15/Post.php | 0 tests/{Annotated => }/Fixtures/Fixtures15/Tag.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/Beaver.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/Buyer.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/Ceo.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/Customer.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/Employee.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/Executive.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/Executive2.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/ExecutiveProxy.php | 0 .../{Annotated => }/Fixtures/Fixtures16/ExternalSupplier.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/ExtraColumns.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/FooColumns.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/LocalSupplier.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/Person.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/Supplier.php | 0 tests/{Annotated => }/Fixtures/Fixtures16/Tool.php | 0 .../Fixtures/Fixtures17/MapperSegmentSchemaModifier.php | 0 .../Fixtures/Fixtures17/ParentSegmentSchemaModifier.php | 0 tests/{Annotated => }/Fixtures/Fixtures17/Post.php | 0 tests/{Annotated => }/Fixtures/Fixtures18/Booking.php | 0 tests/{Annotated => }/Fixtures/Fixtures18/Pivot.php | 0 tests/{Annotated => }/Fixtures/Fixtures18/Reservation.php | 0 tests/{Annotated => }/Fixtures/Fixtures18/Segment.php | 0 tests/{Annotated => }/Fixtures/Fixtures19/BackedEnum.php | 0 .../{Annotated => }/Fixtures/Fixtures19/BackedEnumWrapper.php | 0 tests/{Annotated => }/Fixtures/Fixtures19/Booking.php | 0 tests/{Annotated => }/Fixtures/Fixtures2/Complete.php | 0 tests/{Annotated => }/Fixtures/Fixtures2/Mark.php | 0 tests/{Annotated => }/Fixtures/Fixtures2/MarkedInterface.php | 0 tests/{Annotated => }/Fixtures/Fixtures2/Simple.php | 0 tests/{Annotated => }/Fixtures/Fixtures2/User.php | 0 tests/{Annotated => }/Fixtures/Fixtures20/Buyer.php | 0 tests/{Annotated => }/Fixtures/Fixtures20/Ceo.php | 0 tests/{Annotated => }/Fixtures/Fixtures20/Customer.php | 0 tests/{Annotated => }/Fixtures/Fixtures20/Employee.php | 0 tests/{Annotated => }/Fixtures/Fixtures20/Person.php | 0 tests/{Annotated => }/Fixtures/Fixtures21/Buyer.php | 0 tests/{Annotated => }/Fixtures/Fixtures21/Employee.php | 0 tests/{Annotated => }/Fixtures/Fixtures21/Executive.php | 0 tests/{Annotated => }/Fixtures/Fixtures21/Person.php | 0 .../Fixtures/Fixtures22/Annotated/LocalManager.php | 0 .../Fixtures/Fixtures22/Annotated/LocalSupplier.php | 0 .../{Annotated => }/Fixtures/Fixtures22/Annotated/Person.php | 0 .../Fixtures/Fixtures22/Annotated/Supplier.php | 0 .../Fixtures/Fixtures22/Attributed/LocalManager.php | 0 .../Fixtures/Fixtures22/Attributed/LocalSupplier.php | 0 .../{Annotated => }/Fixtures/Fixtures22/Attributed/Person.php | 0 .../Fixtures/Fixtures22/Attributed/Supplier.php | 0 .../Fixtures/Fixtures23/STIWithClassColumn/BaseEvent.php | 0 .../Fixtures/Fixtures23/STIWithClassColumn/Comment.php | 0 .../Fixtures/Fixtures23/STIWithClassColumn/CommentCreated.php | 0 .../Fixtures/Fixtures23/STIWithClassColumn/CommentUpdated.php | 0 .../Fixtures23/STIWithClassColumn/EventEmitterInterface.php | 0 .../Fixtures/Fixtures23/STIWithEntityColumn/BaseEvent.php | 0 .../Fixtures/Fixtures23/STIWithEntityColumn/Comment.php | 0 .../Fixtures23/STIWithEntityColumn/CommentCreated.php | 0 .../Fixtures23/STIWithEntityColumn/CommentUpdated.php | 0 .../Fixtures23/STIWithEntityColumn/EventEmitterInterface.php | 0 .../Fixtures/Fixtures23/STIWithPropertyColumn/BaseEvent.php | 0 .../Fixtures/Fixtures23/STIWithPropertyColumn/Comment.php | 0 .../Fixtures23/STIWithPropertyColumn/CommentCreated.php | 0 .../Fixtures23/STIWithPropertyColumn/CommentUpdated.php | 0 .../STIWithPropertyColumn/EventEmitterInterface.php | 0 .../Fixtures/Fixtures23/STIWithTableColumn/BaseEvent.php | 0 .../Fixtures/Fixtures23/STIWithTableColumn/Comment.php | 0 .../Fixtures/Fixtures23/STIWithTableColumn/CommentCreated.php | 0 .../Fixtures/Fixtures23/STIWithTableColumn/CommentUpdated.php | 0 .../Fixtures23/STIWithTableColumn/EventEmitterInterface.php | 0 .../Fixtures/Fixtures24/Class/DatabaseField/DatabaseField.php | 0 .../Fixtures/Fixtures24/Class/DatabaseField/Target.php | 0 .../Fixtures/Fixtures24/Class/PrimaryKey/PrimaryKey.php | 0 .../Fixtures/Fixtures24/Class/PrimaryKey/Target.php | 0 .../Fixtures/Fixtures24/Class/PropertyName/PropertyName.php | 0 .../Fixtures/Fixtures24/Class/PropertyName/Target.php | 0 .../Fixtures24/Entity/DatabaseField/DatabaseField.php | 0 .../Fixtures/Fixtures24/Entity/DatabaseField/Target.php | 0 .../Fixtures/Fixtures24/Entity/PrimaryKey/PrimaryKey.php | 0 .../Fixtures/Fixtures24/Entity/PrimaryKey/Target.php | 0 .../Fixtures/Fixtures24/Entity/PropertyName/PropertyName.php | 0 .../Fixtures/Fixtures24/Entity/PropertyName/Target.php | 0 .../Fixtures24/Property/DatabaseField/DatabaseField.php | 0 .../Fixtures/Fixtures24/Property/DatabaseField/Target.php | 0 .../Fixtures/Fixtures24/Property/PrimaryKey/PrimaryKey.php | 0 .../Fixtures/Fixtures24/Property/PrimaryKey/Target.php | 0 .../Fixtures24/Property/PropertyName/PropertyName.php | 0 .../Fixtures/Fixtures24/Property/PropertyName/Target.php | 0 .../Fixtures/Fixtures25/PostgreSQL/WithGeneratedSerial.php | 0 .../Fixtures/Fixtures25/WithGeneratedFields.php | 0 tests/{Annotated => }/Fixtures/Fixtures26/Address.php | 0 tests/{Annotated => }/Fixtures/Fixtures26/City.php | 0 tests/{Annotated => }/Fixtures/Fixtures26/CityTypecast.php | 0 tests/{Annotated => }/Fixtures/Fixtures26/User.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/BtJoined.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/BtParent.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/BtTarget.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/JgLeaf.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/JgMid.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/JgParent.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/JgTarget.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/SoParent.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/SoSeparate.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/SoSti.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/SoTarget.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/StChild.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/StParent.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/StTarget.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/TrJti.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/TrParent.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/TrRelTrait.php | 0 tests/{Annotated => }/Fixtures/Fixtures27/TrTarget.php | 0 tests/{Annotated => }/Fixtures/Fixtures28/Event.php | 0 tests/{Annotated => }/Fixtures/Fixtures3/User.php | 0 tests/{Annotated => }/Fixtures/Fixtures4/User.php | 0 tests/{Annotated => }/Fixtures/Fixtures5/Simple.php | 0 tests/{Annotated => }/Fixtures/Fixtures5/User.php | 0 tests/{Annotated => }/Fixtures/Fixtures6/Address.php | 0 tests/{Annotated => }/Fixtures/Fixtures6/User.php | 0 tests/{Annotated => }/Fixtures/Fixtures7/Address.php | 0 tests/{Annotated => }/Fixtures/Fixtures7/User.php | 0 tests/{Annotated => }/Fixtures/Fixtures8/Article.php | 0 tests/{Annotated => }/Fixtures/Fixtures8/Post.php | 0 tests/{Annotated => }/Fixtures/Fixtures8/Some.php | 0 tests/{Annotated => }/Fixtures/Fixtures9/OrderedIdx.php | 0 tests/{Annotated => }/Fixtures/RefersToMorphed/Comment.php | 0 .../Fixtures/RefersToMorphed/MorphedParentInterface.php | 0 tests/{Annotated => }/Fixtures/RefersToMorphed/Post.php | 0 tests/{Annotated => }/Unit/Attribute/ColumnTest.php | 0 .../Unit/Attribute/SingleTable/IntegerEnum.php | 0 .../Unit/Attribute/SingleTable/SingleTableTest.php | 0 .../{Annotated => }/Unit/Attribute/SingleTable/StringEnum.php | 0 .../Unit/Attribute/SingleTable/StringableObject.php | 0 .../Unit/Locator/TokenizerEmbeddingLocatorTest.php | 0 .../Unit/Locator/TokenizerEntityLocatorTest.php | 0 tests/{Annotated => }/Unit/ReaderFactoryTest.php | 0 tests/{Annotated => }/Unit/Utils/EntityUtilsTest.php | 0 191 files changed, 4 insertions(+), 4 deletions(-) rename tests/{Annotated => }/Feature/BaseTestCase.php (100%) rename tests/{Annotated => }/Feature/Common/ChildTest.php (100%) rename tests/{Annotated => }/Feature/Common/CompositePkGeneratedTest.php (100%) rename tests/{Annotated => }/Feature/Common/GeneratedFieldsTest.php (100%) rename tests/{Annotated => }/Feature/Common/GeneratorTest.php (100%) rename tests/{Annotated => }/Feature/Common/Inheritance/JoinedTableTest.php (100%) rename tests/{Annotated => }/Feature/Common/Inheritance/SingleTableTest.php (100%) rename tests/{Annotated => }/Feature/Common/InheritanceTest.php (100%) rename tests/{Annotated => }/Feature/Common/InvalidTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/BelongsToTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/CompositeKeysTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/EmbeddedTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/HasManyTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/HasOneTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/InverseTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/ManyToManyTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/Morphed/BelongsToMorphedTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/Morphed/MorphedHasManyTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/Morphed/MorphedHasOneTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/Morphed/RefersToMorphedTest.php (100%) rename tests/{Annotated => }/Feature/Common/Relation/RefersToTest.php (100%) rename tests/{Annotated => }/Feature/Common/SchemaModifiersTest.php (100%) rename tests/{Annotated => }/Feature/Common/TableTest.php (100%) rename tests/{Annotated => }/Feature/Common/TypecastTest.php (100%) rename tests/{Annotated => }/Feature/MySQL/TableTest.php (100%) rename tests/{Annotated => }/Feature/Postgres/GeneratedFieldsTest.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/AnotherClass.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Child.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Collection/BaseCollection.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Complete.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/CompleteMapper.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Constrain/SomeConstrain.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Label.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/LabelledInterface.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Repository/CompleteRepository.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Simple.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Source/TestSource.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Tag.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Tag/Context.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Third.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Typecast/Typecaster.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/Typecast/UuidTypecaster.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures1/WithTable.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures10/MergedMetadata.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures11/BadEntity.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures12/CompositePost.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures13/CompositePost.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures14/Article.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures14/Post.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures14/Some.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures14/Tag.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures15/Context.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures15/Post.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures15/Tag.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/Beaver.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/Buyer.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/Ceo.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/Customer.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/Employee.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/Executive.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/Executive2.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/ExecutiveProxy.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/ExternalSupplier.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/ExtraColumns.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/FooColumns.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/LocalSupplier.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/Person.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/Supplier.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures16/Tool.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures17/MapperSegmentSchemaModifier.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures17/ParentSegmentSchemaModifier.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures17/Post.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures18/Booking.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures18/Pivot.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures18/Reservation.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures18/Segment.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures19/BackedEnum.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures19/BackedEnumWrapper.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures19/Booking.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures2/Complete.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures2/Mark.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures2/MarkedInterface.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures2/Simple.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures2/User.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures20/Buyer.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures20/Ceo.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures20/Customer.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures20/Employee.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures20/Person.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures21/Buyer.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures21/Employee.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures21/Executive.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures21/Person.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures22/Annotated/LocalManager.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures22/Annotated/LocalSupplier.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures22/Annotated/Person.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures22/Annotated/Supplier.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures22/Attributed/LocalManager.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures22/Attributed/LocalSupplier.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures22/Attributed/Person.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures22/Attributed/Supplier.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithClassColumn/BaseEvent.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithClassColumn/Comment.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithClassColumn/CommentCreated.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithClassColumn/CommentUpdated.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithClassColumn/EventEmitterInterface.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithEntityColumn/BaseEvent.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithEntityColumn/Comment.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithEntityColumn/CommentCreated.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithEntityColumn/CommentUpdated.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithEntityColumn/EventEmitterInterface.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithPropertyColumn/BaseEvent.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithPropertyColumn/Comment.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithPropertyColumn/CommentCreated.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithPropertyColumn/CommentUpdated.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithPropertyColumn/EventEmitterInterface.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithTableColumn/BaseEvent.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithTableColumn/Comment.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithTableColumn/CommentCreated.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithTableColumn/CommentUpdated.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures23/STIWithTableColumn/EventEmitterInterface.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Class/DatabaseField/DatabaseField.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Class/DatabaseField/Target.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Class/PrimaryKey/PrimaryKey.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Class/PrimaryKey/Target.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Class/PropertyName/PropertyName.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Class/PropertyName/Target.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Entity/DatabaseField/DatabaseField.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Entity/DatabaseField/Target.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Entity/PrimaryKey/PrimaryKey.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Entity/PrimaryKey/Target.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Entity/PropertyName/PropertyName.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Entity/PropertyName/Target.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Property/DatabaseField/DatabaseField.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Property/DatabaseField/Target.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Property/PrimaryKey/PrimaryKey.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Property/PrimaryKey/Target.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Property/PropertyName/PropertyName.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures24/Property/PropertyName/Target.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures25/PostgreSQL/WithGeneratedSerial.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures25/WithGeneratedFields.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures26/Address.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures26/City.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures26/CityTypecast.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures26/User.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/BtJoined.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/BtParent.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/BtTarget.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/JgLeaf.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/JgMid.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/JgParent.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/JgTarget.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/SoParent.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/SoSeparate.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/SoSti.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/SoTarget.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/StChild.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/StParent.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/StTarget.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/TrJti.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/TrParent.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/TrRelTrait.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures27/TrTarget.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures28/Event.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures3/User.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures4/User.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures5/Simple.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures5/User.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures6/Address.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures6/User.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures7/Address.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures7/User.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures8/Article.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures8/Post.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures8/Some.php (100%) rename tests/{Annotated => }/Fixtures/Fixtures9/OrderedIdx.php (100%) rename tests/{Annotated => }/Fixtures/RefersToMorphed/Comment.php (100%) rename tests/{Annotated => }/Fixtures/RefersToMorphed/MorphedParentInterface.php (100%) rename tests/{Annotated => }/Fixtures/RefersToMorphed/Post.php (100%) rename tests/{Annotated => }/Unit/Attribute/ColumnTest.php (100%) rename tests/{Annotated => }/Unit/Attribute/SingleTable/IntegerEnum.php (100%) rename tests/{Annotated => }/Unit/Attribute/SingleTable/SingleTableTest.php (100%) rename tests/{Annotated => }/Unit/Attribute/SingleTable/StringEnum.php (100%) rename tests/{Annotated => }/Unit/Attribute/SingleTable/StringableObject.php (100%) rename tests/{Annotated => }/Unit/Locator/TokenizerEmbeddingLocatorTest.php (100%) rename tests/{Annotated => }/Unit/Locator/TokenizerEntityLocatorTest.php (100%) rename tests/{Annotated => }/Unit/ReaderFactoryTest.php (100%) rename tests/{Annotated => }/Unit/Utils/EntityUtilsTest.php (100%) diff --git a/README.md b/README.md index 3319b923..bcea4c07 100644 --- a/README.md +++ b/README.md @@ -374,7 +374,7 @@ Querying and persisting the mapped entities is covered by the `cycle-orm` skill ## Testing -The tests run on [Testo](https://github.com/php-testo/testo) through the shared [cycle/testing](https://github.com/cycle/testing) harness: `tests/Annotated/Unit` needs no database, and `tests/Annotated/Feature` runs once per database driver. +The tests run on [Testo](https://github.com/php-testo/testo) through the shared [cycle/testing](https://github.com/cycle/testing) harness: `tests/Unit` needs no database, and `tests/Feature` runs once per database driver. ```bash composer test:unit # no database diff --git a/composer.json b/composer.json index c56ae63c..f04f7af0 100644 --- a/composer.json +++ b/composer.json @@ -70,7 +70,7 @@ }, "autoload-dev": { "psr-4": { - "Cycle\\Annotated\\Tests\\": "tests/Annotated/" + "Cycle\\Annotated\\Tests\\": "tests/" } }, "scripts": { diff --git a/testo.php b/testo.php index 3aef8dff..f0a5034e 100644 --- a/testo.php +++ b/testo.php @@ -7,9 +7,9 @@ use Cycle\Testing\ORM\OrmPlugin; return Config::forPackage('cycle/annotated', root: __DIR__) - ->unit('tests/Annotated/Unit') + ->unit('tests/Unit') ->feature( - 'tests/Annotated/Feature', + 'tests/Feature', layout: Layout::prefixed(['secondary' => 'secondary_']), plugins: [new OrmPlugin()], ) diff --git a/tests/Annotated/Feature/BaseTestCase.php b/tests/Feature/BaseTestCase.php similarity index 100% rename from tests/Annotated/Feature/BaseTestCase.php rename to tests/Feature/BaseTestCase.php diff --git a/tests/Annotated/Feature/Common/ChildTest.php b/tests/Feature/Common/ChildTest.php similarity index 100% rename from tests/Annotated/Feature/Common/ChildTest.php rename to tests/Feature/Common/ChildTest.php diff --git a/tests/Annotated/Feature/Common/CompositePkGeneratedTest.php b/tests/Feature/Common/CompositePkGeneratedTest.php similarity index 100% rename from tests/Annotated/Feature/Common/CompositePkGeneratedTest.php rename to tests/Feature/Common/CompositePkGeneratedTest.php diff --git a/tests/Annotated/Feature/Common/GeneratedFieldsTest.php b/tests/Feature/Common/GeneratedFieldsTest.php similarity index 100% rename from tests/Annotated/Feature/Common/GeneratedFieldsTest.php rename to tests/Feature/Common/GeneratedFieldsTest.php diff --git a/tests/Annotated/Feature/Common/GeneratorTest.php b/tests/Feature/Common/GeneratorTest.php similarity index 100% rename from tests/Annotated/Feature/Common/GeneratorTest.php rename to tests/Feature/Common/GeneratorTest.php diff --git a/tests/Annotated/Feature/Common/Inheritance/JoinedTableTest.php b/tests/Feature/Common/Inheritance/JoinedTableTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Inheritance/JoinedTableTest.php rename to tests/Feature/Common/Inheritance/JoinedTableTest.php diff --git a/tests/Annotated/Feature/Common/Inheritance/SingleTableTest.php b/tests/Feature/Common/Inheritance/SingleTableTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Inheritance/SingleTableTest.php rename to tests/Feature/Common/Inheritance/SingleTableTest.php diff --git a/tests/Annotated/Feature/Common/InheritanceTest.php b/tests/Feature/Common/InheritanceTest.php similarity index 100% rename from tests/Annotated/Feature/Common/InheritanceTest.php rename to tests/Feature/Common/InheritanceTest.php diff --git a/tests/Annotated/Feature/Common/InvalidTest.php b/tests/Feature/Common/InvalidTest.php similarity index 100% rename from tests/Annotated/Feature/Common/InvalidTest.php rename to tests/Feature/Common/InvalidTest.php diff --git a/tests/Annotated/Feature/Common/Relation/BelongsToTest.php b/tests/Feature/Common/Relation/BelongsToTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/BelongsToTest.php rename to tests/Feature/Common/Relation/BelongsToTest.php diff --git a/tests/Annotated/Feature/Common/Relation/CompositeKeysTest.php b/tests/Feature/Common/Relation/CompositeKeysTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/CompositeKeysTest.php rename to tests/Feature/Common/Relation/CompositeKeysTest.php diff --git a/tests/Annotated/Feature/Common/Relation/EmbeddedTest.php b/tests/Feature/Common/Relation/EmbeddedTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/EmbeddedTest.php rename to tests/Feature/Common/Relation/EmbeddedTest.php diff --git a/tests/Annotated/Feature/Common/Relation/HasManyTest.php b/tests/Feature/Common/Relation/HasManyTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/HasManyTest.php rename to tests/Feature/Common/Relation/HasManyTest.php diff --git a/tests/Annotated/Feature/Common/Relation/HasOneTest.php b/tests/Feature/Common/Relation/HasOneTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/HasOneTest.php rename to tests/Feature/Common/Relation/HasOneTest.php diff --git a/tests/Annotated/Feature/Common/Relation/InverseTest.php b/tests/Feature/Common/Relation/InverseTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/InverseTest.php rename to tests/Feature/Common/Relation/InverseTest.php diff --git a/tests/Annotated/Feature/Common/Relation/ManyToManyTest.php b/tests/Feature/Common/Relation/ManyToManyTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/ManyToManyTest.php rename to tests/Feature/Common/Relation/ManyToManyTest.php diff --git a/tests/Annotated/Feature/Common/Relation/Morphed/BelongsToMorphedTest.php b/tests/Feature/Common/Relation/Morphed/BelongsToMorphedTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/Morphed/BelongsToMorphedTest.php rename to tests/Feature/Common/Relation/Morphed/BelongsToMorphedTest.php diff --git a/tests/Annotated/Feature/Common/Relation/Morphed/MorphedHasManyTest.php b/tests/Feature/Common/Relation/Morphed/MorphedHasManyTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/Morphed/MorphedHasManyTest.php rename to tests/Feature/Common/Relation/Morphed/MorphedHasManyTest.php diff --git a/tests/Annotated/Feature/Common/Relation/Morphed/MorphedHasOneTest.php b/tests/Feature/Common/Relation/Morphed/MorphedHasOneTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/Morphed/MorphedHasOneTest.php rename to tests/Feature/Common/Relation/Morphed/MorphedHasOneTest.php diff --git a/tests/Annotated/Feature/Common/Relation/Morphed/RefersToMorphedTest.php b/tests/Feature/Common/Relation/Morphed/RefersToMorphedTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/Morphed/RefersToMorphedTest.php rename to tests/Feature/Common/Relation/Morphed/RefersToMorphedTest.php diff --git a/tests/Annotated/Feature/Common/Relation/RefersToTest.php b/tests/Feature/Common/Relation/RefersToTest.php similarity index 100% rename from tests/Annotated/Feature/Common/Relation/RefersToTest.php rename to tests/Feature/Common/Relation/RefersToTest.php diff --git a/tests/Annotated/Feature/Common/SchemaModifiersTest.php b/tests/Feature/Common/SchemaModifiersTest.php similarity index 100% rename from tests/Annotated/Feature/Common/SchemaModifiersTest.php rename to tests/Feature/Common/SchemaModifiersTest.php diff --git a/tests/Annotated/Feature/Common/TableTest.php b/tests/Feature/Common/TableTest.php similarity index 100% rename from tests/Annotated/Feature/Common/TableTest.php rename to tests/Feature/Common/TableTest.php diff --git a/tests/Annotated/Feature/Common/TypecastTest.php b/tests/Feature/Common/TypecastTest.php similarity index 100% rename from tests/Annotated/Feature/Common/TypecastTest.php rename to tests/Feature/Common/TypecastTest.php diff --git a/tests/Annotated/Feature/MySQL/TableTest.php b/tests/Feature/MySQL/TableTest.php similarity index 100% rename from tests/Annotated/Feature/MySQL/TableTest.php rename to tests/Feature/MySQL/TableTest.php diff --git a/tests/Annotated/Feature/Postgres/GeneratedFieldsTest.php b/tests/Feature/Postgres/GeneratedFieldsTest.php similarity index 100% rename from tests/Annotated/Feature/Postgres/GeneratedFieldsTest.php rename to tests/Feature/Postgres/GeneratedFieldsTest.php diff --git a/tests/Annotated/Fixtures/Fixtures1/AnotherClass.php b/tests/Fixtures/Fixtures1/AnotherClass.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/AnotherClass.php rename to tests/Fixtures/Fixtures1/AnotherClass.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Child.php b/tests/Fixtures/Fixtures1/Child.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Child.php rename to tests/Fixtures/Fixtures1/Child.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Collection/BaseCollection.php b/tests/Fixtures/Fixtures1/Collection/BaseCollection.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Collection/BaseCollection.php rename to tests/Fixtures/Fixtures1/Collection/BaseCollection.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Complete.php b/tests/Fixtures/Fixtures1/Complete.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Complete.php rename to tests/Fixtures/Fixtures1/Complete.php diff --git a/tests/Annotated/Fixtures/Fixtures1/CompleteMapper.php b/tests/Fixtures/Fixtures1/CompleteMapper.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/CompleteMapper.php rename to tests/Fixtures/Fixtures1/CompleteMapper.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Constrain/SomeConstrain.php b/tests/Fixtures/Fixtures1/Constrain/SomeConstrain.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Constrain/SomeConstrain.php rename to tests/Fixtures/Fixtures1/Constrain/SomeConstrain.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Label.php b/tests/Fixtures/Fixtures1/Label.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Label.php rename to tests/Fixtures/Fixtures1/Label.php diff --git a/tests/Annotated/Fixtures/Fixtures1/LabelledInterface.php b/tests/Fixtures/Fixtures1/LabelledInterface.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/LabelledInterface.php rename to tests/Fixtures/Fixtures1/LabelledInterface.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Repository/CompleteRepository.php b/tests/Fixtures/Fixtures1/Repository/CompleteRepository.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Repository/CompleteRepository.php rename to tests/Fixtures/Fixtures1/Repository/CompleteRepository.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Simple.php b/tests/Fixtures/Fixtures1/Simple.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Simple.php rename to tests/Fixtures/Fixtures1/Simple.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Source/TestSource.php b/tests/Fixtures/Fixtures1/Source/TestSource.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Source/TestSource.php rename to tests/Fixtures/Fixtures1/Source/TestSource.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Tag.php b/tests/Fixtures/Fixtures1/Tag.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Tag.php rename to tests/Fixtures/Fixtures1/Tag.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Tag/Context.php b/tests/Fixtures/Fixtures1/Tag/Context.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Tag/Context.php rename to tests/Fixtures/Fixtures1/Tag/Context.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Third.php b/tests/Fixtures/Fixtures1/Third.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Third.php rename to tests/Fixtures/Fixtures1/Third.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Typecast/Typecaster.php b/tests/Fixtures/Fixtures1/Typecast/Typecaster.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Typecast/Typecaster.php rename to tests/Fixtures/Fixtures1/Typecast/Typecaster.php diff --git a/tests/Annotated/Fixtures/Fixtures1/Typecast/UuidTypecaster.php b/tests/Fixtures/Fixtures1/Typecast/UuidTypecaster.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/Typecast/UuidTypecaster.php rename to tests/Fixtures/Fixtures1/Typecast/UuidTypecaster.php diff --git a/tests/Annotated/Fixtures/Fixtures1/WithTable.php b/tests/Fixtures/Fixtures1/WithTable.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures1/WithTable.php rename to tests/Fixtures/Fixtures1/WithTable.php diff --git a/tests/Annotated/Fixtures/Fixtures10/MergedMetadata.php b/tests/Fixtures/Fixtures10/MergedMetadata.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures10/MergedMetadata.php rename to tests/Fixtures/Fixtures10/MergedMetadata.php diff --git a/tests/Annotated/Fixtures/Fixtures11/BadEntity.php b/tests/Fixtures/Fixtures11/BadEntity.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures11/BadEntity.php rename to tests/Fixtures/Fixtures11/BadEntity.php diff --git a/tests/Annotated/Fixtures/Fixtures12/CompositePost.php b/tests/Fixtures/Fixtures12/CompositePost.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures12/CompositePost.php rename to tests/Fixtures/Fixtures12/CompositePost.php diff --git a/tests/Annotated/Fixtures/Fixtures13/CompositePost.php b/tests/Fixtures/Fixtures13/CompositePost.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures13/CompositePost.php rename to tests/Fixtures/Fixtures13/CompositePost.php diff --git a/tests/Annotated/Fixtures/Fixtures14/Article.php b/tests/Fixtures/Fixtures14/Article.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures14/Article.php rename to tests/Fixtures/Fixtures14/Article.php diff --git a/tests/Annotated/Fixtures/Fixtures14/Post.php b/tests/Fixtures/Fixtures14/Post.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures14/Post.php rename to tests/Fixtures/Fixtures14/Post.php diff --git a/tests/Annotated/Fixtures/Fixtures14/Some.php b/tests/Fixtures/Fixtures14/Some.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures14/Some.php rename to tests/Fixtures/Fixtures14/Some.php diff --git a/tests/Annotated/Fixtures/Fixtures14/Tag.php b/tests/Fixtures/Fixtures14/Tag.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures14/Tag.php rename to tests/Fixtures/Fixtures14/Tag.php diff --git a/tests/Annotated/Fixtures/Fixtures15/Context.php b/tests/Fixtures/Fixtures15/Context.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures15/Context.php rename to tests/Fixtures/Fixtures15/Context.php diff --git a/tests/Annotated/Fixtures/Fixtures15/Post.php b/tests/Fixtures/Fixtures15/Post.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures15/Post.php rename to tests/Fixtures/Fixtures15/Post.php diff --git a/tests/Annotated/Fixtures/Fixtures15/Tag.php b/tests/Fixtures/Fixtures15/Tag.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures15/Tag.php rename to tests/Fixtures/Fixtures15/Tag.php diff --git a/tests/Annotated/Fixtures/Fixtures16/Beaver.php b/tests/Fixtures/Fixtures16/Beaver.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/Beaver.php rename to tests/Fixtures/Fixtures16/Beaver.php diff --git a/tests/Annotated/Fixtures/Fixtures16/Buyer.php b/tests/Fixtures/Fixtures16/Buyer.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/Buyer.php rename to tests/Fixtures/Fixtures16/Buyer.php diff --git a/tests/Annotated/Fixtures/Fixtures16/Ceo.php b/tests/Fixtures/Fixtures16/Ceo.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/Ceo.php rename to tests/Fixtures/Fixtures16/Ceo.php diff --git a/tests/Annotated/Fixtures/Fixtures16/Customer.php b/tests/Fixtures/Fixtures16/Customer.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/Customer.php rename to tests/Fixtures/Fixtures16/Customer.php diff --git a/tests/Annotated/Fixtures/Fixtures16/Employee.php b/tests/Fixtures/Fixtures16/Employee.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/Employee.php rename to tests/Fixtures/Fixtures16/Employee.php diff --git a/tests/Annotated/Fixtures/Fixtures16/Executive.php b/tests/Fixtures/Fixtures16/Executive.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/Executive.php rename to tests/Fixtures/Fixtures16/Executive.php diff --git a/tests/Annotated/Fixtures/Fixtures16/Executive2.php b/tests/Fixtures/Fixtures16/Executive2.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/Executive2.php rename to tests/Fixtures/Fixtures16/Executive2.php diff --git a/tests/Annotated/Fixtures/Fixtures16/ExecutiveProxy.php b/tests/Fixtures/Fixtures16/ExecutiveProxy.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/ExecutiveProxy.php rename to tests/Fixtures/Fixtures16/ExecutiveProxy.php diff --git a/tests/Annotated/Fixtures/Fixtures16/ExternalSupplier.php b/tests/Fixtures/Fixtures16/ExternalSupplier.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/ExternalSupplier.php rename to tests/Fixtures/Fixtures16/ExternalSupplier.php diff --git a/tests/Annotated/Fixtures/Fixtures16/ExtraColumns.php b/tests/Fixtures/Fixtures16/ExtraColumns.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/ExtraColumns.php rename to tests/Fixtures/Fixtures16/ExtraColumns.php diff --git a/tests/Annotated/Fixtures/Fixtures16/FooColumns.php b/tests/Fixtures/Fixtures16/FooColumns.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/FooColumns.php rename to tests/Fixtures/Fixtures16/FooColumns.php diff --git a/tests/Annotated/Fixtures/Fixtures16/LocalSupplier.php b/tests/Fixtures/Fixtures16/LocalSupplier.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/LocalSupplier.php rename to tests/Fixtures/Fixtures16/LocalSupplier.php diff --git a/tests/Annotated/Fixtures/Fixtures16/Person.php b/tests/Fixtures/Fixtures16/Person.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/Person.php rename to tests/Fixtures/Fixtures16/Person.php diff --git a/tests/Annotated/Fixtures/Fixtures16/Supplier.php b/tests/Fixtures/Fixtures16/Supplier.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/Supplier.php rename to tests/Fixtures/Fixtures16/Supplier.php diff --git a/tests/Annotated/Fixtures/Fixtures16/Tool.php b/tests/Fixtures/Fixtures16/Tool.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures16/Tool.php rename to tests/Fixtures/Fixtures16/Tool.php diff --git a/tests/Annotated/Fixtures/Fixtures17/MapperSegmentSchemaModifier.php b/tests/Fixtures/Fixtures17/MapperSegmentSchemaModifier.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures17/MapperSegmentSchemaModifier.php rename to tests/Fixtures/Fixtures17/MapperSegmentSchemaModifier.php diff --git a/tests/Annotated/Fixtures/Fixtures17/ParentSegmentSchemaModifier.php b/tests/Fixtures/Fixtures17/ParentSegmentSchemaModifier.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures17/ParentSegmentSchemaModifier.php rename to tests/Fixtures/Fixtures17/ParentSegmentSchemaModifier.php diff --git a/tests/Annotated/Fixtures/Fixtures17/Post.php b/tests/Fixtures/Fixtures17/Post.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures17/Post.php rename to tests/Fixtures/Fixtures17/Post.php diff --git a/tests/Annotated/Fixtures/Fixtures18/Booking.php b/tests/Fixtures/Fixtures18/Booking.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures18/Booking.php rename to tests/Fixtures/Fixtures18/Booking.php diff --git a/tests/Annotated/Fixtures/Fixtures18/Pivot.php b/tests/Fixtures/Fixtures18/Pivot.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures18/Pivot.php rename to tests/Fixtures/Fixtures18/Pivot.php diff --git a/tests/Annotated/Fixtures/Fixtures18/Reservation.php b/tests/Fixtures/Fixtures18/Reservation.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures18/Reservation.php rename to tests/Fixtures/Fixtures18/Reservation.php diff --git a/tests/Annotated/Fixtures/Fixtures18/Segment.php b/tests/Fixtures/Fixtures18/Segment.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures18/Segment.php rename to tests/Fixtures/Fixtures18/Segment.php diff --git a/tests/Annotated/Fixtures/Fixtures19/BackedEnum.php b/tests/Fixtures/Fixtures19/BackedEnum.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures19/BackedEnum.php rename to tests/Fixtures/Fixtures19/BackedEnum.php diff --git a/tests/Annotated/Fixtures/Fixtures19/BackedEnumWrapper.php b/tests/Fixtures/Fixtures19/BackedEnumWrapper.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures19/BackedEnumWrapper.php rename to tests/Fixtures/Fixtures19/BackedEnumWrapper.php diff --git a/tests/Annotated/Fixtures/Fixtures19/Booking.php b/tests/Fixtures/Fixtures19/Booking.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures19/Booking.php rename to tests/Fixtures/Fixtures19/Booking.php diff --git a/tests/Annotated/Fixtures/Fixtures2/Complete.php b/tests/Fixtures/Fixtures2/Complete.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures2/Complete.php rename to tests/Fixtures/Fixtures2/Complete.php diff --git a/tests/Annotated/Fixtures/Fixtures2/Mark.php b/tests/Fixtures/Fixtures2/Mark.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures2/Mark.php rename to tests/Fixtures/Fixtures2/Mark.php diff --git a/tests/Annotated/Fixtures/Fixtures2/MarkedInterface.php b/tests/Fixtures/Fixtures2/MarkedInterface.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures2/MarkedInterface.php rename to tests/Fixtures/Fixtures2/MarkedInterface.php diff --git a/tests/Annotated/Fixtures/Fixtures2/Simple.php b/tests/Fixtures/Fixtures2/Simple.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures2/Simple.php rename to tests/Fixtures/Fixtures2/Simple.php diff --git a/tests/Annotated/Fixtures/Fixtures2/User.php b/tests/Fixtures/Fixtures2/User.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures2/User.php rename to tests/Fixtures/Fixtures2/User.php diff --git a/tests/Annotated/Fixtures/Fixtures20/Buyer.php b/tests/Fixtures/Fixtures20/Buyer.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures20/Buyer.php rename to tests/Fixtures/Fixtures20/Buyer.php diff --git a/tests/Annotated/Fixtures/Fixtures20/Ceo.php b/tests/Fixtures/Fixtures20/Ceo.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures20/Ceo.php rename to tests/Fixtures/Fixtures20/Ceo.php diff --git a/tests/Annotated/Fixtures/Fixtures20/Customer.php b/tests/Fixtures/Fixtures20/Customer.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures20/Customer.php rename to tests/Fixtures/Fixtures20/Customer.php diff --git a/tests/Annotated/Fixtures/Fixtures20/Employee.php b/tests/Fixtures/Fixtures20/Employee.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures20/Employee.php rename to tests/Fixtures/Fixtures20/Employee.php diff --git a/tests/Annotated/Fixtures/Fixtures20/Person.php b/tests/Fixtures/Fixtures20/Person.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures20/Person.php rename to tests/Fixtures/Fixtures20/Person.php diff --git a/tests/Annotated/Fixtures/Fixtures21/Buyer.php b/tests/Fixtures/Fixtures21/Buyer.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures21/Buyer.php rename to tests/Fixtures/Fixtures21/Buyer.php diff --git a/tests/Annotated/Fixtures/Fixtures21/Employee.php b/tests/Fixtures/Fixtures21/Employee.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures21/Employee.php rename to tests/Fixtures/Fixtures21/Employee.php diff --git a/tests/Annotated/Fixtures/Fixtures21/Executive.php b/tests/Fixtures/Fixtures21/Executive.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures21/Executive.php rename to tests/Fixtures/Fixtures21/Executive.php diff --git a/tests/Annotated/Fixtures/Fixtures21/Person.php b/tests/Fixtures/Fixtures21/Person.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures21/Person.php rename to tests/Fixtures/Fixtures21/Person.php diff --git a/tests/Annotated/Fixtures/Fixtures22/Annotated/LocalManager.php b/tests/Fixtures/Fixtures22/Annotated/LocalManager.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures22/Annotated/LocalManager.php rename to tests/Fixtures/Fixtures22/Annotated/LocalManager.php diff --git a/tests/Annotated/Fixtures/Fixtures22/Annotated/LocalSupplier.php b/tests/Fixtures/Fixtures22/Annotated/LocalSupplier.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures22/Annotated/LocalSupplier.php rename to tests/Fixtures/Fixtures22/Annotated/LocalSupplier.php diff --git a/tests/Annotated/Fixtures/Fixtures22/Annotated/Person.php b/tests/Fixtures/Fixtures22/Annotated/Person.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures22/Annotated/Person.php rename to tests/Fixtures/Fixtures22/Annotated/Person.php diff --git a/tests/Annotated/Fixtures/Fixtures22/Annotated/Supplier.php b/tests/Fixtures/Fixtures22/Annotated/Supplier.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures22/Annotated/Supplier.php rename to tests/Fixtures/Fixtures22/Annotated/Supplier.php diff --git a/tests/Annotated/Fixtures/Fixtures22/Attributed/LocalManager.php b/tests/Fixtures/Fixtures22/Attributed/LocalManager.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures22/Attributed/LocalManager.php rename to tests/Fixtures/Fixtures22/Attributed/LocalManager.php diff --git a/tests/Annotated/Fixtures/Fixtures22/Attributed/LocalSupplier.php b/tests/Fixtures/Fixtures22/Attributed/LocalSupplier.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures22/Attributed/LocalSupplier.php rename to tests/Fixtures/Fixtures22/Attributed/LocalSupplier.php diff --git a/tests/Annotated/Fixtures/Fixtures22/Attributed/Person.php b/tests/Fixtures/Fixtures22/Attributed/Person.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures22/Attributed/Person.php rename to tests/Fixtures/Fixtures22/Attributed/Person.php diff --git a/tests/Annotated/Fixtures/Fixtures22/Attributed/Supplier.php b/tests/Fixtures/Fixtures22/Attributed/Supplier.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures22/Attributed/Supplier.php rename to tests/Fixtures/Fixtures22/Attributed/Supplier.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithClassColumn/BaseEvent.php b/tests/Fixtures/Fixtures23/STIWithClassColumn/BaseEvent.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithClassColumn/BaseEvent.php rename to tests/Fixtures/Fixtures23/STIWithClassColumn/BaseEvent.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithClassColumn/Comment.php b/tests/Fixtures/Fixtures23/STIWithClassColumn/Comment.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithClassColumn/Comment.php rename to tests/Fixtures/Fixtures23/STIWithClassColumn/Comment.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithClassColumn/CommentCreated.php b/tests/Fixtures/Fixtures23/STIWithClassColumn/CommentCreated.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithClassColumn/CommentCreated.php rename to tests/Fixtures/Fixtures23/STIWithClassColumn/CommentCreated.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithClassColumn/CommentUpdated.php b/tests/Fixtures/Fixtures23/STIWithClassColumn/CommentUpdated.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithClassColumn/CommentUpdated.php rename to tests/Fixtures/Fixtures23/STIWithClassColumn/CommentUpdated.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithClassColumn/EventEmitterInterface.php b/tests/Fixtures/Fixtures23/STIWithClassColumn/EventEmitterInterface.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithClassColumn/EventEmitterInterface.php rename to tests/Fixtures/Fixtures23/STIWithClassColumn/EventEmitterInterface.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithEntityColumn/BaseEvent.php b/tests/Fixtures/Fixtures23/STIWithEntityColumn/BaseEvent.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithEntityColumn/BaseEvent.php rename to tests/Fixtures/Fixtures23/STIWithEntityColumn/BaseEvent.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithEntityColumn/Comment.php b/tests/Fixtures/Fixtures23/STIWithEntityColumn/Comment.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithEntityColumn/Comment.php rename to tests/Fixtures/Fixtures23/STIWithEntityColumn/Comment.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithEntityColumn/CommentCreated.php b/tests/Fixtures/Fixtures23/STIWithEntityColumn/CommentCreated.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithEntityColumn/CommentCreated.php rename to tests/Fixtures/Fixtures23/STIWithEntityColumn/CommentCreated.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithEntityColumn/CommentUpdated.php b/tests/Fixtures/Fixtures23/STIWithEntityColumn/CommentUpdated.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithEntityColumn/CommentUpdated.php rename to tests/Fixtures/Fixtures23/STIWithEntityColumn/CommentUpdated.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithEntityColumn/EventEmitterInterface.php b/tests/Fixtures/Fixtures23/STIWithEntityColumn/EventEmitterInterface.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithEntityColumn/EventEmitterInterface.php rename to tests/Fixtures/Fixtures23/STIWithEntityColumn/EventEmitterInterface.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithPropertyColumn/BaseEvent.php b/tests/Fixtures/Fixtures23/STIWithPropertyColumn/BaseEvent.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithPropertyColumn/BaseEvent.php rename to tests/Fixtures/Fixtures23/STIWithPropertyColumn/BaseEvent.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithPropertyColumn/Comment.php b/tests/Fixtures/Fixtures23/STIWithPropertyColumn/Comment.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithPropertyColumn/Comment.php rename to tests/Fixtures/Fixtures23/STIWithPropertyColumn/Comment.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithPropertyColumn/CommentCreated.php b/tests/Fixtures/Fixtures23/STIWithPropertyColumn/CommentCreated.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithPropertyColumn/CommentCreated.php rename to tests/Fixtures/Fixtures23/STIWithPropertyColumn/CommentCreated.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithPropertyColumn/CommentUpdated.php b/tests/Fixtures/Fixtures23/STIWithPropertyColumn/CommentUpdated.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithPropertyColumn/CommentUpdated.php rename to tests/Fixtures/Fixtures23/STIWithPropertyColumn/CommentUpdated.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithPropertyColumn/EventEmitterInterface.php b/tests/Fixtures/Fixtures23/STIWithPropertyColumn/EventEmitterInterface.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithPropertyColumn/EventEmitterInterface.php rename to tests/Fixtures/Fixtures23/STIWithPropertyColumn/EventEmitterInterface.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithTableColumn/BaseEvent.php b/tests/Fixtures/Fixtures23/STIWithTableColumn/BaseEvent.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithTableColumn/BaseEvent.php rename to tests/Fixtures/Fixtures23/STIWithTableColumn/BaseEvent.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithTableColumn/Comment.php b/tests/Fixtures/Fixtures23/STIWithTableColumn/Comment.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithTableColumn/Comment.php rename to tests/Fixtures/Fixtures23/STIWithTableColumn/Comment.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithTableColumn/CommentCreated.php b/tests/Fixtures/Fixtures23/STIWithTableColumn/CommentCreated.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithTableColumn/CommentCreated.php rename to tests/Fixtures/Fixtures23/STIWithTableColumn/CommentCreated.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithTableColumn/CommentUpdated.php b/tests/Fixtures/Fixtures23/STIWithTableColumn/CommentUpdated.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithTableColumn/CommentUpdated.php rename to tests/Fixtures/Fixtures23/STIWithTableColumn/CommentUpdated.php diff --git a/tests/Annotated/Fixtures/Fixtures23/STIWithTableColumn/EventEmitterInterface.php b/tests/Fixtures/Fixtures23/STIWithTableColumn/EventEmitterInterface.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures23/STIWithTableColumn/EventEmitterInterface.php rename to tests/Fixtures/Fixtures23/STIWithTableColumn/EventEmitterInterface.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Class/DatabaseField/DatabaseField.php b/tests/Fixtures/Fixtures24/Class/DatabaseField/DatabaseField.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Class/DatabaseField/DatabaseField.php rename to tests/Fixtures/Fixtures24/Class/DatabaseField/DatabaseField.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Class/DatabaseField/Target.php b/tests/Fixtures/Fixtures24/Class/DatabaseField/Target.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Class/DatabaseField/Target.php rename to tests/Fixtures/Fixtures24/Class/DatabaseField/Target.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Class/PrimaryKey/PrimaryKey.php b/tests/Fixtures/Fixtures24/Class/PrimaryKey/PrimaryKey.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Class/PrimaryKey/PrimaryKey.php rename to tests/Fixtures/Fixtures24/Class/PrimaryKey/PrimaryKey.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Class/PrimaryKey/Target.php b/tests/Fixtures/Fixtures24/Class/PrimaryKey/Target.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Class/PrimaryKey/Target.php rename to tests/Fixtures/Fixtures24/Class/PrimaryKey/Target.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Class/PropertyName/PropertyName.php b/tests/Fixtures/Fixtures24/Class/PropertyName/PropertyName.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Class/PropertyName/PropertyName.php rename to tests/Fixtures/Fixtures24/Class/PropertyName/PropertyName.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Class/PropertyName/Target.php b/tests/Fixtures/Fixtures24/Class/PropertyName/Target.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Class/PropertyName/Target.php rename to tests/Fixtures/Fixtures24/Class/PropertyName/Target.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Entity/DatabaseField/DatabaseField.php b/tests/Fixtures/Fixtures24/Entity/DatabaseField/DatabaseField.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Entity/DatabaseField/DatabaseField.php rename to tests/Fixtures/Fixtures24/Entity/DatabaseField/DatabaseField.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Entity/DatabaseField/Target.php b/tests/Fixtures/Fixtures24/Entity/DatabaseField/Target.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Entity/DatabaseField/Target.php rename to tests/Fixtures/Fixtures24/Entity/DatabaseField/Target.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Entity/PrimaryKey/PrimaryKey.php b/tests/Fixtures/Fixtures24/Entity/PrimaryKey/PrimaryKey.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Entity/PrimaryKey/PrimaryKey.php rename to tests/Fixtures/Fixtures24/Entity/PrimaryKey/PrimaryKey.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Entity/PrimaryKey/Target.php b/tests/Fixtures/Fixtures24/Entity/PrimaryKey/Target.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Entity/PrimaryKey/Target.php rename to tests/Fixtures/Fixtures24/Entity/PrimaryKey/Target.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Entity/PropertyName/PropertyName.php b/tests/Fixtures/Fixtures24/Entity/PropertyName/PropertyName.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Entity/PropertyName/PropertyName.php rename to tests/Fixtures/Fixtures24/Entity/PropertyName/PropertyName.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Entity/PropertyName/Target.php b/tests/Fixtures/Fixtures24/Entity/PropertyName/Target.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Entity/PropertyName/Target.php rename to tests/Fixtures/Fixtures24/Entity/PropertyName/Target.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Property/DatabaseField/DatabaseField.php b/tests/Fixtures/Fixtures24/Property/DatabaseField/DatabaseField.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Property/DatabaseField/DatabaseField.php rename to tests/Fixtures/Fixtures24/Property/DatabaseField/DatabaseField.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Property/DatabaseField/Target.php b/tests/Fixtures/Fixtures24/Property/DatabaseField/Target.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Property/DatabaseField/Target.php rename to tests/Fixtures/Fixtures24/Property/DatabaseField/Target.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Property/PrimaryKey/PrimaryKey.php b/tests/Fixtures/Fixtures24/Property/PrimaryKey/PrimaryKey.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Property/PrimaryKey/PrimaryKey.php rename to tests/Fixtures/Fixtures24/Property/PrimaryKey/PrimaryKey.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Property/PrimaryKey/Target.php b/tests/Fixtures/Fixtures24/Property/PrimaryKey/Target.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Property/PrimaryKey/Target.php rename to tests/Fixtures/Fixtures24/Property/PrimaryKey/Target.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Property/PropertyName/PropertyName.php b/tests/Fixtures/Fixtures24/Property/PropertyName/PropertyName.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Property/PropertyName/PropertyName.php rename to tests/Fixtures/Fixtures24/Property/PropertyName/PropertyName.php diff --git a/tests/Annotated/Fixtures/Fixtures24/Property/PropertyName/Target.php b/tests/Fixtures/Fixtures24/Property/PropertyName/Target.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures24/Property/PropertyName/Target.php rename to tests/Fixtures/Fixtures24/Property/PropertyName/Target.php diff --git a/tests/Annotated/Fixtures/Fixtures25/PostgreSQL/WithGeneratedSerial.php b/tests/Fixtures/Fixtures25/PostgreSQL/WithGeneratedSerial.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures25/PostgreSQL/WithGeneratedSerial.php rename to tests/Fixtures/Fixtures25/PostgreSQL/WithGeneratedSerial.php diff --git a/tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php b/tests/Fixtures/Fixtures25/WithGeneratedFields.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures25/WithGeneratedFields.php rename to tests/Fixtures/Fixtures25/WithGeneratedFields.php diff --git a/tests/Annotated/Fixtures/Fixtures26/Address.php b/tests/Fixtures/Fixtures26/Address.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures26/Address.php rename to tests/Fixtures/Fixtures26/Address.php diff --git a/tests/Annotated/Fixtures/Fixtures26/City.php b/tests/Fixtures/Fixtures26/City.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures26/City.php rename to tests/Fixtures/Fixtures26/City.php diff --git a/tests/Annotated/Fixtures/Fixtures26/CityTypecast.php b/tests/Fixtures/Fixtures26/CityTypecast.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures26/CityTypecast.php rename to tests/Fixtures/Fixtures26/CityTypecast.php diff --git a/tests/Annotated/Fixtures/Fixtures26/User.php b/tests/Fixtures/Fixtures26/User.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures26/User.php rename to tests/Fixtures/Fixtures26/User.php diff --git a/tests/Annotated/Fixtures/Fixtures27/BtJoined.php b/tests/Fixtures/Fixtures27/BtJoined.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/BtJoined.php rename to tests/Fixtures/Fixtures27/BtJoined.php diff --git a/tests/Annotated/Fixtures/Fixtures27/BtParent.php b/tests/Fixtures/Fixtures27/BtParent.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/BtParent.php rename to tests/Fixtures/Fixtures27/BtParent.php diff --git a/tests/Annotated/Fixtures/Fixtures27/BtTarget.php b/tests/Fixtures/Fixtures27/BtTarget.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/BtTarget.php rename to tests/Fixtures/Fixtures27/BtTarget.php diff --git a/tests/Annotated/Fixtures/Fixtures27/JgLeaf.php b/tests/Fixtures/Fixtures27/JgLeaf.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/JgLeaf.php rename to tests/Fixtures/Fixtures27/JgLeaf.php diff --git a/tests/Annotated/Fixtures/Fixtures27/JgMid.php b/tests/Fixtures/Fixtures27/JgMid.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/JgMid.php rename to tests/Fixtures/Fixtures27/JgMid.php diff --git a/tests/Annotated/Fixtures/Fixtures27/JgParent.php b/tests/Fixtures/Fixtures27/JgParent.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/JgParent.php rename to tests/Fixtures/Fixtures27/JgParent.php diff --git a/tests/Annotated/Fixtures/Fixtures27/JgTarget.php b/tests/Fixtures/Fixtures27/JgTarget.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/JgTarget.php rename to tests/Fixtures/Fixtures27/JgTarget.php diff --git a/tests/Annotated/Fixtures/Fixtures27/SoParent.php b/tests/Fixtures/Fixtures27/SoParent.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/SoParent.php rename to tests/Fixtures/Fixtures27/SoParent.php diff --git a/tests/Annotated/Fixtures/Fixtures27/SoSeparate.php b/tests/Fixtures/Fixtures27/SoSeparate.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/SoSeparate.php rename to tests/Fixtures/Fixtures27/SoSeparate.php diff --git a/tests/Annotated/Fixtures/Fixtures27/SoSti.php b/tests/Fixtures/Fixtures27/SoSti.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/SoSti.php rename to tests/Fixtures/Fixtures27/SoSti.php diff --git a/tests/Annotated/Fixtures/Fixtures27/SoTarget.php b/tests/Fixtures/Fixtures27/SoTarget.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/SoTarget.php rename to tests/Fixtures/Fixtures27/SoTarget.php diff --git a/tests/Annotated/Fixtures/Fixtures27/StChild.php b/tests/Fixtures/Fixtures27/StChild.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/StChild.php rename to tests/Fixtures/Fixtures27/StChild.php diff --git a/tests/Annotated/Fixtures/Fixtures27/StParent.php b/tests/Fixtures/Fixtures27/StParent.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/StParent.php rename to tests/Fixtures/Fixtures27/StParent.php diff --git a/tests/Annotated/Fixtures/Fixtures27/StTarget.php b/tests/Fixtures/Fixtures27/StTarget.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/StTarget.php rename to tests/Fixtures/Fixtures27/StTarget.php diff --git a/tests/Annotated/Fixtures/Fixtures27/TrJti.php b/tests/Fixtures/Fixtures27/TrJti.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/TrJti.php rename to tests/Fixtures/Fixtures27/TrJti.php diff --git a/tests/Annotated/Fixtures/Fixtures27/TrParent.php b/tests/Fixtures/Fixtures27/TrParent.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/TrParent.php rename to tests/Fixtures/Fixtures27/TrParent.php diff --git a/tests/Annotated/Fixtures/Fixtures27/TrRelTrait.php b/tests/Fixtures/Fixtures27/TrRelTrait.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/TrRelTrait.php rename to tests/Fixtures/Fixtures27/TrRelTrait.php diff --git a/tests/Annotated/Fixtures/Fixtures27/TrTarget.php b/tests/Fixtures/Fixtures27/TrTarget.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures27/TrTarget.php rename to tests/Fixtures/Fixtures27/TrTarget.php diff --git a/tests/Annotated/Fixtures/Fixtures28/Event.php b/tests/Fixtures/Fixtures28/Event.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures28/Event.php rename to tests/Fixtures/Fixtures28/Event.php diff --git a/tests/Annotated/Fixtures/Fixtures3/User.php b/tests/Fixtures/Fixtures3/User.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures3/User.php rename to tests/Fixtures/Fixtures3/User.php diff --git a/tests/Annotated/Fixtures/Fixtures4/User.php b/tests/Fixtures/Fixtures4/User.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures4/User.php rename to tests/Fixtures/Fixtures4/User.php diff --git a/tests/Annotated/Fixtures/Fixtures5/Simple.php b/tests/Fixtures/Fixtures5/Simple.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures5/Simple.php rename to tests/Fixtures/Fixtures5/Simple.php diff --git a/tests/Annotated/Fixtures/Fixtures5/User.php b/tests/Fixtures/Fixtures5/User.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures5/User.php rename to tests/Fixtures/Fixtures5/User.php diff --git a/tests/Annotated/Fixtures/Fixtures6/Address.php b/tests/Fixtures/Fixtures6/Address.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures6/Address.php rename to tests/Fixtures/Fixtures6/Address.php diff --git a/tests/Annotated/Fixtures/Fixtures6/User.php b/tests/Fixtures/Fixtures6/User.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures6/User.php rename to tests/Fixtures/Fixtures6/User.php diff --git a/tests/Annotated/Fixtures/Fixtures7/Address.php b/tests/Fixtures/Fixtures7/Address.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures7/Address.php rename to tests/Fixtures/Fixtures7/Address.php diff --git a/tests/Annotated/Fixtures/Fixtures7/User.php b/tests/Fixtures/Fixtures7/User.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures7/User.php rename to tests/Fixtures/Fixtures7/User.php diff --git a/tests/Annotated/Fixtures/Fixtures8/Article.php b/tests/Fixtures/Fixtures8/Article.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures8/Article.php rename to tests/Fixtures/Fixtures8/Article.php diff --git a/tests/Annotated/Fixtures/Fixtures8/Post.php b/tests/Fixtures/Fixtures8/Post.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures8/Post.php rename to tests/Fixtures/Fixtures8/Post.php diff --git a/tests/Annotated/Fixtures/Fixtures8/Some.php b/tests/Fixtures/Fixtures8/Some.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures8/Some.php rename to tests/Fixtures/Fixtures8/Some.php diff --git a/tests/Annotated/Fixtures/Fixtures9/OrderedIdx.php b/tests/Fixtures/Fixtures9/OrderedIdx.php similarity index 100% rename from tests/Annotated/Fixtures/Fixtures9/OrderedIdx.php rename to tests/Fixtures/Fixtures9/OrderedIdx.php diff --git a/tests/Annotated/Fixtures/RefersToMorphed/Comment.php b/tests/Fixtures/RefersToMorphed/Comment.php similarity index 100% rename from tests/Annotated/Fixtures/RefersToMorphed/Comment.php rename to tests/Fixtures/RefersToMorphed/Comment.php diff --git a/tests/Annotated/Fixtures/RefersToMorphed/MorphedParentInterface.php b/tests/Fixtures/RefersToMorphed/MorphedParentInterface.php similarity index 100% rename from tests/Annotated/Fixtures/RefersToMorphed/MorphedParentInterface.php rename to tests/Fixtures/RefersToMorphed/MorphedParentInterface.php diff --git a/tests/Annotated/Fixtures/RefersToMorphed/Post.php b/tests/Fixtures/RefersToMorphed/Post.php similarity index 100% rename from tests/Annotated/Fixtures/RefersToMorphed/Post.php rename to tests/Fixtures/RefersToMorphed/Post.php diff --git a/tests/Annotated/Unit/Attribute/ColumnTest.php b/tests/Unit/Attribute/ColumnTest.php similarity index 100% rename from tests/Annotated/Unit/Attribute/ColumnTest.php rename to tests/Unit/Attribute/ColumnTest.php diff --git a/tests/Annotated/Unit/Attribute/SingleTable/IntegerEnum.php b/tests/Unit/Attribute/SingleTable/IntegerEnum.php similarity index 100% rename from tests/Annotated/Unit/Attribute/SingleTable/IntegerEnum.php rename to tests/Unit/Attribute/SingleTable/IntegerEnum.php diff --git a/tests/Annotated/Unit/Attribute/SingleTable/SingleTableTest.php b/tests/Unit/Attribute/SingleTable/SingleTableTest.php similarity index 100% rename from tests/Annotated/Unit/Attribute/SingleTable/SingleTableTest.php rename to tests/Unit/Attribute/SingleTable/SingleTableTest.php diff --git a/tests/Annotated/Unit/Attribute/SingleTable/StringEnum.php b/tests/Unit/Attribute/SingleTable/StringEnum.php similarity index 100% rename from tests/Annotated/Unit/Attribute/SingleTable/StringEnum.php rename to tests/Unit/Attribute/SingleTable/StringEnum.php diff --git a/tests/Annotated/Unit/Attribute/SingleTable/StringableObject.php b/tests/Unit/Attribute/SingleTable/StringableObject.php similarity index 100% rename from tests/Annotated/Unit/Attribute/SingleTable/StringableObject.php rename to tests/Unit/Attribute/SingleTable/StringableObject.php diff --git a/tests/Annotated/Unit/Locator/TokenizerEmbeddingLocatorTest.php b/tests/Unit/Locator/TokenizerEmbeddingLocatorTest.php similarity index 100% rename from tests/Annotated/Unit/Locator/TokenizerEmbeddingLocatorTest.php rename to tests/Unit/Locator/TokenizerEmbeddingLocatorTest.php diff --git a/tests/Annotated/Unit/Locator/TokenizerEntityLocatorTest.php b/tests/Unit/Locator/TokenizerEntityLocatorTest.php similarity index 100% rename from tests/Annotated/Unit/Locator/TokenizerEntityLocatorTest.php rename to tests/Unit/Locator/TokenizerEntityLocatorTest.php diff --git a/tests/Annotated/Unit/ReaderFactoryTest.php b/tests/Unit/ReaderFactoryTest.php similarity index 100% rename from tests/Annotated/Unit/ReaderFactoryTest.php rename to tests/Unit/ReaderFactoryTest.php diff --git a/tests/Annotated/Unit/Utils/EntityUtilsTest.php b/tests/Unit/Utils/EntityUtilsTest.php similarity index 100% rename from tests/Annotated/Unit/Utils/EntityUtilsTest.php rename to tests/Unit/Utils/EntityUtilsTest.php From e744a7367755922966217fd02d3554128dbf049b Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 16:59:09 +0400 Subject: [PATCH 09/12] 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 f04f7af0..b10af4f2 100644 --- a/composer.json +++ b/composer.json @@ -54,7 +54,7 @@ "require-dev": { "bamarni/composer-bin-plugin": "^1.8", "buggregator/trap": "^1.20", - "cycle/testing": "^0.1", + "cycle/testing": "^0.1.1", "doctrine/annotations": "^2.0.2", "llm/skills": "^1.20", "roxblnfk/unpoly": "^1.8", From 8af1869fc327aafe66e0751609f025a91e10e686 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 17:01:15 +0400 Subject: [PATCH 10/12] test: generate regression cases with cycle-testing new-case Assisted-By: Claude Opus 5.5 --- README.md | 3 ++- composer.json | 4 ++++ testo.php | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bcea4c07..610654d0 100644 --- a/README.md +++ b/README.md @@ -384,4 +384,5 @@ composer test # every suite; a driver whose server is down is skipp composer db:down ``` -`composer test:mysql`, `test:postgres` and `test:sqlserver` run one driver. +`composer test:mysql`, `test:postgres` and `test:sqlserver` run one driver. To reproduce a new issue, generate a case: +`composer test:new-case -- 123` writes `tests/Regression/Issue123`. diff --git a/composer.json b/composer.json index b10af4f2..3770a5e6 100644 --- a/composer.json +++ b/composer.json @@ -83,11 +83,15 @@ "db:up": "docker compose -f vendor/cycle/testing/resources/docker/compose.yaml up -d --wait", "test": "testo", "test:mysql": "testo --suite=Feature/MySQL --suite=Acceptance/MySQL --suite=Regression/MySQL", + "test:new-case": "cycle-testing new-case --template=orm-attributes", "test:postgres": "testo --suite=Feature/Postgres --suite=Acceptance/Postgres --suite=Regression/Postgres", "test:sqlite": "testo --suite=Feature/SQLite --suite=Acceptance/SQLite --suite=Regression/SQLite", "test:sqlserver": "testo --suite=Feature/SQLServer --suite=Acceptance/SQLServer --suite=Regression/SQLServer", "test:unit": "testo --suite=Unit" }, + "scripts-descriptions": { + "test:new-case": "Create a regression case for an issue: composer test:new-case -- " + }, "extra": { "bamarni-bin": { "bin-links": true, diff --git a/testo.php b/testo.php index f0a5034e..bd8e6bdf 100644 --- a/testo.php +++ b/testo.php @@ -13,4 +13,5 @@ layout: Layout::prefixed(['secondary' => 'secondary_']), plugins: [new OrmPlugin()], ) + ->regression('tests/Regression', plugins: [new OrmPlugin()]) ->build(); From 1ef8257be033bff7e5f8f403b2ad718f270b030a Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 17:06:47 +0400 Subject: [PATCH 11/12] ci: run tests through the shared cycle/gh-actions workflow Assisted-By: Claude Opus 5.5 --- .github/workflows/main.yml | 107 ++++--------------------------------- 1 file changed, 11 insertions(+), 96 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9f117280..2459c2c3 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,9 +1,12 @@ +--- + name: build on: # yamllint disable-line rule:truthy - pull_request: push: - branches: [4.x] + branches: + - 4.x + pull_request: null permissions: contents: read @@ -13,98 +16,10 @@ concurrency: cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - test: - name: Unit + SQLite, PHP ${{ matrix.php-version }} (${{ matrix.dependencies }}) - runs-on: ubuntu-latest - 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: pcov - extensions: mbstring, pdo, pdo_sqlite - - - name: Validate composer.json - run: composer validate --ansi --strict - - - name: Install dependencies with composer - uses: ramsey/composer-install@v4 - with: - dependency-versions: ${{ matrix.dependencies }} - - - name: Execute tests - env: - DB_DRIVERS: sqlite - run: composer test -- --coverage-clover=runtime/clover.xml - - - name: Upload coverage to Codecov - continue-on-error: true # if is fork - uses: codecov/codecov-action@v7 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./runtime/clover.xml - flags: sqlite - - database: - name: ${{ matrix.driver }}, PHP ${{ matrix.php-version }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - php-version: ['8.2', '8.5'] - driver: [mysql, postgres, sqlserver] - include: - - driver: mysql - extensions: pdo_mysql - - driver: postgres - extensions: pdo_pgsql - - driver: sqlserver - extensions: sqlsrv, pdo_sqlsrv - env: - DB_REQUIRED: 1 - steps: - - name: Install ODBC driver - if: matrix.driver == 'sqlserver' - 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 PHP ${{ matrix.php-version }} - uses: shivammathur/setup-php@v2 - with: - php-version: ${{ matrix.php-version }} - coverage: pcov - tools: pecl - extensions: mbstring, pdo, ${{ matrix.extensions }} - - - name: Install dependencies with composer - uses: ramsey/composer-install@v4 - - - name: Start the database - run: composer db:up -- ${{ matrix.driver }} - - - name: Execute tests - run: composer test:${{ matrix.driver }} -- --coverage-clover=runtime/clover.xml + testo: + uses: cycle/gh-actions/.github/workflows/testo.yml@master + with: + coverage: true + secrets: inherit - - name: Upload coverage to Codecov - continue-on-error: true # if is fork - uses: codecov/codecov-action@v7 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./runtime/clover.xml - flags: ${{ matrix.driver }} +... From e922fe32ebbd8109023ff46a6c514bda0aa9192a Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Fri, 20 Nov 2026 17:30:43 +0400 Subject: [PATCH 12/12] ci: show the test job as Testo Assisted-By: Claude Opus 5.5 --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 2459c2c3..62180330 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,6 +17,7 @@ concurrency: jobs: testo: + name: Testo uses: cycle/gh-actions/.github/workflows/testo.yml@master with: coverage: true