Skip to content

Conversation

@Simperfit
Copy link
Contributor

@Simperfit Simperfit commented Jun 27, 2016

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets none
License MIT
Doc PR none

We should not use POST in itemOperation (it is not supported) and each unsupported actionName should not be able to be used since it break NelmioApiDoc.

Thanks to @dunglas for the help.

@Simperfit Simperfit force-pushed the hotfix/add-exception-wrong-actionname branch from 5170551 to 6087d46 Compare June 27, 2016 11:08
@Simperfit Simperfit changed the title hotfix: add exception when there a not builtin action hotfix: add exception when the action is not a builtin action Jun 27, 2016
@Simperfit Simperfit force-pushed the hotfix/add-exception-wrong-actionname branch from 6087d46 to b6e85b3 Compare June 27, 2016 11:36
@Simperfit Simperfit force-pushed the hotfix/add-exception-wrong-actionname branch from b6e85b3 to 6b32716 Compare June 27, 2016 11:40
@dunglas
Copy link
Member

dunglas commented Jun 27, 2016

👍

$containerBuilderProphecy = $this->prophesize(ContainerBuilder::class);

$kernelProphecy->getContainer()->willReturn($containerBuilderProphecy);
$containerBuilderProphecy->has(Argument::any())->willReturn(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use a more specific wildcard here...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Argument::type('string') indeed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can limit it to the specific values we need here.
On 27 Jun 2016 21:50, "Kévin Dunglas" notifications@github.com wrote:

In tests/Bridge/Symfony/Routing/ApiLoaderTest.php
#586 (comment):

@@ -113,6 +115,10 @@ private function getApiLoaderWithResourceMetadata(ResourceMetadata $resourceMeta

     $kernelProphecy = $this->prophesize(KernelInterface::class);
     $kernelProphecy->locateResource(Argument::any())->willReturn($routingConfig);
  •    $containerBuilderProphecy = $this->prophesize(ContainerBuilder::class);
    
  •    $kernelProphecy->getContainer()->willReturn($containerBuilderProphecy);
    
  •    $containerBuilderProphecy->has(Argument::any())->willReturn(true);
    

Argument::type('string') indeed


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/api-platform/core/pull/586/files/6b32716eb4e97b5aadd594a29fb7ee625b0490a8#r68579198,
or mute the thread
https://github.com/notifications/unsubscribe/AAhf647GnFhS_HyQaZz6cQNKgae5Pvahks5qP9VDgaJpZM4I-_Cx
.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @teohhanhui said, we expect specific values here don't we? So we should check against them :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will use both since I want to test that the exception is triggered correctly

@Simperfit Simperfit force-pushed the hotfix/add-exception-wrong-actionname branch from 63790ee to 8b9b7f9 Compare June 28, 2016 10:26
@Simperfit
Copy link
Contributor Author

Simperfit commented Jun 28, 2016

Thanks @teohhanhui @theofidry @dunglas for reviewing this PR :)

];

$containerInterfaceProphecy = $this->prophesize(ContainerInterface::class);
$containerInterfaceProphecy->reveal();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$containerProphecy = $this->prophesize(ContainerInterface::class);
// ...
$kernelProphecy->getContainer()->willReturn($containerProphecy->reveal());

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or:

$containerProphecy = $this->prophesize(ContainerInterface::class);
/** @var ContainerInterface $container */
$container = $containerProphecy->reveal();
// ...
$kernelProphecy->getContainer()->willReturn($container);

if you want to benefit from the typehint and avoid raising a warning on Scrutinizer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theofidry I know @dunglas does not like extra variables... 😛

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not pleased with it either but there is no workaround, to avoid that and benefit from the typehint there is phpSpec for that. But I don't like forcing the users to use phpSpec and you loose your code coverage as well...

Anyway let's blame @dunglas tastes in the meantime 😆

Copy link
Member

@dunglas dunglas Jun 28, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer PHPSpec too, and I use it for my private projects. But I'm tired of "I don't know PHPSpec so I let you write tests." or "I dont't know PHPSpec so I wrote PHPUnit tests." comments ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"I don't know PHPSpec so I let you write tests." or "I don't know PHPSpec so I wrote PHPUnit tests."

The problem isn't here, it's "I won't contribute because I'm not willing to learn a new testing tool just for this project". It's arguable, but that's the reason why we stayed to phpunit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we agree then that there shall be no inline ->reveal()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going for it ;)

@Simperfit Simperfit force-pushed the hotfix/add-exception-wrong-actionname branch from 02e1dcf to 0349711 Compare June 28, 2016 19:35
@Simperfit
Copy link
Contributor Author

comments addressed

@theofidry
Copy link
Contributor

👍

@dunglas dunglas merged commit 4c9d78a into api-platform:master Jun 30, 2016
@dunglas
Copy link
Member

dunglas commented Jun 30, 2016

Thank you @Simperfit

@Simperfit Simperfit deleted the hotfix/add-exception-wrong-actionname branch August 13, 2016 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants