Skip to content

Commit f1afabc

Browse files
dinamicdkarlovi
authored andcommitted
~ changes to fix error message:
Cannot mock Symfony\Component\DependencyInjection\ContainerBuilder::addExpressionLanguageProvider() because a class or interface used in the signature is not loaded
1 parent ab166f6 commit f1afabc

File tree

6 files changed

+61
-8
lines changed

6 files changed

+61
-8
lines changed

Tests/DependencyInjection/Compiler/GrantExtensionsCompilerPassTest.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,15 @@ public function setUp()
3131

3232
public function testProcessWillNotDoAnythingIfTheStorageDoesNotImplementOurInterface()
3333
{
34-
$container = $this->createMock(ContainerBuilder::class);
34+
$container = $this->getMockBuilder(ContainerBuilder::class)
35+
->disableOriginalConstructor()
36+
->setMethods([
37+
'findDefinition',
38+
'getParameterBag',
39+
40+
])
41+
->getMock()
42+
;
3543
$storageDefinition = $this->createMock(Definition::class);
3644
$parameterBag = $this->createMock(ParameterBag::class);
3745

@@ -71,7 +79,15 @@ public function testProcessWillNotDoAnythingIfTheStorageDoesNotImplementOurInter
7179

7280
public function testProcessWillFailIfUriIsEmpty()
7381
{
74-
$container = $this->createMock(ContainerBuilder::class);
82+
$container = $this->getMockBuilder(ContainerBuilder::class)
83+
->disableOriginalConstructor()
84+
->setMethods([
85+
'findDefinition',
86+
'getParameterBag',
87+
'findTaggedServiceIds',
88+
])
89+
->getMock()
90+
;
7591
$storageDefinition = $this->createMock(Definition::class);
7692
$parameterBag = $this->createMock(ParameterBag::class);
7793

@@ -156,7 +172,15 @@ public function testProcessWillFailIfUriIsEmpty()
156172

157173
public function testProcess()
158174
{
159-
$container = $this->createMock(ContainerBuilder::class);
175+
$container = $this->getMockBuilder(ContainerBuilder::class)
176+
->disableOriginalConstructor()
177+
->setMethods([
178+
'findDefinition',
179+
'getParameterBag',
180+
'findTaggedServiceIds',
181+
])
182+
->getMock()
183+
;
160184
$storageDefinition = $this->createMock(Definition::class);
161185
$parameterBag = $this->createMock(ParameterBag::class);
162186

Tests/DependencyInjection/Compiler/RequestStackCompilerPassTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ class RequestStackCompilerPassTest extends \PHPUnit_Framework_TestCase
2626

2727
public function setUp()
2828
{
29-
$this->container = $this->createMock(ContainerBuilder::class);
29+
$this->container = $this->getMockBuilder(ContainerBuilder::class)
30+
->disableOriginalConstructor()
31+
->setMethods([
32+
'has',
33+
'getDefinition',
34+
])
35+
->getMock()
36+
;
3037

3138
$this->instance = new RequestStackCompilerPass();
3239

Tests/DependencyInjection/Compiler/TokenStorageCompilerPassTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ class TokenStorageCompilerPassTest extends \PHPUnit_Framework_TestCase
2626

2727
public function setUp()
2828
{
29-
$this->container = $this->createMock(ContainerBuilder::class);
29+
$this->container = $this->getMockBuilder(ContainerBuilder::class)
30+
->disableOriginalConstructor()
31+
->setMethods([
32+
'getDefinition',
33+
'hasDefinition',
34+
])
35+
->getMock()
36+
;
3037
$this->instance = new TokenStorageCompilerPass();
3138

3239
parent::setUp();

Tests/DependencyInjection/Security/Factory/OAuthFactoryTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ public function testGetKey()
4040

4141
public function testCreate()
4242
{
43-
$container = $this->createMock(ContainerBuilder::class);
43+
$container = $this->getMockBuilder(ContainerBuilder::class)
44+
->disableOriginalConstructor()
45+
->setMethods([
46+
'setDefinition',
47+
48+
])
49+
->getMock()
50+
;
4451
$id = '12';
4552
$config = [];
4653
$userProvider = 'mock.user.provider.service';

Tests/FOSOAuthServerBundleTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public function testBuildForSymfonyHigherThan20()
4646
/** @var ContainerBuilder|\PHPUnit_Framework_MockObject_MockObject $containerBuilder */
4747
$containerBuilder = $this->getMockBuilder(ContainerBuilder::class)
4848
->disableOriginalConstructor()
49+
->setMethods([
50+
'getExtension',
51+
'addCompilerPass',
52+
])
4953
->getMock()
5054
;
5155

@@ -99,6 +103,9 @@ public function testBuildForSymfony20()
99103
/** @var ContainerBuilder|\PHPUnit_Framework_MockObject_MockObject $containerBuilder */
100104
$containerBuilder = $this->getMockBuilder(ContainerBuilder::class)
101105
->disableOriginalConstructor()
106+
->setMethods([
107+
'addCompilerPass',
108+
])
102109
->getMock()
103110
;
104111

Tests/Form/Handler/AuthorizeFormHandlerTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,16 @@ public function testProcessWillHandleRequestOnPostAndWillProcessDataIfFormIsVali
429429
'scope' => $query->scope,
430430
];
431431

432-
// $this->assertSame($expectedSuperGlobalValue, $_GET);
433432
$this->assertTrue($this->instance->process());
433+
434+
$this->assertSame($expectedSuperGlobalValue, $_GET);
434435
}
435436

436437
/**
437438
* @param string $methodName
438439
* @return \ReflectionMethod
439440
*/
440-
protected function getReflectionMethod(string $methodName)
441+
protected function getReflectionMethod($methodName)
441442
{
442443
$reflectionObject = new \ReflectionObject($this->instance);
443444
$reflectionMethod = $reflectionObject->getMethod($methodName);

0 commit comments

Comments
 (0)