forked from sensiolabs/SensioFrameworkExtraBundle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merged branch henrikbjorn/tests (PR sensiolabs#60)
Commits ------- bfa8505 [ParamConverter] Change test to be complient with parameter-name-bug branch (pass for master and parameter-name-bug) cc2cdf8 [ParamConverter] Basic Test for ParamConverterManager Discussion ---------- Tests Basic test for ParamConverterManager, better to have a single test than none at all
- Loading branch information
Showing
4 changed files
with
110 additions
and
0 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
coverage | |||
phpunit.xml |
72 changes: 72 additions & 0 deletions
72
Tests/Request/ParamConverter/ParamConverterManagerTest.php
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,72 @@ | |||
<?php | |||
|
|||
namespace Sensio\Bundle\FrameworkExtraBundle\Tests\Request\ParamConverter; | |||
|
|||
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterManager; | |||
use Sensio\Bundle\FrameworkExtraBundle\Configuration; | |||
use Symfony\Component\HttpFoundation\Request; | |||
|
|||
class ParamConverterManagerTest extends \PHPUnit_Framework_TestCase | |||
{ | |||
public function setUp() | |||
{ | |||
$this->manager = new ParamConverterManager(); | |||
} | |||
|
|||
public function testPriorities() | |||
{ | |||
$this->assertEquals(array(), $this->manager->all()); | |||
|
|||
$high = $this->createParamConverterMock(); | |||
$low = $this->createParamConverterMock(); | |||
|
|||
$this->manager->add($low); | |||
$this->manager->add($high, 10); | |||
|
|||
$this->assertEquals(array( | |||
$high, | |||
$low, | |||
), $this->manager->all()); | |||
} | |||
|
|||
public function testApply() | |||
{ | |||
$supported = $this->createParamConverterMock(); | |||
$supported | |||
->expects($this->once()) | |||
->method('supports') | |||
->will($this->returnValue(true)) | |||
; | |||
$supported | |||
->expects($this->once()) | |||
->method('apply') | |||
->will($this->returnValue(false)) | |||
; | |||
|
|||
$invalid = $this->createParamConverterMock(); | |||
$invalid | |||
->expects($this->once()) | |||
->method('supports') | |||
->will($this->returnValue(false)) | |||
; | |||
$invalid | |||
->expects($this->never()) | |||
->method('apply') | |||
; | |||
|
|||
$configurations = array( | |||
new Configuration\ParamConverter(array( | |||
'name' => 'var', | |||
)), | |||
); | |||
|
|||
$this->manager->add($supported); | |||
$this->manager->add($invalid); | |||
$this->manager->apply(new Request(), $configurations); | |||
} | |||
|
|||
protected function createParamConverterMock() | |||
{ | |||
return $this->getMock('Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface'); | |||
} | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,12 @@ | |||
<?php | |||
|
|||
require_once $_SERVER['SYMFONY'] . '/Symfony/Component/ClassLoader/UniversalClassLoader.php'; | |||
|
|||
use Symfony\Component\ClassLoader\UniversalClassLoader; | |||
|
|||
$loader = new UniversalClassLoader(); | |||
$loader->registerNamespaces(array( | |||
'Sensio\Bundle\FrameworkExtraBundle' => __DIR__ . '/../../', | |||
'Symfony' => $_SERVER['SYMFONY'], | |||
)); | |||
$loader->register(); |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,24 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
|
|||
<phpunit bootstrap="./Tests/bootstrap.php" colors="true"> | |||
<!-- | |||
<php> | |||
<server name="SYMFONY" value="../../vendor/symfony/src" /> | |||
</php> | |||
--> | |||
<testsuites> | |||
<testsuite name="SensioFrameworkExtraBundle"> | |||
<directory suffix="Test.php">./Tests</directory> | |||
</testsuite> | |||
</testsuites> | |||
|
|||
<filter> | |||
<whitelist> | |||
<directory>./</directory> | |||
<exclude> | |||
<directory>./Resources</directory> | |||
<directory>./Tests</directory> | |||
</exclude> | |||
</whitelist> | |||
</filter> | |||
</phpunit> |