From ec6fd0612d7d2ad003f5ac1ef45916f6c20b5364 Mon Sep 17 00:00:00 2001 From: daycry <7590335+daycry@users.noreply.github.com> Date: Thu, 29 Aug 2024 10:28:51 +0200 Subject: [PATCH] Testing --- phpunit.xml.dist | 122 ++++++++++------------------ src/Structures/Mergeable.php | 2 + tests/draft/BaseDrafterTest.php | 2 + tests/draft/DatabaseDrafterTest.php | 6 +- tests/draft/ModelDrafterTest.php | 2 + tests/misc/BaseHandlerTest.php | 2 + tests/misc/LiveTest.php | 6 +- 7 files changed, 56 insertions(+), 86 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index ac88cfc..00ddd04 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,102 +1,64 @@ - - - + + + + + + + + + + + + + + + - ./src/ + ./src ./src/Config - ./src/Views + ./src/Language + ./src/Collectors - - - - - - - - - + ./tests + ./tests/Language - - - - - - - 0.50 - - - 30 - - - 2 - - - true - - - true - - - - - - - - - + + + + - - - - + + + - - - - - - - - - + diff --git a/src/Structures/Mergeable.php b/src/Structures/Mergeable.php index 8e791ce..5a800e6 100644 --- a/src/Structures/Mergeable.php +++ b/src/Structures/Mergeable.php @@ -6,7 +6,9 @@ use Countable; use IteratorAggregate; use Traversable; +use AllowDynamicProperties; +#[AllowDynamicProperties] class Mergeable implements Countable, IteratorAggregate { /** diff --git a/tests/draft/BaseDrafterTest.php b/tests/draft/BaseDrafterTest.php index d276e91..312b2c2 100644 --- a/tests/draft/BaseDrafterTest.php +++ b/tests/draft/BaseDrafterTest.php @@ -11,6 +11,8 @@ */ final class BaseDrafterTest extends SchemasTestCase { + protected ?BaseDrafter $handler = null; + protected function setUp(): void { parent::setUp(); diff --git a/tests/draft/DatabaseDrafterTest.php b/tests/draft/DatabaseDrafterTest.php index b64f78c..f4b308c 100644 --- a/tests/draft/DatabaseDrafterTest.php +++ b/tests/draft/DatabaseDrafterTest.php @@ -35,7 +35,7 @@ public function testHasAllTables() public function testHasSpecificTable() { - $this->assertObjectHasAttribute('factories', $this->schema->tables); + $this->assertTrue(property_exists($this->schema->tables, 'factories')); } public function testDetectsPivotTablesWithFK() @@ -50,7 +50,7 @@ public function testDetectsPivotTablesWithoutFK() public function testIgnoredTables() { - $this->assertObjectNotHasAttribute('migrations', $this->schema->tables); + $this->assertFalse(property_exists($this->schema->tables, 'migrations')); $config = new Schemas(); $config->ignoredTables = []; @@ -58,7 +58,7 @@ public function testIgnoredTables() $handler = new DatabaseHandler($config, 'tests'); $schema = $handler->draft(); - $this->assertObjectHasAttribute('migrations', $schema->tables); + $this->assertTrue(property_exists($schema->tables, 'migrations')); } // -------------------- RELATIONSHIPS -------------------- diff --git a/tests/draft/ModelDrafterTest.php b/tests/draft/ModelDrafterTest.php index e6ff924..af74751 100644 --- a/tests/draft/ModelDrafterTest.php +++ b/tests/draft/ModelDrafterTest.php @@ -8,6 +8,8 @@ */ final class ModelDrafterTest extends SchemasTestCase { + private ?ModelHandler $handler = null; + protected function setUp(): void { parent::setUp(); diff --git a/tests/misc/BaseHandlerTest.php b/tests/misc/BaseHandlerTest.php index 9643e78..9f67c27 100644 --- a/tests/misc/BaseHandlerTest.php +++ b/tests/misc/BaseHandlerTest.php @@ -8,6 +8,8 @@ */ final class BaseHandlerTest extends SchemasTestCase { + protected ?BaseHandler $handler = null; + protected function setUp(): void { parent::setUp(); diff --git a/tests/misc/LiveTest.php b/tests/misc/LiveTest.php index ffa0d8c..cc9605d 100644 --- a/tests/misc/LiveTest.php +++ b/tests/misc/LiveTest.php @@ -36,7 +36,7 @@ public function testDatabaseToCache() $schemaFromCache = $cache->get('schema-testing'); $this->assertCount(is_countable($schemaFromCache->tables) ? count($schemaFromCache->tables) : 0, $schemaFromService->tables); - $this->assertObjectHasAttribute('factories', $schemaFromCache->tables); + $this->assertTrue(property_exists($schemaFromService->tables, 'factories')); } public function testDatabaseMergeFile() @@ -50,7 +50,7 @@ public function testDatabaseMergeFile() $schema = $this->schemas->draft([$databaseHandler, $fileHandler])->get(); - $this->assertObjectHasAttribute('products', $schema->tables); + $this->assertTrue(property_exists($schema->tables, 'products')); $this->assertCount(3, $schema->tables->workers->relations); } @@ -66,7 +66,7 @@ public function testMergeAllDrafters() $schema = $this->schemas->draft([$databaseHandler, $modelHandler, $fileHandler])->get(); - $this->assertObjectHasAttribute('products', $schema->tables); + $this->assertTrue(property_exists($schema->tables, 'products')); $this->assertSame('Tests\Support\Models\FactoryModel', $schema->tables->factories->model); $this->assertCount(3, $schema->tables->workers->relations); }