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

Appearance settings

Commit 33e4665

Browse filesBrowse files
minor #33428 Cleanup tests (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- Cleanup tests | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Commits ------- a461943 Cleanup tests
2 parents 6a31d31 + a461943 commit 33e4665
Copy full SHA for 33e4665

File tree

5 files changed

+29
-39
lines changed
Filter options

5 files changed

+29
-39
lines changed

‎src/Symfony/Component/HttpKernel/Kernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Kernel.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,12 @@ public function getProjectDir()
354354
{
355355
if (null === $this->projectDir) {
356356
$r = new \ReflectionObject($this);
357-
$dir = $rootDir = \dirname($r->getFileName());
357+
358+
if (!file_exists($dir = $r->getFileName())) {
359+
throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name));
360+
}
361+
362+
$dir = $rootDir = \dirname($dir);
358363
while (!file_exists($dir.'/composer.json')) {
359364
if ($dir === \dirname($dir)) {
360365
return $this->projectDir = $rootDir;

‎src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/Fixtures/KernelForTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,9 @@ public function isBooted()
3434
{
3535
return $this->booted;
3636
}
37+
38+
public function getProjectDir()
39+
{
40+
return __DIR__;
41+
}
3742
}

‎src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Symfony\Component\HttpKernel\Config\EnvParametersResource;
2323
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
2424
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
25-
use Symfony\Component\HttpKernel\HttpKernel;
2625
use Symfony\Component\HttpKernel\HttpKernelInterface;
2726
use Symfony\Component\HttpKernel\Kernel;
2827
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;
@@ -119,7 +118,7 @@ public function testBootSetsTheContainerToTheBundles()
119118
public function testBootSetsTheBootedFlagToTrue()
120119
{
121120
// use test kernel to access isBooted()
122-
$kernel = $this->getKernelForTest(['initializeBundles', 'initializeContainer']);
121+
$kernel = $this->getKernel(['initializeBundles', 'initializeContainer']);
123122
$kernel->boot();
124123

125124
$this->assertTrue($kernel->isBooted());
@@ -899,7 +898,7 @@ public function testServicesResetter()
899898
*/
900899
public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel()
901900
{
902-
$kernel = $this->getKernelForTest(['initializeBundles'], true);
901+
$kernel = $this->getKernel(['initializeBundles'], [], true);
903902
$kernel->boot();
904903
$preReBoot = $kernel->getStartTime();
905904

@@ -957,15 +956,15 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
957956
*
958957
* @return Kernel
959958
*/
960-
protected function getKernel(array $methods = [], array $bundles = [])
959+
protected function getKernel(array $methods = [], array $bundles = [], $debug = false)
961960
{
962961
$methods[] = 'registerBundles';
963962

964963
$kernel = $this
965-
->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
964+
->getMockBuilder(KernelForTest::class)
966965
->setMethods($methods)
967-
->setConstructorArgs(['test', false])
968-
->getMockForAbstractClass()
966+
->setConstructorArgs(['test', $debug])
967+
->getMock()
969968
;
970969
$kernel->expects($this->any())
971970
->method('registerBundles')
@@ -980,10 +979,11 @@ protected function getKernel(array $methods = [], array $bundles = [])
980979

981980
protected function getKernelForTest(array $methods = [], $debug = false)
982981
{
983-
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
982+
$kernel = $this->getMockBuilder(KernelForTest::class)
984983
->setConstructorArgs(['test', $debug])
985984
->setMethods($methods)
986-
->getMock();
985+
->getMock()
986+
;
987987
$p = new \ReflectionProperty($kernel, 'rootDir');
988988
$p->setAccessible(true);
989989
$p->setValue($kernel, __DIR__.'/Fixtures');
@@ -1004,6 +1004,11 @@ public function terminate()
10041004
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
10051005
{
10061006
}
1007+
1008+
public function getProjectDir()
1009+
{
1010+
return __DIR__.'/Fixtures';
1011+
}
10071012
}
10081013

10091014
class CustomProjectDirKernel extends Kernel

‎src/Symfony/Component/Lock/Tests/Store/BlockingStoreTestTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Lock/Tests/Store/BlockingStoreTestTrait.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ abstract protected function getStore();
3030
*
3131
* This test is time sensible: the $clockDelay could be adjust.
3232
*
33+
* It also fails when run with the global ./phpunit test suite.
34+
*
35+
* @group transient
36+
*
3337
* @requires extension pcntl
3438
* @requires extension posix
3539
* @requires function pcntl_sigwaitinfo

‎src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Serializer/Tests/Encoder/ChainEncoderTest.php
-29Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -84,42 +84,13 @@ public function testNeedsNormalizationBasic()
8484
$this->assertTrue($this->chainEncoder->needsNormalization(self::FORMAT_2));
8585
}
8686

87-
/**
88-
* @dataProvider booleanProvider
89-
*/
90-
public function testNeedsNormalizationChainNormalizationAware($bool)
91-
{
92-
$chainEncoder = $this
93-
->getMockBuilder('Symfony\Component\Serializer\Tests\Encoder\ChainNormalizationAwareEncoder')
94-
->getMock();
95-
96-
$chainEncoder->method('supportsEncoding')->willReturn(true);
97-
$chainEncoder->method('needsNormalization')->willReturn($bool);
98-
99-
$sut = new ChainEncoder([$chainEncoder]);
100-
101-
$this->assertEquals($bool, $sut->needsNormalization(self::FORMAT_1));
102-
}
103-
10487
public function testNeedsNormalizationNormalizationAware()
10588
{
10689
$encoder = new NormalizationAwareEncoder();
10790
$sut = new ChainEncoder([$encoder]);
10891

10992
$this->assertFalse($sut->needsNormalization(self::FORMAT_1));
11093
}
111-
112-
public function booleanProvider()
113-
{
114-
return [
115-
[true],
116-
[false],
117-
];
118-
}
119-
}
120-
121-
class ChainNormalizationAwareEncoder extends ChainEncoder implements NormalizationAwareInterface
122-
{
12394
}
12495

12596
class NormalizationAwareEncoder implements EncoderInterface, NormalizationAwareInterface

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.