first commit
This commit is contained in:
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Config;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
|
||||
use Symfony\Component\DependencyInjection\Config\AutowireServiceResource;
|
||||
|
||||
/**
|
||||
* @group legacy
|
||||
*/
|
||||
class AutowireServiceResourceTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var AutowireServiceResource
|
||||
*/
|
||||
private $resource;
|
||||
private $file;
|
||||
private $class;
|
||||
private $time;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->file = realpath(sys_get_temp_dir()).'/tmp.php';
|
||||
$this->time = time();
|
||||
touch($this->file, $this->time);
|
||||
|
||||
$this->class = Foo::class;
|
||||
$this->resource = new AutowireServiceResource(
|
||||
$this->class,
|
||||
$this->file,
|
||||
[]
|
||||
);
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
{
|
||||
$this->assertSame('service.autowire.'.$this->class, (string) $this->resource);
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize()
|
||||
{
|
||||
$unserialized = unserialize(serialize($this->resource));
|
||||
|
||||
$this->assertEquals($this->resource, $unserialized);
|
||||
}
|
||||
|
||||
public function testIsFresh()
|
||||
{
|
||||
$this->assertTrue($this->resource->isFresh($this->time), '->isFresh() returns true if the resource has not changed in same second');
|
||||
$this->assertTrue($this->resource->isFresh($this->time + 10), '->isFresh() returns true if the resource has not changed');
|
||||
$this->assertFalse($this->resource->isFresh($this->time - 86400), '->isFresh() returns false if the resource has been updated');
|
||||
}
|
||||
|
||||
public function testIsFreshForDeletedResources()
|
||||
{
|
||||
unlink($this->file);
|
||||
|
||||
$this->assertFalse($this->resource->isFresh($this->getStaleFileTime()), '->isFresh() returns false if the resource does not exist');
|
||||
}
|
||||
|
||||
public function testIsNotFreshChangedResource()
|
||||
{
|
||||
$oldResource = new AutowireServiceResource(
|
||||
$this->class,
|
||||
$this->file,
|
||||
['will_be_different']
|
||||
);
|
||||
|
||||
// test with a stale file *and* a resource that *will* be different than the actual
|
||||
$this->assertFalse($oldResource->isFresh($this->getStaleFileTime()), '->isFresh() returns false if the constructor arguments have changed');
|
||||
}
|
||||
|
||||
public function testIsFreshSameConstructorArgs()
|
||||
{
|
||||
$oldResource = AutowirePass::createResourceForClass(
|
||||
new \ReflectionClass(Foo::class)
|
||||
);
|
||||
|
||||
// test with a stale file *but* the resource will not be changed
|
||||
$this->assertTrue($oldResource->isFresh($this->getStaleFileTime()), '->isFresh() returns false if the constructor arguments have changed');
|
||||
}
|
||||
|
||||
public function testNotFreshIfClassNotFound()
|
||||
{
|
||||
$resource = new AutowireServiceResource(
|
||||
'Some\Non\Existent\Class',
|
||||
$this->file,
|
||||
[]
|
||||
);
|
||||
|
||||
$this->assertFalse($resource->isFresh($this->getStaleFileTime()), '->isFresh() returns false if the class no longer exists');
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (file_exists($this->file)) {
|
||||
@unlink($this->file);
|
||||
}
|
||||
}
|
||||
|
||||
private function getStaleFileTime()
|
||||
{
|
||||
return $this->time - 10;
|
||||
}
|
||||
}
|
||||
|
||||
class Foo
|
||||
{
|
||||
public function __construct($foo)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Config;
|
||||
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\ResourceCheckerInterface;
|
||||
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
|
||||
use Symfony\Component\DependencyInjection\Config\ContainerParametersResourceChecker;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
class ContainerParametersResourceCheckerTest extends TestCase
|
||||
{
|
||||
/** @var ContainerParametersResource */
|
||||
private $resource;
|
||||
|
||||
/** @var ResourceCheckerInterface */
|
||||
private $resourceChecker;
|
||||
|
||||
/** @var ContainerInterface */
|
||||
private $container;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->resource = new ContainerParametersResource(['locales' => ['fr', 'en'], 'default_locale' => 'fr']);
|
||||
$this->container = $this->getMockBuilder(ContainerInterface::class)->getMock();
|
||||
$this->resourceChecker = new ContainerParametersResourceChecker($this->container);
|
||||
}
|
||||
|
||||
public function testSupports()
|
||||
{
|
||||
$this->assertTrue($this->resourceChecker->supports($this->resource));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider isFreshProvider
|
||||
*/
|
||||
public function testIsFresh(callable $mockContainer, $expected)
|
||||
{
|
||||
$mockContainer($this->container);
|
||||
|
||||
$this->assertSame($expected, $this->resourceChecker->isFresh($this->resource, time()));
|
||||
}
|
||||
|
||||
public function isFreshProvider()
|
||||
{
|
||||
yield 'not fresh on missing parameter' => [function (MockObject $container) {
|
||||
$container->method('hasParameter')->with('locales')->willReturn(false);
|
||||
}, false];
|
||||
|
||||
yield 'not fresh on different value' => [function (MockObject $container) {
|
||||
$container->method('getParameter')->with('locales')->willReturn(['nl', 'es']);
|
||||
}, false];
|
||||
|
||||
yield 'fresh on every identical parameters' => [function (MockObject $container) {
|
||||
$container->expects($this->exactly(2))->method('hasParameter')->willReturn(true);
|
||||
$container->expects($this->exactly(2))->method('getParameter')
|
||||
->withConsecutive(
|
||||
[$this->equalTo('locales')],
|
||||
[$this->equalTo('default_locale')]
|
||||
)
|
||||
->willReturnMap([
|
||||
['locales', ['fr', 'en']],
|
||||
['default_locale', 'fr'],
|
||||
])
|
||||
;
|
||||
}, true];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\DependencyInjection\Tests\Config;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
|
||||
|
||||
class ContainerParametersResourceTest extends TestCase
|
||||
{
|
||||
/** @var ContainerParametersResource */
|
||||
private $resource;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->resource = new ContainerParametersResource(['locales' => ['fr', 'en'], 'default_locale' => 'fr']);
|
||||
}
|
||||
|
||||
public function testToString()
|
||||
{
|
||||
$this->assertSame('container_parameters_9893d3133814ab03cac3490f36dece77', (string) $this->resource);
|
||||
}
|
||||
|
||||
public function testSerializeUnserialize()
|
||||
{
|
||||
$unserialized = unserialize(serialize($this->resource));
|
||||
|
||||
$this->assertEquals($this->resource, $unserialized);
|
||||
}
|
||||
|
||||
public function testGetParameters()
|
||||
{
|
||||
$this->assertSame(['locales' => ['fr', 'en'], 'default_locale' => 'fr'], $this->resource->getParameters());
|
||||
}
|
||||
}
|
||||
11
modules/inpostshipping/vendor/symfony/dependency-injection/Tests/Config/index.php
vendored
Normal file
11
modules/inpostshipping/vendor/symfony/dependency-injection/Tests/Config/index.php
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
|
||||
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
|
||||
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
header("Location: ../");
|
||||
exit;
|
||||
Reference in New Issue
Block a user