From b7981c7458233ad8bd8abd6854e3c66b3536406d Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Sat, 21 Nov 2026 00:30:14 +0400 Subject: [PATCH 1/3] test(harness): run inline tests and a database-less ORM suite through the harness Assisted-By: Claude Opus 5.5 --- .../HarnessSuite/Inline/InlineCase.php | 19 +++++++++++++++++++ tests/Unit/HarnessTest.php | 16 ++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/Fixtures/HarnessSuite/Inline/InlineCase.php diff --git a/tests/Fixtures/HarnessSuite/Inline/InlineCase.php b/tests/Fixtures/HarnessSuite/Inline/InlineCase.php new file mode 100644 index 0000000..1fda522 --- /dev/null +++ b/tests/Fixtures/HarnessSuite/Inline/InlineCase.php @@ -0,0 +1,19 @@ + Date: Sat, 21 Nov 2026 00:30:15 +0400 Subject: [PATCH 2/3] test(orm): report a heap entity without a node A custom HeapInterface can iterate an entity it holds no node for. Assisted-By: Claude Opus 5.5 --- tests/Unit/HeapIntegrityTest.php | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/Unit/HeapIntegrityTest.php b/tests/Unit/HeapIntegrityTest.php index 771d8af..c70d66d 100644 --- a/tests/Unit/HeapIntegrityTest.php +++ b/tests/Unit/HeapIntegrityTest.php @@ -5,6 +5,8 @@ namespace Cycle\Testing\Tests\Unit; use Cycle\ORM\EntityManager; +use Cycle\ORM\Heap\HeapInterface; +use Cycle\ORM\Heap\Node; use Cycle\ORM\Mapper\Mapper; use Cycle\ORM\ORMInterface; use Cycle\ORM\Reference\Reference; @@ -300,6 +302,40 @@ public function collectionsAreComparedAsLists(): void Assert::same($violations, ['Entity and State are not in sync `post`.`author`']); } + public function heapEntityWithoutANodeIsReported(): void + { + $heap = new class implements HeapInterface, \IteratorAggregate { + public function getIterator(): \Iterator + { + return new \ArrayIterator([new User()]); + } + + public function has(object $entity): bool + { + return false; + } + + public function get(object $entity): ?Node + { + return null; + } + + public function find(string $role, array $scope): ?object + { + return null; + } + + public function attach(object $entity, Node $node, array $index = []): void {} + + public function detach(object $entity): void {} + + public function clean(): void {} + }; + $orm = Memory::orm(UserSchema::schema())->with(heap: $heap); + + Assert::same(HeapIntegrity::violations($orm), ['No node for a heap entity of class ' . User::class . '.']); + } + /** * @return array{ORMInterface, User} */ From 2b71cd6f6e3c8a7f5aa381020ef7b0339833a534 Mon Sep 17 00:00:00 2001 From: roxblnfk Date: Sat, 21 Nov 2026 00:30:16 +0400 Subject: [PATCH 3/3] test(regression): generate template cases through the CLI and Config The acceptance test now follows the documented flow, new-case then a regression suite from Config, so every driver suite runs both and Codecov no longer counts their lines from static analysis. Assisted-By: Claude Opus 5.5 --- tests/Acceptance/Common/CaseTemplatesTest.php | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/Acceptance/Common/CaseTemplatesTest.php b/tests/Acceptance/Common/CaseTemplatesTest.php index f4e58bf..4e4b129 100644 --- a/tests/Acceptance/Common/CaseTemplatesTest.php +++ b/tests/Acceptance/Common/CaseTemplatesTest.php @@ -4,16 +4,12 @@ namespace Cycle\Testing\Tests\Acceptance\Common; -use Cycle\Testing\Database\DatabasePlugin; +use Cycle\Testing\Config; use Cycle\Testing\Database\DatabaseTestCase; use Cycle\Testing\Database\Internal\Current; use Cycle\Testing\ORM\OrmPlugin; -use Cycle\Testing\Regression\CaseGenerator; -use Cycle\Testing\Regression\TemplateSet; +use Cycle\Testing\Regression\Command; use Testo\Application\Application; -use Testo\Application\Config\ApplicationConfig; -use Testo\Application\Config\FinderConfig; -use Testo\Application\Config\SuiteConfig; use Testo\Assert; use Testo\Core\Context\TestResult; use Testo\Core\Value\Status; @@ -68,21 +64,29 @@ private static function remove(string $dir): void \rmdir($dir); } + /** + * The way a user adds a case: `cycle-testing new-case`, then a `testo.php` with a regression suite. + */ private function assertGeneratedCasePasses(string $template): void { $this->dir = \sys_get_temp_dir() . '/cycle-testing-case-' . \bin2hex(\random_bytes(4)); # A fresh namespace per run: the classes of a generated case stay loaded for the rest of the process. - $namespace = 'Cycle\Testing\Tests\Generated\Run' . \bin2hex(\random_bytes(4)) . '\Issue1'; - $files = (new CaseGenerator())->generate(TemplateSet::load($template), "{$this->dir}/Issue1", $namespace); - Assert::notBlank($files); + $namespace = 'Cycle\Testing\Tests\Generated\Run' . \bin2hex(\random_bytes(4)); + $output = \fopen('php://memory', 'w+'); + + $code = (new Command($this->dir, $output, $output)) + ->run(['new-case', '1', "--template={$template}", "--namespace={$namespace}"]); + + \rewind($output); + Assert::string((string) \stream_get_contents($output))->startsWith('Created tests/Regression/Issue1 '); + Assert::same($code, 0); $outer = Current::$pool; try { - $result = Application::createFromConfig(new ApplicationConfig(suites: [new SuiteConfig( - name: 'Generated', - location: new FinderConfig(["{$this->dir}/Issue1"]), - plugins: [new DatabasePlugin($this->driver), new OrmPlugin()], - )]))->run(); + $config = Config::forPackage('cycle/generated', src: [], root: $this->dir) + ->regression('tests/Regression', drivers: [$this->driver], plugins: [new OrmPlugin()]) + ->build(); + $result = Application::createFromConfig($config)->run(); } finally { # The nested suite clears the static the outer suite's assertions read. Current::$pool = $outer;