This repository has been archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rodrigue Villetard
committed
Jul 27, 2017
1 parent
ae55309
commit b83b775
Showing
7 changed files
with
143 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the StepArgumentInjectorBehatExtension project. | ||
* | ||
* (c) Rodrigue Villetard <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Gorghoa\StepArgumentInjectorBehatExtension\Argument; | ||
|
||
use Doctrine\Common\Annotations\Reader; | ||
use Gorghoa\StepArgumentInjectorBehatExtension\Annotation\StepInjectorArgument; | ||
use Prophecy\Prophecy\ObjectProphecy; | ||
use Behat\Testwork\Argument\ArgumentOrganiser as BehatArgumentOrganiser; | ||
|
||
/** | ||
* @author Vincent Chalamon <[email protected]> | ||
* @author Rodrigue Villetard <[email protected]> | ||
*/ | ||
class ArgumentOrganiserTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @var ArgumentOrganiser | ||
*/ | ||
private $organiser; | ||
|
||
/** | ||
* @var ObjectProphecy|ArgumentOrganiser | ||
*/ | ||
private $organiserMock; | ||
|
||
/** | ||
* @var ObjectProphecy | ||
*/ | ||
private $initializerMock; | ||
|
||
/** | ||
* @var ObjectProphecy|\ReflectionMethod | ||
*/ | ||
private $functionMock; | ||
|
||
/** | ||
* @var ObjectProphecy|Reader | ||
*/ | ||
private $readerMock; | ||
|
||
/** | ||
* @var StepArgumentHolder | ||
*/ | ||
private $holderMock; | ||
|
||
protected function setUp() | ||
{ | ||
$this->organiserMock = $this->prophesize(BehatArgumentOrganiser::class); | ||
$this->functionMock = $this->prophesize(\ReflectionMethod::class); | ||
$this->readerMock = $this->prophesize(Reader::class); | ||
$this->holderMock = $this->prophesize(StepArgumentHolder::class); | ||
|
||
$this->organiser = new ArgumentOrganiser( | ||
$this->organiserMock->reveal(), | ||
[$this->holderMock->reveal()], | ||
$this->readerMock->reveal() | ||
); | ||
} | ||
|
||
/** | ||
* @return ObjectProphecy | ||
*/ | ||
private function annotationMockFactory() | ||
{ | ||
return $this->prophesize(StepInjectorArgument::class); | ||
} | ||
|
||
public function testOrganiseArguments() | ||
{ | ||
$this->functionMock->getParameters()->willReturn([ | ||
(object) ['name' => 'scenarioBanana'], // argument with injector annotation and **a service hold** value | ||
(object) ['name' => 'gorilla'], // argument with injector annotation but **no service hold** value | ||
(object) ['name' => 'foo'], // argument not handled by this extension | ||
])->shouldBeCalledTimes(1); | ||
|
||
$annot1 = $this->annotationMockFactory(); | ||
$annot1->getArgument()->willReturn('scenarioBanana')->shouldBeCalledTimes(1); | ||
$annot1->reveal(); | ||
|
||
$annot2 = $this->annotationMockFactory(); | ||
$annot2->getArgument()->willReturn('gorilla')->shouldBeCalledTimes(1); | ||
$annot2->reveal(); | ||
|
||
$this->readerMock->getMethodAnnotations($this->functionMock->reveal())->willReturn([ | ||
$annot1, | ||
$annot2, | ||
])->shouldBeCalledTimes(1); | ||
|
||
$this->holderMock->doesHandleStepArgument($annot1)->willReturn(true); | ||
$this->holderMock->doesHandleStepArgument($annot2)->willReturn(false); | ||
|
||
$this->holderMock->getStepArgumentValueFor($annot1)->willReturn('yammyBanana')->shouldBeCalledTimes(1); | ||
$this->holderMock->getStepArgumentValueFor($annot2)->shouldNotBeCalled(); | ||
|
||
$this->holderMock->getStepArgumentValueFor($annot2); | ||
|
||
$this->organiserMock->organiseArguments($this->functionMock->reveal(), [ | ||
0 => 'scenarioBanana', | ||
1 => 'gorilla', | ||
'scenarioBanana' => 'yammyBanana', | ||
2 => 'yammyBanana', | ||
])->shouldBeCalledTimes(1); | ||
|
||
$this->organiser->organiseArguments($this->functionMock->reveal(), ['scenarioBanana', 'gorilla']); | ||
} | ||
} |
114 changes: 0 additions & 114 deletions
114
testsSAI/Argument/ScenarioStateArgumentOrganiserTest.php
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.