Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -0,0 +1,71 @@
<?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\Config\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolver;
class DelegatingLoaderTest extends TestCase
{
public function testConstructor()
{
$loader = new DelegatingLoader($resolver = new LoaderResolver());
$this->assertTrue(true, '__construct() takes a loader resolver as its first argument');
}
public function testGetSetResolver()
{
$resolver = new LoaderResolver();
$loader = new DelegatingLoader($resolver);
$this->assertSame($resolver, $loader->getResolver(), '->getResolver() gets the resolver loader');
$loader->setResolver($resolver = new LoaderResolver());
$this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader');
}
public function testSupports()
{
$loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader1->expects($this->once())->method('supports')->will($this->returnValue(true));
$loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
$this->assertTrue($loader->supports('foo.xml'), '->supports() returns true if the resource is loadable');
$loader1 = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader1->expects($this->once())->method('supports')->will($this->returnValue(false));
$loader = new DelegatingLoader(new LoaderResolver(array($loader1)));
$this->assertFalse($loader->supports('foo.foo'), '->supports() returns false if the resource is not loadable');
}
public function testLoad()
{
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
$loader->expects($this->once())->method('load');
$resolver = new LoaderResolver(array($loader));
$loader = new DelegatingLoader($resolver);
$loader->load('foo');
}
/**
* @expectedException \Symfony\Component\Config\Exception\FileLoaderLoadException
*/
public function testLoadThrowsAnExceptionIfTheResourceCannotBeLoaded()
{
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(false));
$resolver = new LoaderResolver(array($loader));
$loader = new DelegatingLoader($resolver);
$loader->load('foo');
}
}

View file

@ -0,0 +1,128 @@
<?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\Config\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\FileLoader;
use Symfony\Component\Config\Loader\LoaderResolver;
class FileLoaderTest extends TestCase
{
public function testImportWithFileLocatorDelegation()
{
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locatorMockForAdditionalLoader = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$locatorMockForAdditionalLoader->expects($this->any())->method('locate')->will($this->onConsecutiveCalls(
array('path/to/file1'), // Default
array('path/to/file1', 'path/to/file2'), // First is imported
array('path/to/file1', 'path/to/file2'), // Second is imported
array('path/to/file1'), // Exception
array('path/to/file1', 'path/to/file2') // Exception
));
$fileLoader = new TestFileLoader($locatorMock);
$fileLoader->setSupports(false);
$fileLoader->setCurrentDir('.');
$additionalLoader = new TestFileLoader($locatorMockForAdditionalLoader);
$additionalLoader->setCurrentDir('.');
$fileLoader->setResolver($loaderResolver = new LoaderResolver(array($fileLoader, $additionalLoader)));
// Default case
$this->assertSame('path/to/file1', $fileLoader->import('my_resource'));
// Check first file is imported if not already loading
$this->assertSame('path/to/file1', $fileLoader->import('my_resource'));
// Check second file is imported if first is already loading
$fileLoader->addLoading('path/to/file1');
$this->assertSame('path/to/file2', $fileLoader->import('my_resource'));
// Check exception throws if first (and only available) file is already loading
try {
$fileLoader->import('my_resource');
$this->fail('->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading');
} catch (\Exception $e) {
$this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException', $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading');
}
// Check exception throws if all files are already loading
try {
$fileLoader->addLoading('path/to/file2');
$fileLoader->import('my_resource');
$this->fail('->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading');
} catch (\Exception $e) {
$this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException', $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading');
}
}
public function testImportWithGlobLikeResource()
{
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$loader = new TestFileLoader($locatorMock);
$this->assertSame('[foo]', $loader->import('[foo]'));
}
public function testImportWithNoGlobMatch()
{
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
$loader = new TestFileLoader($locatorMock);
$this->assertNull($loader->import('./*.abc'));
}
public function testImportWithSimpleGlob()
{
$loader = new TestFileLoader(new FileLocator(__DIR__));
$this->assertSame(__FILE__, strtr($loader->import('FileLoaderTest.*'), '/', \DIRECTORY_SEPARATOR));
}
}
class TestFileLoader extends FileLoader
{
private $supports = true;
public function load($resource, $type = null)
{
return $resource;
}
public function supports($resource, $type = null)
{
return $this->supports;
}
public function addLoading($resource)
{
self::$loading[$resource] = true;
}
public function removeLoading($resource)
{
unset(self::$loading[$resource]);
}
public function clearLoading()
{
self::$loading = array();
}
public function setSupports($supports)
{
$this->supports = $supports;
}
}

View file

@ -0,0 +1,47 @@
<?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\Config\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Loader\LoaderResolver;
class LoaderResolverTest extends TestCase
{
public function testConstructor()
{
$resolver = new LoaderResolver(array(
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock(),
));
$this->assertEquals(array($loader), $resolver->getLoaders(), '__construct() takes an array of loaders as its first argument');
}
public function testResolve()
{
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$resolver = new LoaderResolver(array($loader));
$this->assertFalse($resolver->resolve('foo.foo'), '->resolve() returns false if no loader is able to load the resource');
$loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
$resolver = new LoaderResolver(array($loader));
$this->assertEquals($loader, $resolver->resolve(function () {}), '->resolve() returns the loader for the given resource');
}
public function testLoaders()
{
$resolver = new LoaderResolver();
$resolver->addLoader($loader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock());
$this->assertEquals(array($loader), $resolver->getLoaders(), 'addLoader() adds a loader');
}
}

View file

@ -0,0 +1,118 @@
<?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\Config\Tests\Loader;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Loader\Loader;
class LoaderTest extends TestCase
{
public function testGetSetResolver()
{
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$loader = new ProjectLoader1();
$loader->setResolver($resolver);
$this->assertSame($resolver, $loader->getResolver(), '->setResolver() sets the resolver loader');
}
public function testResolve()
{
$resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once())
->method('resolve')
->with('foo.xml')
->will($this->returnValue($resolvedLoader));
$loader = new ProjectLoader1();
$loader->setResolver($resolver);
$this->assertSame($loader, $loader->resolve('foo.foo'), '->resolve() finds a loader');
$this->assertSame($resolvedLoader, $loader->resolve('foo.xml'), '->resolve() finds a loader');
}
/**
* @expectedException \Symfony\Component\Config\Exception\FileLoaderLoadException
*/
public function testResolveWhenResolverCannotFindLoader()
{
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once())
->method('resolve')
->with('FOOBAR')
->will($this->returnValue(false));
$loader = new ProjectLoader1();
$loader->setResolver($resolver);
$loader->resolve('FOOBAR');
}
public function testImport()
{
$resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$resolvedLoader->expects($this->once())
->method('load')
->with('foo')
->will($this->returnValue('yes'));
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once())
->method('resolve')
->with('foo')
->will($this->returnValue($resolvedLoader));
$loader = new ProjectLoader1();
$loader->setResolver($resolver);
$this->assertEquals('yes', $loader->import('foo'));
}
public function testImportWithType()
{
$resolvedLoader = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderInterface')->getMock();
$resolvedLoader->expects($this->once())
->method('load')
->with('foo', 'bar')
->will($this->returnValue('yes'));
$resolver = $this->getMockBuilder('Symfony\Component\Config\Loader\LoaderResolverInterface')->getMock();
$resolver->expects($this->once())
->method('resolve')
->with('foo', 'bar')
->will($this->returnValue($resolvedLoader));
$loader = new ProjectLoader1();
$loader->setResolver($resolver);
$this->assertEquals('yes', $loader->import('foo', 'bar'));
}
}
class ProjectLoader1 extends Loader
{
public function load($resource, $type = null)
{
}
public function supports($resource, $type = null)
{
return \is_string($resource) && 'foo' === pathinfo($resource, PATHINFO_EXTENSION);
}
public function getType()
{
}
}