Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
2
vendor/dflydev/placeholder-resolver/.gitignore
vendored
Normal file
2
vendor/dflydev/placeholder-resolver/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
composer.lock
|
||||
vendor
|
12
vendor/dflydev/placeholder-resolver/.travis.yml
vendored
Normal file
12
vendor/dflydev/placeholder-resolver/.travis.yml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
language: php
|
||||
|
||||
php:
|
||||
- 5.3.3
|
||||
- 5.3
|
||||
- 5.4
|
||||
|
||||
before_script:
|
||||
- wget -nc http://getcomposer.org/composer.phar
|
||||
- php composer.phar install --dev
|
||||
|
||||
script: phpunit --coverage-text --verbose
|
19
vendor/dflydev/placeholder-resolver/LICENSE
vendored
Normal file
19
vendor/dflydev/placeholder-resolver/LICENSE
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2012 Dragonfly Development Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is furnished
|
||||
to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
101
vendor/dflydev/placeholder-resolver/README.md
vendored
Normal file
101
vendor/dflydev/placeholder-resolver/README.md
vendored
Normal file
|
@ -0,0 +1,101 @@
|
|||
Placeholder Resolver
|
||||
====================
|
||||
|
||||
Given a data source representing key => value pairs, resolve placeholders
|
||||
like `${foo.bar}` to the value associated with the `foo.bar` key in
|
||||
the data source.
|
||||
|
||||
Placeholder Resolver is intended to be used at a relatively low level.
|
||||
For example, a configuration library could use Placeholder Resolver
|
||||
behind the scenes to allow for configuration values to reference
|
||||
other configuration values.
|
||||
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
conn.driver: mysql
|
||||
conn.db_name: example
|
||||
conn.hostname: 127.0.0.1
|
||||
conn.username: root
|
||||
conn.password: pa$$word
|
||||
|
||||
Given the appropriate `DataSourceInterface` implementation to provide
|
||||
the above data as a set of key => value pairs, the Placeholder Resolver
|
||||
would resolve the value of `$dsnPattern` to `mysql:dbname=example;host=127.0.0.1`.
|
||||
|
||||
$dsnPattern = '${conn.driver}:dbname=${conn.db_name};host=${conn.hostname}';
|
||||
$dsn = $placeholderResolver->resolveValue($dsnPattern);
|
||||
// mysql:dbname=example;host=127.0.0.1
|
||||
|
||||
|
||||
Requirements
|
||||
------------
|
||||
|
||||
* PHP 5.3+
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
use Dflydev\PlaceholderResolver\RegexPlaceholderResolver;
|
||||
|
||||
// YourDataSource implements Dflydev\PlaceholderResolver\DataSource\DataSourceInterface
|
||||
$dataSource = new YourDataSource;
|
||||
|
||||
// Create the placeholder resolver
|
||||
$placeholderResolver = new RegexPlaceholderResolver($dataSource);
|
||||
|
||||
// Start resolving placeholders
|
||||
$value = $placeholderResolver->resolvePlaceholder('${foo}');
|
||||
|
||||
The `RegexPlaceholderResolver` constructor accepts two additional arguments,
|
||||
a placeholder prefix and a placeholder suffix. The default placeholder
|
||||
prefix is `${` and the default placeholder suffix is `}`.
|
||||
|
||||
To handle placeholders that look like `<foo.bar>` instead of `${foo.bar}`,
|
||||
one would instantiate the class like this:
|
||||
|
||||
$placeholderResolver = new RegexPlaceholderResolver($dataSource, '<', '>');
|
||||
|
||||
Placeholders can recursively resolve placeholders. For example, given a
|
||||
data source with the following:
|
||||
|
||||
array(
|
||||
'foo' => 'FOO',
|
||||
'bar' => 'BAR',
|
||||
'FOO.BAR' => 'BAZ!',
|
||||
);
|
||||
|
||||
The placeholder `${${foo}.${bar}}` would internally be resolved to
|
||||
`${FOO.BAR}` before being further resolved to `BAZ!`.
|
||||
|
||||
Resolved placeholders are cached using the `CacheInterface`. The default
|
||||
`Cache` implementation is used unless it is explicitly set on the
|
||||
Placeholder Resolver.
|
||||
|
||||
// YourCache implements Dflydev\PlaceholderResolver\Cache\CacheInterface
|
||||
$cache = new YourCache;
|
||||
|
||||
$placeholderResolver->setCache($cache);
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
This library is licensed under the New BSD License - see the LICENSE file
|
||||
for details.
|
||||
|
||||
|
||||
Community
|
||||
---------
|
||||
|
||||
If you have questions or want to help out, join us in the
|
||||
[#dflydev](irc://irc.freenode.net/#dflydev) channel on irc.freenode.net.
|
||||
|
||||
|
||||
Not Invented Here
|
||||
-----------------
|
||||
|
||||
Much of the ideas behind this library came from Spring's Property
|
||||
Placeholder Configurer implementation.
|
33
vendor/dflydev/placeholder-resolver/composer.json
vendored
Normal file
33
vendor/dflydev/placeholder-resolver/composer.json
vendored
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "dflydev/placeholder-resolver",
|
||||
"type": "library",
|
||||
"description": "Given a data source representing key => value pairs, resolve placeholders like ${foo.bar} to the value associated with the 'foo.bar' key in the data source.",
|
||||
"homepage": "https://github.com/dflydev/dflydev-placeholder-resolver",
|
||||
"keywords": ["placeholder", "resolver"],
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dragonfly Development Inc.",
|
||||
"email": "info@dflydev.com",
|
||||
"homepage": "http://dflydev.com"
|
||||
},
|
||||
{
|
||||
"name": "Beau Simensen",
|
||||
"email": "beau@dflydev.com",
|
||||
"homepage": "http://beausimensen.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Dflydev\\PlaceholderResolver": "src"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
}
|
||||
}
|
14
vendor/dflydev/placeholder-resolver/phpunit.xml.dist
vendored
Normal file
14
vendor/dflydev/placeholder-resolver/phpunit.xml.dist
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit colors="true" bootstrap="tests/bootstrap.php">
|
||||
<testsuites>
|
||||
<testsuite name="Placeholder Resolver Test Suite">
|
||||
<directory>./tests/Dflydev/PlaceholderResolver</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./src/Dflydev/PlaceholderResolver/</directory>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver;
|
||||
|
||||
use Dflydev\PlaceholderResolver\Cache\Cache;
|
||||
use Dflydev\PlaceholderResolver\Cache\CacheInterface;
|
||||
|
||||
abstract class AbstractPlaceholderResolver implements PlaceholderResolverInterface
|
||||
{
|
||||
private $cache;
|
||||
protected $maxReplacementDepth = 10;
|
||||
|
||||
/**
|
||||
* Set maximum depth for recursive replacement
|
||||
*
|
||||
* @param int $maxReplacementDepth
|
||||
*
|
||||
* @return PlaceholderResolver
|
||||
*/
|
||||
public function setMaxReplacementDepth($maxReplacementDepth)
|
||||
{
|
||||
$this->maxReplacementDepth = $maxReplacementDepth;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cache
|
||||
*
|
||||
* @return CacheInterface
|
||||
*/
|
||||
public function getCache()
|
||||
{
|
||||
if (null === $this->cache) {
|
||||
$this->cache = new Cache;
|
||||
}
|
||||
|
||||
return $this->cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set cache
|
||||
*
|
||||
* @param CacheInterface $cache
|
||||
*/
|
||||
public function setCache(CacheInterface $cache)
|
||||
{
|
||||
$this->cache = $cache;
|
||||
}
|
||||
}
|
62
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/Cache/Cache.php
vendored
Normal file
62
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/Cache/Cache.php
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver\Cache;
|
||||
|
||||
class Cache implements CacheInterface
|
||||
{
|
||||
private $cache = array();
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exists($placeholder)
|
||||
{
|
||||
if (is_array($placeholder)) {
|
||||
throw new \RuntimeException('Placeholder is an array');
|
||||
}
|
||||
|
||||
return array_key_exists((string) $placeholder, $this->cache);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($placeholder)
|
||||
{
|
||||
if (is_array($placeholder)) {
|
||||
throw new \RuntimeException('Placeholder is an array');
|
||||
}
|
||||
|
||||
return array_key_exists((string) $placeholder, $this->cache)
|
||||
? $this->cache[(string) $placeholder]
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function set($placeholder, $value = null)
|
||||
{
|
||||
if (is_array($placeholder)) {
|
||||
throw new \RuntimeException('Placeholder is an array');
|
||||
}
|
||||
$this->cache[(string) $placeholder] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
$this->cache = array();
|
||||
}
|
||||
}
|
48
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/Cache/CacheInterface.php
vendored
Normal file
48
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/Cache/CacheInterface.php
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver\Cache;
|
||||
|
||||
interface CacheInterface
|
||||
{
|
||||
/**
|
||||
* Does specified placeholder exist?
|
||||
*
|
||||
* @param string $placeholder
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($placeholder);
|
||||
|
||||
/**
|
||||
* Get placeholder's value
|
||||
*
|
||||
* @param string $placeholder
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function get($placeholder);
|
||||
|
||||
/**
|
||||
* Set placeholder's value
|
||||
*
|
||||
* @param string $placeholder
|
||||
* @param string|null $value
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function set($placeholder, $value = null);
|
||||
|
||||
/**
|
||||
* Flush cache
|
||||
*/
|
||||
public function flush();
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver\DataSource;
|
||||
|
||||
/**
|
||||
* Array Data Source
|
||||
*
|
||||
* Simple array based implementation of the Data Source Interface
|
||||
*
|
||||
* @author Beau Simensen <beau@dflydev.com>
|
||||
*/
|
||||
class ArrayDataSource implements DataSourceInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $array;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $array
|
||||
*/
|
||||
public function __construct(array $array = array())
|
||||
{
|
||||
$this->array = $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function exists($key, $system = false)
|
||||
{
|
||||
if ($system) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return isset($this->array[$key]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get($key, $system = false)
|
||||
{
|
||||
if ($system) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return isset($this->array[$key]) ? $this->array[$key] : null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver\DataSource;
|
||||
|
||||
interface DataSourceInterface
|
||||
{
|
||||
/**
|
||||
* Does specified key exist?
|
||||
*
|
||||
* If $system is true, check system data. Otherwise,
|
||||
* use application data. (think system == $_SERVER)
|
||||
*
|
||||
* @param string $key
|
||||
* @param bool|null $system
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exists($key, $system = false);
|
||||
|
||||
/**
|
||||
* Get key's value
|
||||
*
|
||||
* If $system is true, check system data. Otherwise,
|
||||
* use application data. (think system == $_SERVER)
|
||||
*
|
||||
* @param string $key
|
||||
* @param bool|null $system
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function get($key, $system = false);
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver;
|
||||
|
||||
interface PlaceholderResolverInterface
|
||||
{
|
||||
/**
|
||||
* Resolve a placeholder
|
||||
*
|
||||
* @param string $placeholder
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function resolvePlaceholder($placeholder);
|
||||
}
|
69
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/RegexPlaceholderResolver.php
vendored
Normal file
69
vendor/dflydev/placeholder-resolver/src/Dflydev/PlaceholderResolver/RegexPlaceholderResolver.php
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver;
|
||||
|
||||
use Dflydev\PlaceholderResolver\DataSource\DataSourceInterface;
|
||||
|
||||
class RegexPlaceholderResolver extends AbstractPlaceholderResolver
|
||||
{
|
||||
/**
|
||||
* @var PlaceholderResolverCallback
|
||||
*/
|
||||
private $placeholderResolverCallback;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pattern;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DataSourceInterface $dataSource
|
||||
* @param string|null $placeholderPrefix
|
||||
* @param string|null $placeholderSuffix
|
||||
*/
|
||||
public function __construct(DataSourceInterface $dataSource, $placeholderPrefix = '${', $placeholderSuffix = '}')
|
||||
{
|
||||
$this->placeholderResolverCallback = new RegexPlaceholderResolverCallback($dataSource);
|
||||
$placeholderPrefix = preg_quote($placeholderPrefix);
|
||||
$placeholderSuffix = preg_quote($placeholderSuffix);
|
||||
$this->pattern = "/{$placeholderPrefix}([a-zA-Z0-9\.\(\)_\:]+?){$placeholderSuffix}/";
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function resolvePlaceholder($placeholder)
|
||||
{
|
||||
if ($this->getCache()->exists($placeholder)) {
|
||||
return $this->getCache()->get($placeholder);
|
||||
}
|
||||
|
||||
$value = $placeholder;
|
||||
$counter = 0;
|
||||
|
||||
while ($counter++ < $this->maxReplacementDepth) {
|
||||
$newValue = preg_replace_callback(
|
||||
$this->pattern,
|
||||
array($this->placeholderResolverCallback, 'callback'),
|
||||
$value
|
||||
);
|
||||
if ($newValue === $value) { break; }
|
||||
$value = $newValue;
|
||||
}
|
||||
|
||||
$this->getCache()->set($placeholder, $value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver;
|
||||
|
||||
use Dflydev\PlaceholderResolver\DataSource\DataSourceInterface;
|
||||
|
||||
class RegexPlaceholderResolverCallback
|
||||
{
|
||||
/**
|
||||
* @var DataSourceInterface
|
||||
*/
|
||||
private $dataSource;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DataSourceInterface $dataSource
|
||||
*/
|
||||
public function __construct(DataSourceInterface $dataSource)
|
||||
{
|
||||
$this->dataSource = $dataSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for preg_replace_callback() generally called in PlaceholderResolver
|
||||
*
|
||||
* The expected input will be array($fullMatch, $potentialKey) and the
|
||||
* expected output will be either a value from the data source, a special
|
||||
* value from SERVER or CONSTANT, or the contents of $fullMatch (the key
|
||||
* itself with its wrapped prefix and suffix).
|
||||
*
|
||||
* @param array $matches
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function callback($matches)
|
||||
{
|
||||
list ($fullMatch, $potentialKey) = $matches;
|
||||
if (preg_match('/^(SYSTEM|SERVER|CONSTANT):(\w+)$/', $potentialKey, $specialMatches)) {
|
||||
list ($dummy, $which, $specialKey) = $specialMatches;
|
||||
switch ($which) {
|
||||
case 'SERVER':
|
||||
case 'SYSTEM':
|
||||
if ($this->dataSource->exists($specialKey, true)) {
|
||||
return $this->dataSource->get($specialKey, true);
|
||||
}
|
||||
break;
|
||||
case 'CONSTANT':
|
||||
if (defined($specialKey)) {
|
||||
return constant($specialKey);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->dataSource->exists($potentialKey)) {
|
||||
return $this->dataSource->get($potentialKey);
|
||||
}
|
||||
|
||||
return $fullMatch;
|
||||
}
|
||||
}
|
125
vendor/dflydev/placeholder-resolver/tests/Dflydev/PlaceholderResolver/Cache/CacheTest.php
vendored
Normal file
125
vendor/dflydev/placeholder-resolver/tests/Dflydev/PlaceholderResolver/Cache/CacheTest.php
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver\Cache;
|
||||
|
||||
class CacheTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testSetAndGet()
|
||||
{
|
||||
$object = new CacheTestToSTring;
|
||||
|
||||
$cache = new Cache;
|
||||
$cache->set(1, "one as integer");
|
||||
$cache->set("2", "two as string '2'");
|
||||
$cache->set("three", "three as string");
|
||||
$cache->set($object, "object");
|
||||
|
||||
$this->assertEquals("one as integer", $cache->get(1));
|
||||
$this->assertEquals("two as string '2'", $cache->get('2'));
|
||||
$this->assertEquals("three as string", $cache->get('three'));
|
||||
$this->assertEquals("object", $cache->get($object));
|
||||
|
||||
$this->assertNull($cache->get(11));
|
||||
$this->assertNull($cache->get('12'));
|
||||
$this->assertNull($cache->get('thirteen'));
|
||||
}
|
||||
|
||||
public function testExists()
|
||||
{
|
||||
$object = new CacheTestToSTring;
|
||||
|
||||
$cache = new Cache;
|
||||
|
||||
$this->assertFalse($cache->exists(1));
|
||||
$this->assertFalse($cache->exists("2"));
|
||||
$this->assertFalse($cache->exists("three"));
|
||||
$this->assertFalse($cache->exists($object));
|
||||
}
|
||||
|
||||
public function testExistsArray()
|
||||
{
|
||||
$array = array();
|
||||
|
||||
$cache = new Cache;
|
||||
|
||||
$this->setExpectedException('RuntimeException');
|
||||
|
||||
$cache->exists($array);
|
||||
}
|
||||
|
||||
public function testGetArray()
|
||||
{
|
||||
$array = array();
|
||||
|
||||
$cache = new Cache;
|
||||
|
||||
$this->setExpectedException('RuntimeException');
|
||||
|
||||
$cache->get($array);
|
||||
}
|
||||
|
||||
public function testSetArray()
|
||||
{
|
||||
$array = array();
|
||||
|
||||
$cache = new Cache;
|
||||
|
||||
$this->setExpectedException('RuntimeException');
|
||||
|
||||
$cache->set($array, 'broken');
|
||||
}
|
||||
|
||||
public function testExistsNoToString()
|
||||
{
|
||||
$object = new CacheTestNoToSTring;
|
||||
|
||||
$cache = new Cache;
|
||||
|
||||
$this->setExpectedException('PHPUnit_Framework_Error');
|
||||
|
||||
$cache->exists($object);
|
||||
}
|
||||
|
||||
public function testGetNoToString()
|
||||
{
|
||||
$object = new CacheTestNoToSTring;
|
||||
|
||||
$cache = new Cache;
|
||||
|
||||
$this->setExpectedException('PHPUnit_Framework_Error');
|
||||
|
||||
$cache->get($object);
|
||||
}
|
||||
|
||||
public function testSetNoToString()
|
||||
{
|
||||
$object = new CacheTestNoToSTring;
|
||||
|
||||
$cache = new Cache;
|
||||
|
||||
$this->setExpectedException('PHPUnit_Framework_Error');
|
||||
|
||||
$cache->set($object, 'broken');
|
||||
}
|
||||
}
|
||||
|
||||
class CacheTestNoToSTring
|
||||
{
|
||||
}
|
||||
|
||||
class CacheTestToSTring
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return 'any string';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver\DataSource;
|
||||
|
||||
/**
|
||||
* ArrayDataSource Test
|
||||
*
|
||||
* @author Beau Simensen <beau@dflydev.com>
|
||||
*/
|
||||
class ArrayDataSourceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Test basic functionality
|
||||
*/
|
||||
public function testBasic()
|
||||
{
|
||||
$dataSource = new ArrayDataSource(array(
|
||||
'a' => 'A',
|
||||
'b' => 'B',
|
||||
'c' => 'C',
|
||||
));
|
||||
|
||||
$this->assertTrue($dataSource->exists('a'));
|
||||
$this->assertTrue($dataSource->exists('b'));
|
||||
$this->assertTrue($dataSource->exists('c'));
|
||||
$this->assertFalse($dataSource->exists('d'));
|
||||
|
||||
$this->assertFalse($dataSource->exists('a', true));
|
||||
$this->assertFalse($dataSource->exists('d', true));
|
||||
|
||||
$this->assertEquals('A', $dataSource->get('a'));
|
||||
$this->assertEquals('B', $dataSource->get('b'));
|
||||
$this->assertEquals('C', $dataSource->get('c'));
|
||||
$this->assertNull($dataSource->get('d'));
|
||||
|
||||
$this->assertNull($dataSource->get('a', true));
|
||||
$this->assertNull($dataSource->get('d', true));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver;
|
||||
|
||||
class RegexPlaceholderResolverCallbackTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testCallback()
|
||||
{
|
||||
$dataSource = $this->getMock('Dflydev\PlaceholderResolver\DataSource\DataSourceInterface');
|
||||
$dataSource
|
||||
->expects($this->any())
|
||||
->method('exists')
|
||||
->will($this->returnValueMap(array(
|
||||
array('foo', false, true),
|
||||
array('bar', false, true),
|
||||
array('baz', false, true),
|
||||
array('bat', false, false),
|
||||
array('foo', true, true),
|
||||
array('bar', true, false),
|
||||
)))
|
||||
;
|
||||
$dataSource
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap(array(
|
||||
array('foo', false, 'FOO'),
|
||||
array('bar', false, 'BAR'),
|
||||
array('baz', false, 'BAZ'),
|
||||
array('foo', true, 'SYSTEM FOO'),
|
||||
)))
|
||||
;
|
||||
|
||||
$placeholderResolverCallback = new RegexPlaceholderResolverCallback($dataSource);
|
||||
|
||||
define('TEST_CONSTANT_RESOLVE', 'abc123');
|
||||
|
||||
$this->assertEquals('FOO', $placeholderResolverCallback->callback(array('${foo}', 'foo')));
|
||||
$this->assertEquals('BAR', $placeholderResolverCallback->callback(array('${bar}', 'bar')));
|
||||
$this->assertEquals('BAZ', $placeholderResolverCallback->callback(array('${baz}', 'baz')));
|
||||
$this->assertEquals('${bat}', $placeholderResolverCallback->callback(array('${bat}', 'bat')));
|
||||
$this->assertEquals('SYSTEM FOO', $placeholderResolverCallback->callback(array('${SYSTEM:foo}', 'SYSTEM:foo')));
|
||||
$this->assertEquals('${SYSTEM:bar}', $placeholderResolverCallback->callback(array('${SYSTEM:bar}', 'SYSTEM:bar')));
|
||||
$this->assertEquals('SYSTEM FOO', $placeholderResolverCallback->callback(array('${SERVER:foo}', 'SERVER:foo')));
|
||||
$this->assertEquals('${SERVER:bar}', $placeholderResolverCallback->callback(array('${SERVER:bar}', 'SERVER:bar')));
|
||||
$this->assertEquals('abc123', $placeholderResolverCallback->callback(array('${CONSTANT:TEST_CONSTANT_RESOLVE}', 'CONSTANT:TEST_CONSTANT_RESOLVE')));
|
||||
$this->assertEquals('${CONSTANT:MISSING_TEST_CONSTANT_RESOLVE}', $placeholderResolverCallback->callback(array('${CONSTANT:MISSING_TEST_CONSTANT_RESOLVE}', 'CONSTANT:MISSING_TEST_CONSTANT_RESOLVE')));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (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\PlaceholderResolver;
|
||||
|
||||
class PlaceholderResolverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testResolvePlaceholder()
|
||||
{
|
||||
$dataSource = $this->getMock('Dflydev\PlaceholderResolver\DataSource\DataSourceInterface');
|
||||
$dataSource
|
||||
->expects($this->any())
|
||||
->method('exists')
|
||||
->will($this->returnValueMap(array(
|
||||
array('foo', false, true),
|
||||
array('bar', false, true),
|
||||
array('baz', false, true),
|
||||
array('bat', false, false),
|
||||
array('composite', false, true),
|
||||
array('FOO.BAR', false, true),
|
||||
array('FOO.BAR.BAZ', false, false),
|
||||
)))
|
||||
;
|
||||
$dataSource
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap(array(
|
||||
array('foo', false, 'FOO'),
|
||||
array('bar', false, 'BAR'),
|
||||
array('baz', false, 'BAZ'),
|
||||
array('composite', false, '${foo}-${bar}'),
|
||||
array('FOO.BAR', false, 'Foo Dot Bar'),
|
||||
)))
|
||||
;
|
||||
|
||||
$placeholderResolver = new RegexPlaceholderResolver($dataSource);
|
||||
|
||||
$this->assertEquals("FOO", $placeholderResolver->resolvePlaceholder('${foo}'));
|
||||
$this->assertEquals("BAR", $placeholderResolver->resolvePlaceholder('${bar}'));
|
||||
$this->assertEquals("BAZ", $placeholderResolver->resolvePlaceholder('${baz}'));
|
||||
$this->assertEquals("FOO-BAR", $placeholderResolver->resolvePlaceholder('${composite}'));
|
||||
$this->assertEquals("FOO-BAR-BAZ", $placeholderResolver->resolvePlaceholder('${composite}-${baz}'));
|
||||
$this->assertEquals("Foo Dot Bar", $placeholderResolver->resolvePlaceholder('${${foo}.${bar}}'));
|
||||
$this->assertEquals('${FOO.BAR.BAZ}', $placeholderResolver->resolvePlaceholder('${FOO.BAR.BAZ}'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider resolvePlaceholderPrefixAndSuffixProvider
|
||||
*/
|
||||
public function testResolvePlaceholderPrefixAndSuffix($prefix, $suffix)
|
||||
{
|
||||
$dataSource = $this->getMock('Dflydev\PlaceholderResolver\DataSource\DataSourceInterface');
|
||||
$dataSource
|
||||
->expects($this->any())
|
||||
->method('exists')
|
||||
->will($this->returnValueMap(array(
|
||||
array('foo', false, true),
|
||||
array('bar', false, true),
|
||||
array('baz', false, true),
|
||||
array('bat', false, false),
|
||||
array('composite', false, true),
|
||||
array('FOO.BAR', false, true),
|
||||
)))
|
||||
;
|
||||
$dataSource
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap(array(
|
||||
array('foo', false, 'FOO'),
|
||||
array('bar', false, 'BAR'),
|
||||
array('baz', false, 'BAZ'),
|
||||
array('composite', false, $prefix.'foo'.$suffix.'-'.$prefix.'bar'.$suffix),
|
||||
array('FOO.BAR', false, 'Foo Dot Bar'),
|
||||
)))
|
||||
;
|
||||
|
||||
$placeholderResolver = new RegexPlaceholderResolver($dataSource, $prefix, $suffix);
|
||||
$this->assertEquals("FOO", $placeholderResolver->resolvePlaceholder($prefix.'foo'.$suffix));
|
||||
$this->assertEquals($prefix.'bat'.$suffix, $placeholderResolver->resolvePlaceholder($prefix.'bat'.$suffix));
|
||||
$this->assertEquals("FOO-BAR", $placeholderResolver->resolvePlaceholder($prefix.'composite'.$suffix));
|
||||
$this->assertEquals("FOO-BAR-BAZ", $placeholderResolver->resolvePlaceholder($prefix.'composite'.$suffix.'-'.$prefix.'baz'.$suffix));
|
||||
$this->assertEquals("Foo Dot Bar", $placeholderResolver->resolvePlaceholder($prefix.$prefix.'foo'.$suffix.'.'.$prefix.'bar'.$suffix.$suffix));
|
||||
}
|
||||
|
||||
public function resolvePlaceholderPrefixAndSuffixProvider()
|
||||
{
|
||||
return array(
|
||||
array('%', '%'),
|
||||
array('<', '>'),
|
||||
array('(<)', '(>)'),
|
||||
);
|
||||
}
|
||||
}
|
13
vendor/dflydev/placeholder-resolver/tests/bootstrap.php
vendored
Normal file
13
vendor/dflydev/placeholder-resolver/tests/bootstrap.php
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is a part of dflydev/placeholder-resolver.
|
||||
*
|
||||
* (c) Dragonfly Development Inc.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
$loader = require dirname(__DIR__).'/vendor/autoload.php';
|
||||
|
Reference in a new issue