diff --git a/.gitignore b/.gitignore index 20328172b..f69e4693c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ composer.phar .vagrant integration-tests/vendor -integration-tests/composer.lock +composer.lock diff --git a/circle.yml b/circle.yml index fae9330de..73fa1cac4 100644 --- a/circle.yml +++ b/circle.yml @@ -15,7 +15,6 @@ dependencies: test: override: - vendor/bin/phpunit tests --coverage-text - - ln -s vendor integration-tests/vendor - vendor/bin/phpunit integration-tests/LDDFeatureRequesterTest.php - composer update && vendor/bin/phpunit tests diff --git a/integration-tests/LDDFeatureRequesterTest.php b/integration-tests/LDDFeatureRequesterTest.php index 47229c861..3f96cd831 100644 --- a/integration-tests/LDDFeatureRequesterTest.php +++ b/integration-tests/LDDFeatureRequesterTest.php @@ -1,20 +1,21 @@ "tcp", "host" => 'localhost', "port" => 6379)); - $client = new LDClient("BOGUS_API_KEY", array('feature_requester_class' => '\\LaunchDarkly\\LDDFeatureRequester')); + $client = new LDClient("BOGUS_API_KEY", array('feature_requester_class' => LDDFeatureRequester::class)); $builder = new LDUserBuilder(3); $user = $builder->build(); @@ -28,11 +29,11 @@ public function testGetApc() { if (!extension_loaded('apc')) { self::markTestSkipped('Install `apc` extension to run this test.'); } - $redis = new \Predis\Client(array( + $redis = new Client(array( "scheme" => "tcp", "host" => 'localhost', "port" => 6379)); - $client = new LDClient("BOGUS_API_KEY", array('feature_requester_class' => '\\LaunchDarkly\\ApcLDDFeatureRequester', + $client = new LDClient("BOGUS_API_KEY", array('feature_requester_class' => ApcLDDFeatureRequester::class, 'apc_expiration' => 1)); $builder = new LDUserBuilder(3); $user = $builder->build(); @@ -62,7 +63,7 @@ public function testGetApcu() { ]); $client = new LDClient('BOGUS_API_KEY', [ - 'feature_requester_class' => '\LaunchDarkly\ApcuLDDFeatureRequester', + 'feature_requester_class' => ApcuLDDFeatureRequester::class, 'apc_expiration' => 1 ]); diff --git a/integration-tests/bootstrap.sh b/integration-tests/bootstrap.sh index c0dbc86f6..f3f4ad105 100755 --- a/integration-tests/bootstrap.sh +++ b/integration-tests/bootstrap.sh @@ -21,7 +21,7 @@ apt-get install -y php-apc 2> /dev/null apt-get install -y phpunit 2> /dev/null # phpbrew stuff for 5.4 -apt-get build-dep php5 2> /dev/null +apt-get build-dep -y php5 2> /dev/null apt-get install -y php5 php5-dev php-pear autoconf automake curl build-essential libxslt1-dev re2c libxml2 libxml2-dev php5-cli bison libbz2-dev libreadline-dev 2> /dev/null apt-get install -y libfreetype6 libfreetype6-dev libpng12-0 libpng12-dev libjpeg-dev libjpeg8-dev libjpeg8 libgd-dev libgd3 libxpm4 libltdl7 libltdl-dev 2> /dev/null apt-get install -y libssl-dev openssl 2> /dev/null diff --git a/integration-tests/bootstrap.user.sh b/integration-tests/bootstrap.user.sh index b7a0d35af..fc36f5848 100755 --- a/integration-tests/bootstrap.user.sh +++ b/integration-tests/bootstrap.user.sh @@ -1,32 +1,8 @@ #!/bin/bash set -uxe -echo -echo "install phpbrew and php54" -cd ~ -curl -s -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew -chmod +x phpbrew -sudo mv phpbrew /usr/bin/phpbrew -phpbrew init -phpbrew known --update -phpbrew update -phpbrew install 5.4.34 +default - -echo -echo "switch php54" -echo "source $HOME/.phpbrew/bashrc" >> /home/vagrant/.bashrc -source $HOME/.phpbrew/bashrc -phpbrew switch 5.4.34 - -echo -echo "install php54-apc" -phpbrew ext install apc -echo "apc.enable_cli = 1" >> ~/.phpbrew/php/php-5.4.34/etc/php.ini -php -i | grep apc -echo "date.timezone =UTC" >> ~/.phpbrew/php/php-5.4.34/etc/php.ini - echo echo "update project dependencies" -cd /home/vagrant/project/integration-tests +cd /home/vagrant/project curl -sS https://getcomposer.org/installer | php php composer.phar update diff --git a/integration-tests/composer.json b/integration-tests/composer.json deleted file mode 100644 index 83541023a..000000000 --- a/integration-tests/composer.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "launchdarkly/launchdarkly-php-integration-tests", - "description": "Integration tests", - "homepage": "https://github.com/launchdarkly/php-client", - "license": "Apache-2.0", - "authors": [ - { - "name": "LaunchDarkly ", - "homepage": "http://launchdarkly.com/" - } - ], - "require": { - "php": ">=5.3", - "monolog/monolog": "^1.22", - "predis/predis": "1.0.*" - }, - "require-dev": { - "phpunit/phpunit": "4.3.*" - }, - "autoload": { - "psr-4": { - "": "../src/" - } - }, - "autoload-dev": { - "psr-4": { - "": "." - } - } -} diff --git a/src/LaunchDarkly/LDClient.php b/src/LaunchDarkly/LDClient.php index 5ee841d0c..ab3d22953 100644 --- a/src/LaunchDarkly/LDClient.php +++ b/src/LaunchDarkly/LDClient.php @@ -85,10 +85,10 @@ public function __construct($sdkKey, $options = array()) { if (isset($options['feature_requester_class'])) { $featureRequesterClass = $options['feature_requester_class']; } else { - $featureRequesterClass = '\\LaunchDarkly\\GuzzleFeatureRequester'; + $featureRequesterClass = GuzzleFeatureRequester::class; } - if (!is_a($featureRequesterClass, '\LaunchDarkly\FeatureRequester', true)) { + if (!is_a($featureRequesterClass, FeatureRequester::class, true)) { throw new \InvalidArgumentException; } $this->_featureRequester = new $featureRequesterClass($this->_baseUri, $sdkKey, $options); diff --git a/tests/LDClientTest.php b/tests/LDClientTest.php index 8487e0ca5..3a1492962 100644 --- a/tests/LDClientTest.php +++ b/tests/LDClientTest.php @@ -17,7 +17,7 @@ public function testDefaultCtor() { public function testToggleDefault() { MockFeatureRequester::$val = null; $client = new LDClient("someKey", array( - 'feature_requester_class' => '\\LaunchDarkly\Tests\\MockFeatureRequester', + 'feature_requester_class' => MockFeatureRequester::class, 'events' => false )); @@ -29,7 +29,7 @@ public function testToggleDefault() { public function testToggleFromArray() { MockFeatureRequester::$val = null; $client = new LDClient("someKey", array( - 'feature_requester_class' => '\\LaunchDarkly\Tests\\MockFeatureRequester', + 'feature_requester_class' => MockFeatureRequester::class, 'events' => false, 'defaults' => array('foo' => 'fromarray') )); @@ -42,7 +42,7 @@ public function testToggleFromArray() { public function testToggleEvent() { MockFeatureRequester::$val = null; $client = new LDClient("someKey", array( - 'feature_requester_class' => '\\LaunchDarkly\Tests\\MockFeatureRequester', + 'feature_requester_class' => MockFeatureRequester::class, 'events' => true )); @@ -56,7 +56,7 @@ public function testToggleEvent() { public function testOnlyValidFeatureRequester() { $this->setExpectedException(InvalidArgumentException::class); - new LDClient("BOGUS_SDK_KEY", ['feature_requester_class' => 'stdClass']); + new LDClient("BOGUS_SDK_KEY", ['feature_requester_class' => \stdClass::class]); } public function testSecureModeHash() {