Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
composer.phar
.vagrant
integration-tests/vendor
integration-tests/composer.lock
composer.lock
1 change: 0 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions integration-tests/LDDFeatureRequesterTest.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?php
namespace LaunchDarkly\Tests;

require_once 'vendor/autoload.php';

use LaunchDarkly\LDClient;
use LaunchDarkly\LDUserBuilder;
use LaunchDarkly\LDDFeatureRequester;
use LaunchDarkly\ApcLDDFeatureRequester;
use Predis\Client;
use LaunchDarkly\ApcuLDDFeatureRequester;

class LDDFeatureRetrieverTest extends \PHPUnit_Framework_TestCase {

public function testGet() {
$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\\LDDFeatureRequester'));
$client = new LDClient("BOGUS_API_KEY", array('feature_requester_class' => LDDFeatureRequester::class));
$builder = new LDUserBuilder(3);
$user = $builder->build();

Expand All @@ -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();
Expand Down Expand Up @@ -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
]);

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 1 addition & 25 deletions integration-tests/bootstrap.user.sh
Original file line number Diff line number Diff line change
@@ -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
30 changes: 0 additions & 30 deletions integration-tests/composer.json

This file was deleted.

4 changes: 2 additions & 2 deletions src/LaunchDarkly/LDClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions tests/LDClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
));

Expand All @@ -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')
));
Expand All @@ -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
));

Expand All @@ -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() {
Expand Down