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,89 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
class AbstractConfigurationBuilderTest extends \PHPUnit_Framework_TestCase
{
public function testPlaceholderResolver()
{
$placeholderResolver = $this->getMock('Dflydev\PlaceholderResolver\PlaceholderResolverInterface');
$placeholderResolverFactory = $this->getMock('Dflydev\DotAccessConfiguration\PlaceholderResolverFactoryInterface');
$placeholderResolverFactory
->expects($this->once())
->method('create')
->will($this->returnValue($placeholderResolver))
;
$configurationBuilder = $this->getMockForAbstractClass('Dflydev\DotAccessConfiguration\AbstractConfigurationBuilder');
$configurationBuilder
->expects($this->once())
->method('internalBuild')
;
$configurationBuilder->setPlaceholderResolverFactory($placeholderResolverFactory);
$configurationBuilder->build();
}
public function testReconfigure()
{
$configuration000 = $this->getMock('Dflydev\DotAccessConfiguration\ConfigurationInterface');
$configuration000
->expects($this->exactly(2))
->method('get')
->with($this->equalTo('foo'))
->will($this->returnValue('FOO'))
;
$configuration001 = $this->getMock('Dflydev\DotAccessConfiguration\ConfigurationInterface');
$configuration001
->expects($this->exactly(2))
->method('get')
->with($this->equalTo('bar'))
->will($this->returnValue('BAR'))
;
$placeholderResolver = $this->getMock('Dflydev\PlaceholderResolver\PlaceholderResolverInterface');
$placeholderResolverFactory = $this->getMock('Dflydev\DotAccessConfiguration\PlaceholderResolverFactoryInterface');
$placeholderResolverFactory
->expects($this->exactly(2))
->method('create')
->will($this->returnValue($placeholderResolver))
;
$configurationFactory = $this->getMock('Dflydev\DotAccessConfiguration\ConfigurationFactoryInterface');
$configurationFactory
->expects($this->exactly(2))
->method('create')
->will($this->onConsecutiveCalls($configuration000, $configuration001));
;
$configurationBuilder = $this->getMockForAbstractClass('Dflydev\DotAccessConfiguration\AbstractConfigurationBuilder');
$configurationBuilder->setPlaceholderResolverFactory($placeholderResolverFactory);
$configurationBuilder->setConfigurationFactory($configurationFactory);
$reconfiguredConfigurationBuilder = $this->getMockForAbstractClass('Dflydev\DotAccessConfiguration\AbstractConfigurationBuilder');
$configurationBuilder->reconfigure($reconfiguredConfigurationBuilder);
$configurationTest000 = $configurationBuilder->build();
$configurationTest001 = $reconfiguredConfigurationBuilder->build();
$this->assertEquals('FOO', $configuration000->get('foo'));
$this->assertEquals('FOO', $configurationTest000->get('foo'));
$this->assertEquals('BAR', $configuration001->get('bar'));
$this->assertEquals('BAR', $configurationTest001->get('bar'));
}
}

View file

@ -0,0 +1,39 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
class ConfigurationDataSourceTest extends \PHPUnit_Framework_TestCase
{
public function test()
{
$configuration = $this->getMock('Dflydev\DotAccessConfiguration\Configuration');
$configuration
->expects($this->any())
->method('getRaw')
->will($this->returnValueMap(array(
array('foo', 'bar'),
array('foo', null, true),
array('foo', 'bar', false),
)))
;
$dataSource = new ConfigurationDataSource($configuration);
$this->assertEquals('bar', $dataSource->get('foo'));
$this->assertTrue($dataSource->exists('foo'));
$this->assertEquals('bar', $dataSource->get('foo', false));
$this->assertTrue($dataSource->exists('foo', false));
$this->assertNull($dataSource->get('foo', true));
$this->assertFalse($dataSource->exists('foo', true));
}
}

View file

@ -0,0 +1,21 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
class ConfigurationFactoryTest extends \PHPUnit_Framework_TestCase
{
public function testCreate()
{
$configurationFactory = new ConfigurationFactory;
$configuration = $configurationFactory->create();
}
}

View file

@ -0,0 +1,175 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
class ConfigurationTest extends \PHPUnit_Framework_TestCase
{
protected function getTestData()
{
return array(
'a' => array(
'b' => array(
'c' => 'ABC',
),
),
'abc' => '%a.b.c%',
'abcd' => '%a.b.c.d%',
'some' => array(
'object' => new ConfigurationTestObject('some.object'),
'other' => array(
'object' => new ConfigurationTestObject('some.other.object'),
),
),
'object' => new ConfigurationTestObject('object'),
'an_array' => array('hello'),
);
}
protected function runBasicTests($configuration)
{
$this->assertEquals('ABC', $configuration->get('a.b.c'), 'Direct access by dot notation');
$this->assertEquals('ABC', $configuration->get('abc'), 'Resolved access');
$this->assertEquals('%a.b.c.d%', $configuration->get('abcd'), 'Unresolved access');
$this->assertEquals('object', $configuration->get('object')->key);
$this->assertEquals('some.object', $configuration->get('some.object')->key);
$this->assertEquals('some.other.object', $configuration->get('some.other.object')->key);
$this->assertEquals(array('hello'), $configuration->get('an_array'));
$this->assertEquals('This is ABC', $configuration->resolve('This is %a.b.c%'));
$this->assertNull($configuration->resolve());
}
public function testGet()
{
$configuration = new Configuration($this->getTestData());
$this->runBasicTests($configuration);
}
public function testAppend()
{
$configuration = new Configuration($this->getTestData());
$configuration->append('a.b.c', 'abc');
$configuration->append('an_array', 'world');
$this->assertEquals(array('ABC', 'abc'), $configuration->get('a.b.c'));
$this->assertEquals(array('hello', 'world'), $configuration->get('an_array'));
}
public function testExportRaw()
{
$configuration = new Configuration($this->getTestData());
// Start with "known" expected value.
$expected = $this->getTestData();
$this->assertEquals($expected, $configuration->exportRaw());
// Simulate change on an object to ensure that objects
// are being handled correctly.
$expected['object']->key = 'object (modified)';
// Make the same change in the object that the
// configuration is managing.
$configuration->get('object')->key = 'object (modified)';
$this->assertEquals($expected, $configuration->exportRaw());
}
public function testExport()
{
$configuration = new Configuration($this->getTestData());
// Start with "known" expected value.
$expected = $this->getTestData();
// We have one replacement that is expected to happen.
// It should be represented in the export as the
// resolved value!
$expected['abc'] = 'ABC';
$this->assertEquals($expected, $configuration->export());
// Simulate change on an object to ensure that objects
// are being handled correctly.
$expected['object']->key = 'object (modified)';
// Make the same change in the object that the
// configuration is managing.
$configuration->get('object')->key = 'object (modified)';
$this->assertEquals($expected, $configuration->export());
// Test to make sure that set will result in setting
// a new value and also that export will show this new
// value. (tests "export is dirty" functionality)
$configuration->set('abc', 'ABCD');
$expected['abc'] = 'ABCD';
$this->assertEquals($expected, $configuration->export());
}
public function testExportData()
{
$configuration = new Configuration($this->getTestData());
$data = $configuration->exportData();
// The exportData call should return data filled with
// resolved data.
$this->assertEquals('ABC', $data->get('abc'));
}
public function testImportRaw()
{
$configuration = new Configuration();
$configuration->importRaw($this->getTestData());
$this->runBasicTests($configuration);
}
public function testImport()
{
$configuration = new Configuration();
$configuration->import(new Configuration($this->getTestData()));
$this->runBasicTests($configuration);
}
public function testSetPlaceholderResolver()
{
$placeholderResolver = $this->getMock('Dflydev\PlaceholderResolver\PlaceholderResolverInterface');
$placeholderResolver
->expects($this->once())
->method('resolvePlaceholder')
->with($this->equalTo('foo'))
->will($this->returnValue('bar'))
;
$configuration = new Configuration;
$configuration->setPlaceholderResolver($placeholderResolver);
$this->assertEquals('bar', $configuration->resolve('foo'));
}
}
class ConfigurationTestObject
{
public $key;
public function __construct($key)
{
$this->key = $key;
}
}

View file

@ -0,0 +1,22 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
class PlaceholderResolverFactoryTest extends \PHPUnit_Framework_TestCase
{
public function testCreate()
{
$configuration = $this->getMock('Dflydev\DotAccessConfiguration\Configuration');
$placeholderResolverFactory = new PlaceholderResolverFactory;
$placeholderResolver = $placeholderResolverFactory->create($configuration);
}
}

View file

@ -0,0 +1,34 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
class YamlConfigurationBuilderTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!class_exists('Symfony\Component\Yaml\Yaml')) {
$this->markTestSkipped('The Symfony2 YAML library is not available');
}
}
public function testBuild()
{
$configurationBuilder = new YamlConfigurationBuilder;
$configuration = $configurationBuilder->build();
}
public function testBuildWithData()
{
$configurationBuilder = new YamlConfigurationBuilder('foo: bar');
$configuration = $configurationBuilder->build();
}
}

View file

@ -0,0 +1,38 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
class YamlFileConfigurationBuilderTest extends \PHPUnit_Framework_TestCase
{
public function setUp()
{
if (!class_exists('Symfony\Component\Yaml\Yaml')) {
$this->markTestSkipped('The Symfony2 YAML library is not available');
}
}
public function testBuilder()
{
$configurationBuilder = new YamlFileConfigurationBuilder(array(__DIR__.'/fixtures/yamlFileConfigurationBuilderTest-testBuilder.yml'));
$configuration = $configurationBuilder->build();
$this->assertEquals('C', $configuration->get('a.b.c'));
$this->assertEquals('C0', $configuration->get('a0.b0.c0'));
$this->assertEquals('C1', $configuration->get('a1.b1.c1'));
$this->assertEquals(array(
'yamlFileConfigurationBuilderTest-testBuilder-import-level0.yml',
'/tmp/testing-this-file-should-not-exist.yml',
'yamlFileConfigurationBuilderTest-testBuilder-import-level1.yml',
), $configuration->get('imports'));
}
}

View file

@ -0,0 +1,6 @@
imports:
- yamlFileConfigurationBuilderTest-testBuilder-import-level1.yml
a0:
b0:
c0: C0

View file

@ -0,0 +1,7 @@
imports:
- yamlFileConfigurationBuilderTest-testBuilder-import-level0.yml
- /tmp/testing-this-file-should-not-exist.yml
a:
b:
c: C