Open aitboudad opened 10 years ago
Can you tell us the version of Prophecy you are using ?
When using composer to manage your dependencies, the best way is to paste the output of composer show -i phpspec/prophecy
name : phpspec/prophecy
descrip. : Highly opinionated mocking framework for PHP 5.3+
keywords : Double, Dummy, fake, mock, spy, stub
versions : * 1.1.2
type : library
license : MIT
source : [git] https://github.com/phpspec/prophecy.git 976a65af02a2a0e17ce6c949f7b43437205628bb
dist : [zip] https://api.github.com/repos/phpspec/prophecy/zipball/976a65af02a2a0e17ce6c949f7b43437205628bb 976a65af02a2a0e17ce6c949f7b43437205628bb
names : phpspec/prophecy
@stof I get the same error with the dev-master version.
Actually, could you try https://github.com/phpspec/prophecy/issues/54#issuecomment-26619535 ?
After doing some debug, it only work when I comment this line DisableConstructorPatch#L45 (#30) As I think it shouldn't add __construct method if it's final (already ignored in ClassMirror#L111)
What do you propose to solve this issue ?
Could it be resolved by leting the classMirror looking at private final methods too ? Actually it doesn't verify if final because it's not public.
Is there a good solution for this? I too have to stub a SQLFilter
. I am quite new to PHPSpec, but I cannot unit test my listener properly without having my filter. I have to test that it calls SQLFilter::setParameter()
correctly.
This is the code I use:
function it_sets_workspace_parameter_on_workspace_filter_when_there_is_a_workspace(
FilterControllerEvent $event,
$entityManager,
$workspaceContext,
WorkspaceInterface $workspace,
FilterCollection $filterCollection,
WorkspaceFilter $workspaceFilter
) {
$workspaceFilter->beConstructedWith([$entityManager]);
$event->getRequestType()->willReturn(HttpKernelInterface::MASTER_REQUEST);
$workspaceContext->getWorkspace()
->shouldBeCalled()
->willReturn($workspace)
;
$entityManager->getFilters()
->shouldBeCalled()
->willReturn($filterCollection)
;
$filterCollection->getFilter('workspace')
->shouldBeCalled()
->willReturn($workspaceFilter)
;
$workspace->getId()
->shouldBeCalled()
->willReturn(42)
;
$workspaceFilter->setParameter('workspace_id', 42)
->shouldBeCalled()
;
$this->onKernelController($event);
}
No matter what I try, I keep getting:
PHP Fatal error: Cannot override final method Doctrine\ORM\Query\Filter\SQLFilter::__construct() in /Users/steffen/Development/shopblender/vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCreator.php(49) : eval()'d code on line 2