Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 6 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,9 @@
language: php

php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- nightly

matrix:
fast_finish: true
allow_failures:
- php: hhvm
- php: nightly

sudo: false

env:
- SYMFONY_VERSION="~2.3.0"
- SYMFONY_VERSION="~2.7.0"

- "7.3"
- "7.2"
- "7.1"
- "7.0"
- "5.6"
before_script:
- if [[ $TRAVIS_PHP_VERSION =~ 5.[34] ]] ; then echo 'extension="apc.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [[ $TRAVIS_PHP_VERSION =~ 5.[56] ]] ; then echo yes | pecl install apcu-4.0.10; fi;
- if [[ $TRAVIS_PHP_VERSION == 7.* || $TRAVIS_PHP_VERSION == nightly ]] ; then echo yes | pecl install -f apcu_bc; echo -e 'extension="apcu.so"\nextension="apc.so"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- if [[ $TRAVIS_PHP_VERSION != 'hhvm' ]]; then echo "apc.enable_cli = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
- composer require symfony/dependency-injection:${SYMFONY_VERSION} symfony/config:${SYMFONY_VERSION}
- composer install --dev

script:
- vendor/bin/phpunit
- composer install
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@
"homepage": "http://github.com/moodev/bounce",
"license": "ISC",
"require": {
"php": "^5.4 || ^7.0",
"ext-apc": "*",
"symfony/dependency-injection": ">=2.3.0 <2.8.0",
"symfony/config": ">=2.3.0 <2.8.0"
"php": "^5.5.9|>=7.0.8",
"symfony/dependency-injection": "~3.4",
"symfony/config": "~3.4"
},
"require-dev": {
"mockery/mockery": "~0.9.0",
"phpunit/phpunit": "~4.3.0"
"mockery/mockery": "~1.2",
"phpunit/phpunit": "~5.7|^6.0|^7.0"
},
"autoload": {
"psr-0": {
Expand Down
2 changes: 1 addition & 1 deletion lib/MooDev/Bounce/Config/FilePathValueProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function getValue(IBeanFactory $beanFactory)
$canonicalPath = realpath($filePath);
//If the canonicalPath is false, then the path doesn't exist, so we will
//let this through.
if ($canonicalPath !== false && !(strpos($canonicalPath, realpath($this->_rootDirectory)) === 0)) {
if ($canonicalPath === false && !(strpos($canonicalPath, realpath($this->_rootDirectory)) === 0)) {
throw new BounceException("Relative path $this->_relativePath ($canonicalPath) "
. "does not lie within the root $this->_rootDirectory (" . realpath($this->_rootDirectory) . ")");
}
Expand Down
14 changes: 4 additions & 10 deletions lib/MooDev/Bounce/Symfony/SymfonyConfigBeanFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,13 @@ public function create(Bean $bean)
}

if ($bean->scope) {
// This is getting killed off in Symfony 3. Sigh.
// TODO: deal with Symfony 3.
switch ($bean->scope) {
case "singleton":
$def->setScope(ContainerBuilder::SCOPE_CONTAINER);
$def->setShared(true);
break;
case "prototype":
$def->setScope(ContainerBuilder::SCOPE_PROTOTYPE);
$def->setShared(false);
break;
default:
$def->setScope($bean->scope);
}
}

Expand All @@ -155,11 +151,9 @@ public function create(Bean $bean)
}

if ($bean->factoryBean) {
$def->setFactoryService($bean->factoryBean);
$def->setFactoryMethod($bean->factoryMethod);
$def->setFactory([$bean->factoryBean, $bean->factoryMethod]);
} elseif ($bean->factoryMethod) {
$def->setFactoryClass($originalClass);
$def->setFactoryMethod($bean->factoryMethod);
$def->setFactory([$originalClass, $bean->factoryMethod]);
}

return $def;
Expand Down
3 changes: 2 additions & 1 deletion tests/MooDev/Bounce/Config/BeanRefValueProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
namespace MooDev\Bounce\Config;

use MooDev\Bounce\Context\BeanFactory;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../TestInit.php';

/**
* BeanRefValueProvider test case.
*/
class BeanRefValueProviderTest extends \PHPUnit_Framework_TestCase
class BeanRefValueProviderTest extends TestCase
{
public function testBeanProvider()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/MooDev/Bounce/Config/BeanValueProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
namespace MooDev\Bounce\Config;

use MooDev\Bounce\Context\BeanFactory;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../TestInit.php';

/**
* BeanValueProvider test case.
*/
class BeanValueProviderTest extends \PHPUnit_Framework_TestCase
class BeanValueProviderTest extends TestCase
{

public function testBeanProvider()
Expand Down
3 changes: 2 additions & 1 deletion tests/MooDev/Bounce/Config/ConstantValueProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/
namespace MooDev\Bounce\Config;
use MooDev\Bounce\Context\BeanFactory;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../TestInit.php';

/**
* ConstantValueProvider test case.
*/
class ConstantValueProviderTest extends \PHPUnit_Framework_TestCase
class ConstantValueProviderTest extends TestCase
{

public function testConstantRetrieval()
Expand Down
10 changes: 4 additions & 6 deletions tests/MooDev/Bounce/Config/FilePathValueProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
namespace MooDev\Bounce\Config;
use MooDev\Bounce\Context\BeanFactory;
use MooDev\Bounce\Exception\BounceException;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../TestInit.php';

/**
* FilePathValueProvider test case.
*/
class FilePathValueProviderTest extends \PHPUnit_Framework_TestCase
class FilePathValueProviderTest extends TestCase
{

public function testGoodFilepath()
Expand All @@ -35,11 +36,8 @@ public function testBadFilepath()
define("DOC_DIR", realpath(__DIR__ . '/../../../'));
}
$impl = new FilePathValueProvider("../moo-common-log/build.xml");
try {
$impl->getValue(BeanFactory::getInstance(new Context()));
} catch (BounceException $e) {
$this->assertEquals(1, preg_match("|^Relative path ../moo-common-log/build.xml (.*) does not lie within the root (.*)|", $e->getMessage()));
}
$this->expectException(BounceException::class);
$impl->getValue(BeanFactory::getInstance(new Context()));
}
}

3 changes: 2 additions & 1 deletion tests/MooDev/Bounce/Config/ListValueProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/
namespace MooDev\Bounce\Config;
use MooDev\Bounce\Context\BeanFactory;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../TestInit.php';

/**
* ListValueProvider test case.
*/
class ListValueProviderTest extends \PHPUnit_Framework_TestCase
class ListValueProviderTest extends TestCase
{
public function testEmptyList()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/MooDev/Bounce/Config/MapValueProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/
namespace MooDev\Bounce\Config;
use MooDev\Bounce\Context\BeanFactory;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../TestInit.php';

/**
* MapValueProvider test case.
*/
class MapValueProviderTest extends \PHPUnit_Framework_TestCase
class MapValueProviderTest extends TestCase
{
public function testEmptyMap()
{
Expand Down
3 changes: 2 additions & 1 deletion tests/MooDev/Bounce/Config/NullValueProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/
namespace MooDev\Bounce\Config;
use MooDev\Bounce\Context\BeanFactory;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../TestInit.php';

/**
* NullValueProvider test case.
*/
class NullValueProviderTest extends \PHPUnit_Framework_TestCase
class NullValueProviderTest extends TestCase
{

public function testNullValue()
Expand Down
3 changes: 2 additions & 1 deletion tests/MooDev/Bounce/Config/SimpleValueProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/
namespace MooDev\Bounce\Config;
use MooDev\Bounce\Context\BeanFactory;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../TestInit.php';

/**
* SimpleValueProvider test case.
*/
class SimpleValueProviderTest extends \PHPUnit_Framework_TestCase
class SimpleValueProviderTest extends TestCase
{

public function testSimpleValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,22 @@
* @license ISC
*/
namespace MooDev\Bounce\Context;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../TestInit.php';

/**
* ApcCachedXmlApplicationContext test case.
*/
class ApcCachedXmlApplicationContextTest extends \PHPUnit_Framework_TestCase
class ApcCachedXmlApplicationContextTest extends TestCase
{

/**
* This test case's results are only valid if APC is enabled and functional.
*/
public function testTestConfig()
{
$this->markTestSkipped();
$this->assertTrue(function_exists("apc_fetch"), "APC module is not loaded.");
$this->assertTrue(ini_get("apc.enable_cli") == true, "apc.enable_cli must be enabled in your php.ini");
}
Expand Down
3 changes: 2 additions & 1 deletion tests/MooDev/Bounce/Context/BeanFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

use MooDev\Bounce\Config;
use MooDev\Bounce\Proxy\ProxyGeneratorFactory;
use PHPUnit\Framework\TestCase;
use stdClass;
use MooDev\Bounce\Exception\BounceException;

/**
* BeanFactory test case.
*/
class BeanFactoryTest extends \PHPUnit_Framework_TestCase
class BeanFactoryTest extends TestCase
{

public function setUp() {
Expand Down
3 changes: 2 additions & 1 deletion tests/MooDev/Bounce/Context/XmlApplicationContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
namespace MooDev\Bounce\Context;
use MooDev\Bounce\Exception\BounceException;
use PHPUnit\Framework\TestCase;
use SimpleXMLElement;
use MooDev\Bounce\Config;

Expand All @@ -14,7 +15,7 @@
/**
* XmlApplicationContext test case.
*/
class XmlApplicationContextTest extends \PHPUnit_Framework_TestCase
class XmlApplicationContextTest extends TestCase
{
public function testLoadFullXml()
{
Expand Down
31 changes: 12 additions & 19 deletions tests/MooDev/Bounce/Proxy/LookupMethodProxyGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@
use MooDev\Bounce\Config\Bean;
use MooDev\Bounce\Config\LookupMethod;
use Mockery as m;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../TestInit.php';


class LookupMethodProxyGeneratorTest extends \PHPUnit_Framework_TestCase {
class LookupMethodProxyGeneratorTest extends TestCase {

public function tearDown() {
\Mockery::close();
}

public function testProxyGenerationNoMethodsStdClass() {
$factory = new ProxyGeneratorFactory();
Expand Down Expand Up @@ -42,18 +47,12 @@ public function testProxyGenerationNoMethodsExistingConstructor() {
$this->assertEquals(2, count($rClass->getMethods()));
$params = $constructor->getParameters();
reset($params);
each($params);
/**
* @var \ReflectionParameter $param
*/
list($key, $param) = each($params);
$this->assertEquals("a", $param->getName());
list($key, $param) = each($params);
$this->assertEquals("b", $param->getName());
$this->assertEquals("foo", @$param->getDefaultValue());
list($key, $param) = each($params);
$this->assertEquals("cat", $param->getName());
$this->assertEquals("harhar", @$param->getDefaultValue());
$this->assertEquals("a", $params[1]->getName());
$this->assertEquals("b", $params[2]->getName());
$this->assertEquals("cat", $params[3]->getName());

$this->assertTrue($rClass->hasMethod("getA"));
$this->assertTrue($rClass->hasProperty("a"));
Expand Down Expand Up @@ -94,18 +93,12 @@ public function testProxyGenerationMethodsExistingConstructor() {
$this->assertEquals(4, count($rClass->getMethods()));
$params = $constructor->getParameters();
reset($params);
each($params);
/**
* @var \ReflectionParameter $param
*/
list($key, $param) = each($params);
$this->assertEquals("a", $param->getName());
list($key, $param) = each($params);
$this->assertEquals("b", $param->getName());
$this->assertEquals("foo", @$param->getDefaultValue());
list($key, $param) = each($params);
$this->assertEquals("cat", $param->getName());
$this->assertEquals("harhar", @$param->getDefaultValue());
$this->assertEquals("a", $params[1]->getName());
$this->assertEquals("b", $params[2]->getName());
$this->assertEquals("cat", $params[3]->getName());

$this->assertTrue($rClass->hasMethod("getA"));
$this->assertTrue($rClass->hasProperty("a"));
Expand Down
5 changes: 3 additions & 2 deletions tests/MooDev/Bounce/Proxy/Store/InMemoryProxyStoreTest.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php
namespace MooDev\Bounce\Proxy\Store;
use Mockery as m;
use PHPUnit\Framework\TestCase;

require_once __DIR__ . '/../../../../TestInit.php';

class InMemoryProxyStoreTest extends \PHPUnit_Framework_TestCase {
class InMemoryProxyStoreTest extends TestCase {

public function testDefaultNamespaceIsValid()
{
$store = new UniqTmpDirFilesystemProxyStore();
$ns = $store->getProxyNamespace();
eval("namespace $ns;");
$this->assertNotEmpty($ns);
}

}
Expand Down
Loading