Cleanup tests
This commit is contained in:
parent
71a8ecbfd6
commit
a461943345
@ -354,7 +354,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
|||||||
{
|
{
|
||||||
if (null === $this->projectDir) {
|
if (null === $this->projectDir) {
|
||||||
$r = new \ReflectionObject($this);
|
$r = new \ReflectionObject($this);
|
||||||
$dir = $rootDir = \dirname($r->getFileName());
|
|
||||||
|
if (!file_exists($dir = $r->getFileName())) {
|
||||||
|
throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name));
|
||||||
|
}
|
||||||
|
|
||||||
|
$dir = $rootDir = \dirname($dir);
|
||||||
while (!file_exists($dir.'/composer.json')) {
|
while (!file_exists($dir.'/composer.json')) {
|
||||||
if ($dir === \dirname($dir)) {
|
if ($dir === \dirname($dir)) {
|
||||||
return $this->projectDir = $rootDir;
|
return $this->projectDir = $rootDir;
|
||||||
|
@ -34,4 +34,9 @@ class KernelForTest extends Kernel
|
|||||||
{
|
{
|
||||||
return $this->booted;
|
return $this->booted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getProjectDir()
|
||||||
|
{
|
||||||
|
return __DIR__;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
|||||||
use Symfony\Component\HttpKernel\Config\EnvParametersResource;
|
use Symfony\Component\HttpKernel\Config\EnvParametersResource;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
|
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
|
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
|
||||||
use Symfony\Component\HttpKernel\HttpKernel;
|
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;
|
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;
|
||||||
@ -119,7 +118,7 @@ class KernelTest extends TestCase
|
|||||||
public function testBootSetsTheBootedFlagToTrue()
|
public function testBootSetsTheBootedFlagToTrue()
|
||||||
{
|
{
|
||||||
// use test kernel to access isBooted()
|
// use test kernel to access isBooted()
|
||||||
$kernel = $this->getKernelForTest(['initializeBundles', 'initializeContainer']);
|
$kernel = $this->getKernel(['initializeBundles', 'initializeContainer']);
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
|
|
||||||
$this->assertTrue($kernel->isBooted());
|
$this->assertTrue($kernel->isBooted());
|
||||||
@ -899,7 +898,7 @@ EOF;
|
|||||||
*/
|
*/
|
||||||
public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel()
|
public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel()
|
||||||
{
|
{
|
||||||
$kernel = $this->getKernelForTest(['initializeBundles'], true);
|
$kernel = $this->getKernel(['initializeBundles'], [], true);
|
||||||
$kernel->boot();
|
$kernel->boot();
|
||||||
$preReBoot = $kernel->getStartTime();
|
$preReBoot = $kernel->getStartTime();
|
||||||
|
|
||||||
@ -957,15 +956,15 @@ EOF;
|
|||||||
*
|
*
|
||||||
* @return Kernel
|
* @return Kernel
|
||||||
*/
|
*/
|
||||||
protected function getKernel(array $methods = [], array $bundles = [])
|
protected function getKernel(array $methods = [], array $bundles = [], $debug = false)
|
||||||
{
|
{
|
||||||
$methods[] = 'registerBundles';
|
$methods[] = 'registerBundles';
|
||||||
|
|
||||||
$kernel = $this
|
$kernel = $this
|
||||||
->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
|
->getMockBuilder(KernelForTest::class)
|
||||||
->setMethods($methods)
|
->setMethods($methods)
|
||||||
->setConstructorArgs(['test', false])
|
->setConstructorArgs(['test', $debug])
|
||||||
->getMockForAbstractClass()
|
->getMock()
|
||||||
;
|
;
|
||||||
$kernel->expects($this->any())
|
$kernel->expects($this->any())
|
||||||
->method('registerBundles')
|
->method('registerBundles')
|
||||||
@ -980,10 +979,11 @@ EOF;
|
|||||||
|
|
||||||
protected function getKernelForTest(array $methods = [], $debug = false)
|
protected function getKernelForTest(array $methods = [], $debug = false)
|
||||||
{
|
{
|
||||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
|
$kernel = $this->getMockBuilder(KernelForTest::class)
|
||||||
->setConstructorArgs(['test', $debug])
|
->setConstructorArgs(['test', $debug])
|
||||||
->setMethods($methods)
|
->setMethods($methods)
|
||||||
->getMock();
|
->getMock()
|
||||||
|
;
|
||||||
$p = new \ReflectionProperty($kernel, 'rootDir');
|
$p = new \ReflectionProperty($kernel, 'rootDir');
|
||||||
$p->setAccessible(true);
|
$p->setAccessible(true);
|
||||||
$p->setValue($kernel, __DIR__.'/Fixtures');
|
$p->setValue($kernel, __DIR__.'/Fixtures');
|
||||||
@ -1004,6 +1004,11 @@ class TestKernel implements HttpKernelInterface
|
|||||||
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
|
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getProjectDir()
|
||||||
|
{
|
||||||
|
return __DIR__.'/Fixtures';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomProjectDirKernel extends Kernel
|
class CustomProjectDirKernel extends Kernel
|
||||||
|
@ -30,6 +30,10 @@ trait BlockingStoreTestTrait
|
|||||||
*
|
*
|
||||||
* This test is time sensible: the $clockDelay could be adjust.
|
* This test is time sensible: the $clockDelay could be adjust.
|
||||||
*
|
*
|
||||||
|
* It also fails when run with the global ./phpunit test suite.
|
||||||
|
*
|
||||||
|
* @group transient
|
||||||
|
*
|
||||||
* @requires extension pcntl
|
* @requires extension pcntl
|
||||||
* @requires extension posix
|
* @requires extension posix
|
||||||
* @requires function pcntl_sigwaitinfo
|
* @requires function pcntl_sigwaitinfo
|
||||||
|
@ -84,23 +84,6 @@ class ChainEncoderTest extends TestCase
|
|||||||
$this->assertTrue($this->chainEncoder->needsNormalization(self::FORMAT_2));
|
$this->assertTrue($this->chainEncoder->needsNormalization(self::FORMAT_2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider booleanProvider
|
|
||||||
*/
|
|
||||||
public function testNeedsNormalizationChainNormalizationAware($bool)
|
|
||||||
{
|
|
||||||
$chainEncoder = $this
|
|
||||||
->getMockBuilder('Symfony\Component\Serializer\Tests\Encoder\ChainNormalizationAwareEncoder')
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$chainEncoder->method('supportsEncoding')->willReturn(true);
|
|
||||||
$chainEncoder->method('needsNormalization')->willReturn($bool);
|
|
||||||
|
|
||||||
$sut = new ChainEncoder([$chainEncoder]);
|
|
||||||
|
|
||||||
$this->assertEquals($bool, $sut->needsNormalization(self::FORMAT_1));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNeedsNormalizationNormalizationAware()
|
public function testNeedsNormalizationNormalizationAware()
|
||||||
{
|
{
|
||||||
$encoder = new NormalizationAwareEncoder();
|
$encoder = new NormalizationAwareEncoder();
|
||||||
@ -108,18 +91,6 @@ class ChainEncoderTest extends TestCase
|
|||||||
|
|
||||||
$this->assertFalse($sut->needsNormalization(self::FORMAT_1));
|
$this->assertFalse($sut->needsNormalization(self::FORMAT_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function booleanProvider()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
[true],
|
|
||||||
[false],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChainNormalizationAwareEncoder extends ChainEncoder implements NormalizationAwareInterface
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class NormalizationAwareEncoder implements EncoderInterface, NormalizationAwareInterface
|
class NormalizationAwareEncoder implements EncoderInterface, NormalizationAwareInterface
|
||||||
|
Reference in New Issue
Block a user