Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite2de9f6

Browse files
committed
ensure compatibility with older PHPUnit mocks
1 parent0c32302 commite2de9f6

File tree

17 files changed

+249
-306
lines changed

17 files changed

+249
-306
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTraitTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
useSymfony\Bundle\FrameworkBundle\Tests\TestCase;
1616
useSymfony\Component\DependencyInjection\Container;
1717
useSymfony\Component\Form\Form;
18+
useSymfony\Component\Form\FormConfigInterface;
1819
useSymfony\Component\HttpFoundation\BinaryFileResponse;
1920
useSymfony\Component\HttpFoundation\File\File;
2021
useSymfony\Component\HttpFoundation\JsonResponse;
@@ -487,8 +488,7 @@ public function testCreateNotFoundException()
487488

488489
publicfunctiontestCreateForm()
489490
{
490-
$config =$this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();
491-
$form =newForm($config);
491+
$form =newForm($this->getMockBuilder(FormConfigInterface::class)->getMock());
492492

493493
$formFactory =$this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
494494
$formFactory->expects($this->once())->method('create')->willReturn($form);

‎src/Symfony/Bundle/WebProfilerBundle/Tests/Profiler/TemplateManagerTest.php‎

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
useSymfony\Bundle\WebProfilerBundle\Profiler\TemplateManager;
1515
useSymfony\Bundle\WebProfilerBundle\Tests\TestCase;
16+
useSymfony\Component\HttpKernel\Profiler\Profile;
1617
useTwig\Environment;
1718

1819
/**
@@ -57,8 +58,7 @@ protected function setUp()
5758
*/
5859
publicfunctiontestGetNameOfInvalidTemplate()
5960
{
60-
$profile =$this->mockProfile();
61-
$this->templateManager->getName($profile,'notexistingpanel');
61+
$this->templateManager->getName(newProfile('token'),'notexistingpanel');
6262
}
6363

6464
/**
@@ -71,12 +71,7 @@ public function testGetNameValidTemplate()
7171
->withAnyParameters()
7272
->will($this->returnCallback([$this,'profilerHasCallback']));
7373

74-
$profile =$this->mockProfile();
75-
$profile->expects($this->any())
76-
->method('hasCollector')
77-
->will($this->returnCallback([$this,'profileHasCollectorCallback']));
78-
79-
$this->assertEquals('FooBundle:Collector:foo.html.twig',$this->templateManager->getName($profile,'foo'));
74+
$this->assertEquals('FooBundle:Collector:foo.html.twig',$this->templateManager->getName(newProfileDummy(),'foo'));
8075
}
8176

8277
/**
@@ -85,17 +80,12 @@ public function testGetNameValidTemplate()
8580
*/
8681
publicfunctiontestGetTemplates()
8782
{
88-
$profile =$this->mockProfile();
89-
$profile->expects($this->any())
90-
->method('hasCollector')
91-
->will($this->returnCallback([$this,'profilerHasCallback']));
92-
9383
$this->profiler->expects($this->any())
9484
->method('has')
9585
->withAnyParameters()
9686
->will($this->returnCallback([$this,'profileHasCollectorCallback']));
9787

98-
$result =$this->templateManager->getTemplates($profile);
88+
$result =$this->templateManager->getTemplates(newProfileDummy());
9989
$this->assertArrayHasKey('foo',$result);
10090
$this->assertArrayNotHasKey('bar',$result);
10191
$this->assertArrayNotHasKey('baz',$result);
@@ -155,3 +145,22 @@ protected function mockProfiler()
155145
return$this->profiler;
156146
}
157147
}
148+
149+
class ProfileDummyextends Profile
150+
{
151+
publicfunction__construct()
152+
{
153+
parent::__construct('token');
154+
}
155+
156+
publicfunctionhasCollector($name)
157+
{
158+
switch ($name) {
159+
case'foo':
160+
case'bar':
161+
returntrue;
162+
default:
163+
returnfalse;
164+
}
165+
}
166+
}

‎src/Symfony/Component/Form/Tests/AbstractFormTest.php‎

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,6 @@ protected function getBuilder($name = 'name', EventDispatcherInterface $dispatch
6565
returnnewFormBuilder($name,$dataClass,$dispatcher ?:$this->dispatcher,$this->factory,$options);
6666
}
6767

68-
/**
69-
* @param string $name
70-
*
71-
* @return \PHPUnit_Framework_MockObject_MockObject
72-
*/
73-
protectedfunctiongetMockForm($name ='name')
74-
{
75-
$form =$this->getMockBuilder('Symfony\Component\Form\Test\FormInterface')->getMock();
76-
$config =$this->getMockBuilder('Symfony\Component\Form\FormConfigInterface')->getMock();
77-
78-
$form->expects($this->any())
79-
->method('getName')
80-
->will($this->returnValue($name));
81-
$form->expects($this->any())
82-
->method('getConfig')
83-
->will($this->returnValue($config));
84-
85-
return$form;
86-
}
87-
8868
/**
8969
* @return \PHPUnit_Framework_MockObject_MockObject
9070
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp