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 ContainerBuilder mock generation in tests #914

Merged
merged 1 commit into from
Dec 1, 2014
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class ConfigurationCheckPassTest extends \PHPUnit_Framework_TestCase
*/
public function testShouldThrowRuntimeExceptionWhenFOSRestBundleAnnotations()
{
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
->setMethods(array('has'))
->getMock();
$container->expects($this->at(0))
->method('has')
->with($this->equalTo('sensio_framework_extra.view.listener'))
Expand All @@ -46,7 +48,9 @@ public function testShouldThrowRuntimeExceptionWhenBodyConverterIsEnabledButPara
'RuntimeException',
'You need to enable the parameter converter listeners in SensioFrameworkExtraBundle when using the FOSRestBundle RequestBodyParamConverter'
);
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
->setMethods(array('has'))
->getMock();
$container->expects($this->at(1))
->method('has')
->with($this->equalTo('fos_rest.converter.request_body'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public function testRulesAreAddedWhenFormatListenerAndProfilerToolbarAreEnabled(
{
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition', array('addMethod'));

$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
->setMethods(array('hasDefinition', 'getDefinition', 'hasParameter', 'getParameter'))
->getMock();

$container->expects($this->exactly(3))
->method('hasDefinition')
Expand Down Expand Up @@ -62,7 +64,9 @@ public function testNoRulesAreAddedWhenProfilerToolbarAreDisabled()
{
$definition = $this->getMock('Symfony\Component\DependencyInjection\Definition', array('addMethod'));

$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerBuilder');
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
->setMethods(array('hasDefinition', 'getDefinition', 'hasParameter', 'getParameter'))
->getMock();

$container->expects($this->exactly(2))
->method('hasDefinition')
Expand Down
4 changes: 3 additions & 1 deletion Tests/FOSRestBundleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class FOSRestBundleTest extends \PHPUnit_Framework_TestCase
{
public function testBuild()
{
$container = $this->getMock('\Symfony\Component\DependencyInjection\ContainerBuilder');
$container = $this->getMockBuilder('\Symfony\Component\DependencyInjection\ContainerBuilder')
->setMethods(array('addCompilerPass'))
->getMock();
$container->expects($this->exactly(3))
->method('addCompilerPass')
->with($this->isInstanceOf('\Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface'));
Expand Down
1 change: 1 addition & 0 deletions Tests/Routing/Loader/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected function getControllerLoader(array $formats = array())
if ($this->containerMock === null) {
$this->containerMock = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
->disableOriginalConstructor()
->setMethods(array('get', 'has'))
->getMock();
}
$l = $this->getMockBuilder('Symfony\Component\Config\FileLocator')
Expand Down
1 change: 1 addition & 0 deletions Tests/Routing/Loader/RestYamlCollectionLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public function testControllerAsServiceWithClassName()
// We register the controller in the fake container by its class name
$this->containerMock = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder')
->disableOriginalConstructor()
->setMethods(array('has', 'get', 'enterScope', 'leaveScope'))
->getMock();
$this->containerMock->expects($this->any())
->method('has')
Expand Down
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="./Tests/bootstrap.php" colors="true">
<php>
<!-- Disable E_USER_DEPRECATED until 3.0 -->
<!-- php -r 'echo -1 & ~E_USER_DEPRECATED;' -->
<ini name="error_reporting" value="-16385"/>
</php>

<testsuites>
<testsuite name="FOSRestBundle test suite">
Expand Down