Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix after upmerge #717

Merged
merged 2 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,31 +79,53 @@ jobs:
(cd src/Component && composer validate --strict)

-
name: Run component tests
run: (cd src/Component && vendor/bin/phpspec run)
name: Run Phpspec tests
if: ${{ true != contains( matrix.php, '8.2' ) }}
run: |
vendor/bin/phpspec run --ansi --no-interaction
(cd src/Component && vendor/bin/phpspec run --no-interaction)

-
name: Run bundle tests
run: composer test
name: Run PHPUnit tests
run: vendor/bin/phpunit --colors=always

-
name: Run lint container
run: (cd tests/Application && bin/console lint:container)

-
name: Run state machine tests with winzou/state-machine package
name: Run state machine Phpspec tests with winzou/state-machine package
if: ${{ true != contains( matrix.php, '8.2' ) }}
run: |
sed -i -e 's/state_machine_component: symfony/state_machine_component: winzou/g' tests/Application/config/packages/test/sylius_resource.yaml
(cd tests/Application && bin/console cache:clear --env=test)
vendor/bin/phpspec run --ansi --no-interaction
sed -i -e 's/state_machine_component: winzou/state_machine_component: symfony/g' tests/Application/config/packages/test/sylius_resource.yaml


-
name: Run state machine PHPUnit tests with winzou/state-machine package
run: |
sed -i -e 's/state_machine_component: symfony/state_machine_component: winzou/g' tests/Application/config/packages/test/sylius_resource.yaml
(cd tests/Application && bin/console cache:clear --env=test)
composer test
vendor/bin/phpunit --colors=always
sed -i -e 's/state_machine_component: winzou/state_machine_component: symfony/g' tests/Application/config/packages/test/sylius_resource.yaml

-
name: Run state machine tests with symfony/workflow package
name: Run state machine Phpspec tests with symfony/workflow package
if: ${{ true != contains( matrix.php, '8.2' ) }}
run: |
sed -i -e 's/state_machine_component: winzou/state_machine_component: symfony/g' tests/Application/config/packages/test/sylius_resource.yaml
(cd tests/Application && bin/console cache:clear --env=test)
vendor/bin/phpspec run --ansi --no-interaction
sed -i -e 's/state_machine_component: symfony/state_machine_component: winzou/g' tests/Application/config/packages/test/sylius_resource.yaml

-
name: Run state machine PHPUnit tests with symfony/workflow package
run: |
sed -i -e 's/state_machine_component: winzou/state_machine_component: symfony/g' tests/Application/config/packages/test/sylius_resource.yaml
(cd tests/Application && bin/console cache:clear --env=test)
composer test
vendor/bin/phpunit --colors=always
sed -i -e 's/state_machine_component: symfony/state_machine_component: winzou/g' tests/Application/config/packages/test/sylius_resource.yaml

-
Expand Down
112 changes: 86 additions & 26 deletions src/Bundle/Tests/Command/DebugResourceCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,92 @@ class null
);
}

/**
* @test
*/
public function it_displays_the_metadata_for_given_resource_as_fully_qualified_class_name(): void
{
$this->registry->getByClass('App\Resource')->willReturn($this->createMetadata('one'));

$resourceMetadata = (new Resource(alias: 'sylius.one'))->withOperations(new Operations([
'app_one_index' => new Index(name: 'app_one_index', provider: 'App\GetOneItemProvider'),
'app_one_create' => new Create(name: 'app_one_create', processor: 'App\CreateOneProcessor'),
]));

$resourceMetadataCollection = new ResourceMetadataCollection([$resourceMetadata]);

$this->resourceCollectionMetadataFactory->create('App\One')->willReturn($resourceMetadataCollection);

$this->tester->execute([
'resource' => 'App\Resource',
]);

$display = $this->tester->getDisplay();

$this->assertEquals(
<<<TXT

Configuration
-------------

----------------------- -----------------------------
Option Value
----------------------- -----------------------------
name "one"
applicationName "sylius"
driver "doctrine/foobar"
stateMachineComponent null
templatesNamespace null
classes [
"model" => "App\One",
"foo" => "bar",
"bar" => "foo"
]
whatever [
"something" => [
"elephants" => "camels"
]
]
----------------------- -----------------------------

New Resource Metadata
---------------------

------------------------ --------------
Option Value
------------------------ --------------
alias "sylius.one"
section null
formType null
templatesDir null
routePrefix null
name null
pluralName null
applicationName null
identifier null
normalizationContext null
denormalizationContext null
validationContext null
class null
------------------------ --------------

New operations
--------------

---------------- ---------------------------------------------------------------
Name Details
---------------- ---------------------------------------------------------------
app_one_index bin/console sylius:debug:resource App\Resource app_one_index
app_one_create bin/console sylius:debug:resource App\Resource app_one_create
---------------- ---------------------------------------------------------------


TXT
,
$display,
);
}

/**
* @test
*/
Expand Down Expand Up @@ -257,32 +343,6 @@ public function it_displays_the_metadata_for_given_resource_operation(): void
);
}

/**
* @test
*/
public function it_displays_the_metadata_for_given_resource_as_fully_qualified_class_name(): void
{
$this->registry->getByClass('App\Resource')->willReturn($this->createMetadata('one'));
$this->tester->execute([
'resource' => 'App\Resource',
]);

$display = $this->tester->getDisplay();

$this->assertEquals(<<<'EOT'
+------------------------------+-----------------+
| name | one |
| application | sylius |
| driver | doctrine/foobar |
| classes.foo | bar |
| classes.bar | foo |
| whatever.something.elephants | camels |
+------------------------------+-----------------+

EOT
, $display);
}

private function createMetadata(string $suffix): MetadataInterface
{
return Metadata::fromAliasAndConfiguration(sprintf('sylius.%s', $suffix), [
Expand Down