diff --git a/phpunit.xml b/phpunit.xml index 0f46c2d..363e4da 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,21 +1,28 @@ - - - - src - - - - - tests/src - - - - - - + + + + tests/src + + + + + + + + + src + + diff --git a/src/Commands/InfoCommand.php b/src/Commands/InfoCommand.php index 0687747..61efe46 100644 --- a/src/Commands/InfoCommand.php +++ b/src/Commands/InfoCommand.php @@ -72,7 +72,10 @@ public function perform( foreach ($workflows as $workflow) { $table->addRow([ \sprintf('%s', $workflow['name']), - $workflow['class'] . "\n" . \sprintf('%s', \str_replace($rootDir, '', $workflow['file'])), + $workflow['class'] . "\n" . \sprintf( + '%s', + self::normalizePath($rootDir, $workflow['file']), + ), $workflow['task_queue'], ]); } @@ -100,4 +103,18 @@ public function perform( return self::SUCCESS; } + + /** + * @param non-empty-string $rootDir + * @param non-empty-string $file + */ + private static function normalizePath(string $rootDir, string $file): string + { + $file = \str_replace('\\', '/', $file); + $rootDir = \str_replace('\\', '/', $rootDir); + + return \str_starts_with($file, $rootDir) + ? \substr($file, \strlen($rootDir)) + : $file; + } } diff --git a/tests/src/Commands/InfoCommandTest.php b/tests/src/Commands/InfoCommandTest.php index dd13b63..9d31edb 100644 --- a/tests/src/Commands/InfoCommandTest.php +++ b/tests/src/Commands/InfoCommandTest.php @@ -31,7 +31,7 @@ public function testInfo(): void { $result = $this->runCommand('temporal:info'); - $this->assertSame( + $this->assertStringEqualsStringIgnoringLineEndings( <<<'OUTPUT' Workflows @@ -57,7 +57,7 @@ public function testInfoWithActivities(): void '--show-activities' => true, ]); - $this->assertSame( + $this->assertStringEqualsStringIgnoringLineEndings( <<<'OUTPUT' Workflows diff --git a/tests/src/DeclarationLocatorTest.php b/tests/src/DeclarationLocatorTest.php index e05b63c..e22d860 100644 --- a/tests/src/DeclarationLocatorTest.php +++ b/tests/src/DeclarationLocatorTest.php @@ -20,19 +20,14 @@ protected function setUp(): void { parent::setUp(); - $this->locator = new DeclarationLocator( - $this->classes = m::mock(ClassesInterface::class), - new AttributeReader() - ); + $this->locator = new DeclarationLocator(new AttributeReader()); } public function testEnumClassesShouldBeSkipped(): void { - $this->classes->shouldReceive('getClasses')->once()->andReturn([ - new \ReflectionClass(TestEnum::class), - new \ReflectionClass(TestAbstractClass::class), - new \ReflectionClass(TestInterface::class), - ]); + $this->locator->listen(new \ReflectionClass(TestEnum::class)); + $this->locator->listen(new \ReflectionClass(TestAbstractClass::class)); + $this->locator->listen(new \ReflectionClass(TestInterface::class)); $result = []; @@ -45,15 +40,13 @@ public function testEnumClassesShouldBeSkipped(): void public function testWorkflowsShouldBeRegistered(): void { - $this->classes->shouldReceive('getClasses')->once()->andReturn([ - new \ReflectionClass(TestEnum::class), - new \ReflectionClass(TestAbstractClass::class), - new \ReflectionClass(TestInterface::class), - $workflow1 = new \ReflectionClass(TestWorkflowClass::class), - $workflow2 = new \ReflectionClass(TestWorkflowClassWithInterface::class), - $activity1 = new \ReflectionClass(TestActivityClass::class), - $activity2 = new \ReflectionClass(TestActivityClassWithInterface::class), - ]); + $this->locator->listen(new \ReflectionClass(TestEnum::class)); + $this->locator->listen(new \ReflectionClass(TestAbstractClass::class)); + $this->locator->listen(new \ReflectionClass(TestInterface::class)); + $this->locator->listen($workflow1 = new \ReflectionClass(TestWorkflowClass::class)); + $this->locator->listen($workflow2 = new \ReflectionClass(TestWorkflowClassWithInterface::class)); + $this->locator->listen($activity1 = new \ReflectionClass(TestActivityClass::class)); + $this->locator->listen($activity2 = new \ReflectionClass(TestActivityClassWithInterface::class)); $result = [];