Skip to content

Commit

Permalink
Use full namespace to write serialized message in filesystem to avoid…
Browse files Browse the repository at this point in the history
… naming conflict
  • Loading branch information
Inkod committed Oct 20, 2023
1 parent 8b9eb2d commit f045ae5
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Filesystem/ZddMessageFilesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ public function exists(string $messageFqcn): bool
private function getDirectoryAndShortname(string $classFqcn): array
{
$path = explode('\\', $classFqcn);
$directory = $path[\count($path) - 2];
$shortName = end($path);
array_pop($path);
$directory = implode('/', $path);

return [$directory, $shortName];
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixtures/App/Messages/Config/MessageConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessageWithPrivateConstructor;
use Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\Input\Locale;
use Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\Input\Status;
use Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\Other;

class MessageConfig implements ZddMessageConfigInterface
{
Expand All @@ -21,6 +22,7 @@ public function getMessageToAssert(): array
DummyMessageWithNullableNumberProperty::class,
DummyMessageWithPrivateConstructor::class,
DummyMessageWithAllManagedTypes::class,
Other\DummyMessage::class,
];
}

Expand Down
11 changes: 11 additions & 0 deletions tests/Fixtures/App/Messages/Other/DummyMessage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\Other;

final class DummyMessage
{
public function __construct(
public readonly array $contents
) {
}
}
3 changes: 2 additions & 1 deletion tests/Func/GenerateZddMessageCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function setUp(): void
$kernel = self::bootKernel();
$this->command = new CommandTester((new Application($kernel))->find('yousign:zdd-message:generate'));
$customBasePathFile = $kernel->getContainer()->getParameter('custom_path_file');
$this->serializedMessagesDir = $customBasePathFile.'/Messages';
$this->serializedMessagesDir = $customBasePathFile.'/Yousign/ZddMessageBundle/Tests/Fixtures/App/Messages';
}

protected function tearDown(): void
Expand Down Expand Up @@ -49,6 +49,7 @@ public function testThatCommandIsSuccessful(): void
2 Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessageWithNullableNumberProperty
3 Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessageWithPrivateConstructor
4 Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessageWithAllManagedTypes
5 Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\Other\DummyMessage
--- ---------------------------------------------------------------------------------------------
EOF;

Expand Down
1 change: 1 addition & 0 deletions tests/Func/ListZddMessageCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function testCommandIsSuccess(): void
2 Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessageWithNullableNumberProperty
3 Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessageWithPrivateConstructor
4 Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\DummyMessageWithAllManagedTypes
5 Yousign\ZddMessageBundle\Tests\Fixtures\App\Messages\Other\DummyMessage
--- ---------------------------------------------------------------------------------------------
EOF;

Expand Down
2 changes: 1 addition & 1 deletion tests/Func/ValidateZddMessageCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected function setUp(): void
$kernel = self::bootKernel();
$this->command = new CommandTester((new Application(self::$kernel))->find('yousign:zdd-message:validate'));
$customBasePathFile = $kernel->getContainer()->getParameter('custom_path_file');
$this->serializedMessagesDir = $customBasePathFile.'/Messages';
$this->serializedMessagesDir = $customBasePathFile.'/Yousign/ZddMessageBundle/Tests/Fixtures/App/Messages';

MessageConfig::$messagesToAssert = [
DummyMessage::class,
Expand Down

0 comments on commit f045ae5

Please sign in to comment.