diff --git a/src/SplitIO/Component/Common/Di.php b/src/SplitIO/Component/Common/Di.php index 270b966e..10a353a2 100644 --- a/src/SplitIO/Component/Common/Di.php +++ b/src/SplitIO/Component/Common/Di.php @@ -1,8 +1,7 @@ container[$key] = $instance; + self::getInstance()->factoryTracker += 1; + return self::getInstance()->factoryTracker; } /** - * @param $key - * @return mixed + * @param \SplitIO\Component\Log\Logger $logger */ - private function getKey($key) + public static function setLogger(Logger $logger) { - return (isset($this->container[$key])) ? $this->container[$key] : null; - } - - /** - * Set an object instance with its key - * @param $key - * @param $instance - */ - public static function set($key, $instance) - { - self::getInstance()->setKey($key, $instance); + if (!isset(self::getInstance()->logger)) { + self::getInstance()->logger = $logger; + return; + } + self::getInstance()->logger->debug("logger was set before, ignoring new instance provided"); } /** - * Given a key returns the object instance associated with this. - * @param $key - * @return mixed + * @return \SplitIO\Component\Log\Logger */ - public static function get($key) + public static function getLogger() { - return self::getInstance()->getKey($key); + if (!isset(self::getInstance()->logger)) { + throw new Exception("logger was not set yet"); + } + return self::getInstance()->logger; } - /** - * @param LoggerInterface $logger + * @param string $ip */ - public static function setLogger($logger) + public static function setIPAddress(string $ip) { - self::set(self::KEY_LOG, $logger); + if (empty(self::getInstance()->ipAddress)) { + self::getInstance()->ipAddress = $ip; + return; + } + self::getInstance()->getLogger()->debug("IPAddress was set before, ignoring new instance provided"); } /** - * @return null|\Psr\Log\LoggerInterface + * @return string */ - public static function getLogger() + public static function getIPAddress() { - return self::get(self::KEY_LOG); + return self::getInstance()->ipAddress; } } diff --git a/src/SplitIO/Component/Common/ServiceProvider.php b/src/SplitIO/Component/Common/ServiceProvider.php deleted file mode 100644 index c792de67..00000000 --- a/src/SplitIO/Component/Common/ServiceProvider.php +++ /dev/null @@ -1,10 +0,0 @@ -critical("Factory Instantiation: creating multiple factories is not possible. " - . "You have already created a factory."); - return true; - */ - return false; + \SplitIO\Component\Common\Di::setIPAddress($ip); } /** @@ -118,6 +96,10 @@ private static function instanceExists() */ private static function registerInstance() { - Di::set(Di::KEY_FACTORY_TRACKER, true); + if (Di::trackFactory() > 1) { + Di::getLogger()->warning("Factory Instantiation: You already have an instance of the Split factory. " + . "Make sure you definitely want this additional instance. We recommend keeping only one instance of " + . "the factory at all times (Singleton pattern) and reusing it throughout your application."); + } } } diff --git a/src/SplitIO/functions.php b/src/SplitIO/functions.php index 0ef2da0f..489b6a8c 100644 --- a/src/SplitIO/functions.php +++ b/src/SplitIO/functions.php @@ -1,7 +1,6 @@ getMock(); - Di::set(Di::KEY_LOG, $logger); + ReflectiveTools::overrideLogger($logger); return $logger; } diff --git a/tests/Suite/Attributes/SdkAttributesTest.php b/tests/Suite/Attributes/SdkAttributesTest.php index 6b3e050c..6678b17d 100644 --- a/tests/Suite/Attributes/SdkAttributesTest.php +++ b/tests/Suite/Attributes/SdkAttributesTest.php @@ -13,8 +13,6 @@ class SdkAttributesTest extends \PHPUnit\Framework\TestCase { public function testClient() { - Di::set(Di::KEY_FACTORY_TRACKER, false); - //Testing version string $this->assertTrue(is_string(\SplitIO\version())); diff --git a/tests/Suite/Component/TrafficTypeTests.php b/tests/Suite/Component/TrafficTypeTests.php index 69e5c781..fc169461 100644 --- a/tests/Suite/Component/TrafficTypeTests.php +++ b/tests/Suite/Component/TrafficTypeTests.php @@ -17,7 +17,7 @@ private function getMockedLogger() 'alert', 'notice', 'write', 'log')) ->getMock(); - Di::set(Di::KEY_LOG, $logger); + Di::setLogger($logger); return $logger; } diff --git a/tests/Suite/DynamicConfigurations/EvaluatorTest.php b/tests/Suite/DynamicConfigurations/EvaluatorTest.php index 93b3388e..4face6ad 100644 --- a/tests/Suite/DynamicConfigurations/EvaluatorTest.php +++ b/tests/Suite/DynamicConfigurations/EvaluatorTest.php @@ -4,7 +4,6 @@ use SplitIO\Test\Suite\Redis\ReflectiveTools; use SplitIO\Component\Cache\SplitCache; use SplitIO\Component\Cache\SegmentCache; -use SplitIO\Split as SplitApp; use SplitIO\Grammar\Split; use SplitIO\Sdk\Evaluator; diff --git a/tests/Suite/DynamicConfigurations/SplitTest.php b/tests/Suite/DynamicConfigurations/SplitTest.php index 493bb9ce..c946725d 100644 --- a/tests/Suite/DynamicConfigurations/SplitTest.php +++ b/tests/Suite/DynamicConfigurations/SplitTest.php @@ -4,7 +4,6 @@ use SplitIO\Component\Common\Di; use SplitIO\Test\Suite\Redis\ReflectiveTools; use SplitIO\Component\Cache\SplitCache; -use SplitIO\Split as SplitApp; use SplitIO\Grammar\Split; class SplitTest extends \PHPUnit\Framework\TestCase diff --git a/tests/Suite/Engine/HashTest.php b/tests/Suite/Engine/HashTest.php index c31fc6b7..ea0ff26c 100644 --- a/tests/Suite/Engine/HashTest.php +++ b/tests/Suite/Engine/HashTest.php @@ -8,7 +8,6 @@ use SplitIO\Engine\Hash\HashAlgorithmEnum; use SplitIO\Grammar\Split; use SplitIO\Test\Suite\Redis\ReflectiveTools; -use SplitIO\Split as SplitApp; use SplitIO\Component\Common\Di; use SplitIO\Test\Utils; @@ -80,8 +79,6 @@ public function testMurmur3HashFunction() public function testAlgoField() { - Di::set(Di::KEY_FACTORY_TRACKER, false); - $parameters = array('scheme' => 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array('prefix' => TEST_PREFIX); diff --git a/tests/Suite/Engine/SplitterTest.php b/tests/Suite/Engine/SplitterTest.php index 4febbe73..36655a22 100644 --- a/tests/Suite/Engine/SplitterTest.php +++ b/tests/Suite/Engine/SplitterTest.php @@ -17,7 +17,7 @@ class SplitterTest extends \PHPUnit\Framework\TestCase public function testDiLog() { $logger = LoggerFactory::setupLogger(array('adapter' => 'stdout', 'level' => 'error')); - ServiceProvider::registerLogger($logger); + Di::setLogger($logger); $this->assertTrue(true); } diff --git a/tests/Suite/InputValidation/FactoryTrackerTest.php b/tests/Suite/InputValidation/FactoryTrackerTest.php index e0066aca..5776afbf 100644 --- a/tests/Suite/InputValidation/FactoryTrackerTest.php +++ b/tests/Suite/InputValidation/FactoryTrackerTest.php @@ -1,7 +1,7 @@ getMock(); - Di::set(Di::KEY_LOG, $logger); + ReflectiveTools::overrideLogger($logger); return $logger; } public function testMultipleClientInstantiation() { - // @TODO FIX WHEN WE ALLOW MULTIPLE - /* - Di::set(Di::KEY_FACTORY_TRACKER, false); $splitFactory = $this->getFactoryClient(); $this->assertNotNull($splitFactory->client()); $logger = $this->getMockedLogger(); $logger->expects($this->once()) - ->method('critical') - ->with($this->equalTo("Factory Instantiation: creating multiple factories is not possible. " - . "You have already created a factory.")); + ->method('warning') + ->with($this->equalTo("Factory Instantiation: You already have an instance of the Split factory. " + . "Make sure you definitely want this additional instance. We recommend keeping only one instance " + . "of the factory at all times (Singleton pattern) and reusing it throughout your application.")); $splitFactory2 = $this->getFactoryClient(); - $this->assertEquals(null, $splitFactory2); - */ - $this->assertEquals(true, true); + $this->assertNotNull($splitFactory2->client()); } } diff --git a/tests/Suite/InputValidation/GetTreatmentValidationTest.php b/tests/Suite/InputValidation/GetTreatmentValidationTest.php index 312ab2ac..4942ed6d 100644 --- a/tests/Suite/InputValidation/GetTreatmentValidationTest.php +++ b/tests/Suite/InputValidation/GetTreatmentValidationTest.php @@ -1,7 +1,7 @@ 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array('prefix' => TEST_PREFIX); @@ -36,7 +35,7 @@ private function getMockedLogger() 'alert', 'notice', 'write', 'log')) ->getMock(); - Di::set(Di::KEY_LOG, $logger); + ReflectiveTools::overrideLogger($logger); return $logger; } diff --git a/tests/Suite/InputValidation/GetTreatmentsValidationTest.php b/tests/Suite/InputValidation/GetTreatmentsValidationTest.php index 7e8d9da6..dfb2be12 100644 --- a/tests/Suite/InputValidation/GetTreatmentsValidationTest.php +++ b/tests/Suite/InputValidation/GetTreatmentsValidationTest.php @@ -1,8 +1,8 @@ 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array('prefix' => TEST_PREFIX); @@ -36,7 +35,7 @@ private function getMockedLogger() 'alert', 'notice', 'write', 'log')) ->getMock(); - Di::set(Di::KEY_LOG, $logger); + ReflectiveTools::overrideLogger($logger); return $logger; } diff --git a/tests/Suite/InputValidation/ManagerValidationTest.php b/tests/Suite/InputValidation/ManagerValidationTest.php index 77ef7bb9..09020a0f 100644 --- a/tests/Suite/InputValidation/ManagerValidationTest.php +++ b/tests/Suite/InputValidation/ManagerValidationTest.php @@ -1,13 +1,12 @@ 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array('prefix' => TEST_PREFIX); @@ -33,7 +32,7 @@ private function getMockedLogger() 'alert', 'notice', 'write', 'log')) ->getMock(); - Di::set(Di::KEY_LOG, $logger); + ReflectiveTools::overrideLogger($logger); return $logger; } diff --git a/tests/Suite/InputValidation/TrackValidationTest.php b/tests/Suite/InputValidation/TrackValidationTest.php index e42bb603..9f66e586 100644 --- a/tests/Suite/InputValidation/TrackValidationTest.php +++ b/tests/Suite/InputValidation/TrackValidationTest.php @@ -1,7 +1,7 @@ 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array('prefix' => TEST_PREFIX); @@ -36,7 +35,7 @@ private function getMockedLogger() 'alert', 'notice', 'write', 'log')) ->getMock(); - Di::set(Di::KEY_LOG, $logger); + ReflectiveTools::overrideLogger($logger); return $logger; } diff --git a/tests/Suite/Matchers/MatchersTest.php b/tests/Suite/Matchers/MatchersTest.php index 79bcaf6d..b48990d1 100644 --- a/tests/Suite/Matchers/MatchersTest.php +++ b/tests/Suite/Matchers/MatchersTest.php @@ -19,7 +19,6 @@ class MatcherTest extends \PHPUnit\Framework\TestCase private function setupSplitApp() { - Di::set(Di::KEY_FACTORY_TRACKER, false); $parameters = array( 'scheme' => 'redis', 'host' => "localhost", diff --git a/tests/Suite/Redis/ReflectiveTools.php b/tests/Suite/Redis/ReflectiveTools.php index 879d17f4..d128e510 100644 --- a/tests/Suite/Redis/ReflectiveTools.php +++ b/tests/Suite/Redis/ReflectiveTools.php @@ -3,6 +3,7 @@ namespace SplitIO\Test\Suite\Redis; use ReflectionClass; +use SplitIO\Component\Common\Di; class ReflectiveTools { @@ -54,4 +55,22 @@ public static function clientFromCachePool(\SplitIO\Component\Cache\Pool $cacheP $reflectionClient->setAccessible(true); return $reflectionClient->getValue($adapter); } + + public static function overrideLogger($logger) + { + $di = Di::getInstance(); + $reflection = new \ReflectionClass('SplitIO\Component\Common\Di'); + $property = $reflection->getProperty('logger'); + $property->setAccessible(true); + $property->setValue($di, $logger); + } + + public static function resetIPAddress() + { + $di = Di::getInstance(); + $reflection = new \ReflectionClass('SplitIO\Component\Common\Di'); + $property = $reflection->getProperty('ipAddress'); + $property->setAccessible(true); + $property->setValue($di, ""); + } } diff --git a/tests/Suite/Sdk/ImpressionWrapperTest.php b/tests/Suite/Sdk/ImpressionWrapperTest.php index 10d45d83..e2e79e19 100644 --- a/tests/Suite/Sdk/ImpressionWrapperTest.php +++ b/tests/Suite/Sdk/ImpressionWrapperTest.php @@ -8,7 +8,7 @@ use SplitIO\Test\Suite\Sdk\Helpers\ListenerClient; use SplitIO\Test\Suite\Sdk\Helpers\ListenerClientWithException; use SplitIO\Test\Suite\Sdk\Helpers\ListenerClientWrong; -use SplitIO\Component\Common\Di; +use SplitIO\Test\Suite\Redis\ReflectiveTools; use SplitIO\Test\Utils; @@ -42,7 +42,6 @@ public function testSendDataToClient() private function getFactoryClient($sdkConfig) { - Di::set(Di::KEY_FACTORY_TRACKER, false); $parameters = array('scheme' => 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array(); @@ -121,6 +120,7 @@ public function testClient() $impressionClient = new ListenerClient(); + ReflectiveTools::resetIPAddress(); $sdkConfig = array( 'log' => array('adapter' => 'stdout'), 'impressionListener' => $impressionClient, @@ -162,6 +162,7 @@ public function testClientWithEmptyIpAddress() $impressionClient3 = new ListenerClient(); + ReflectiveTools::resetIPAddress(); $sdkConfig = array( 'log' => array('adapter' => 'stdout'), 'impressionListener' => $impressionClient3, @@ -194,6 +195,7 @@ public function testClientWithEmptyStringIpAddress() $impressionClient4 = new ListenerClient(); + ReflectiveTools::resetIPAddress(); $sdkConfig = array( 'log' => array('adapter' => 'stdout'), 'impressionListener' => $impressionClient4, @@ -226,6 +228,7 @@ public function testClientErasingServer() $impressionClient4 = new ListenerClient(); + ReflectiveTools::resetIPAddress(); $sdkConfig = array( 'log' => array('adapter' => 'stdout'), 'impressionListener' => $impressionClient4, diff --git a/tests/Suite/Sdk/ImpressionsTest.php b/tests/Suite/Sdk/ImpressionsTest.php index 0fe731ab..9fb1c182 100644 --- a/tests/Suite/Sdk/ImpressionsTest.php +++ b/tests/Suite/Sdk/ImpressionsTest.php @@ -13,7 +13,6 @@ class ImpressionsTest extends \PHPUnit\Framework\TestCase { public function testImpressionsAreAdded() { - Di::set(Di::KEY_FACTORY_TRACKER, false); $parameters = array('scheme' => 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array('prefix' => TEST_PREFIX); @@ -63,7 +62,6 @@ public function testImpressionsAreAdded() public function testExpirationOnlyOccursOnce() { - Di::set(Di::KEY_FACTORY_TRACKER, false); $parameters = array('scheme' => 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array('prefix' => TEST_PREFIX); diff --git a/tests/Suite/Sdk/SdkClientTest.php b/tests/Suite/Sdk/SdkClientTest.php index 3cb64311..844c8e7d 100644 --- a/tests/Suite/Sdk/SdkClientTest.php +++ b/tests/Suite/Sdk/SdkClientTest.php @@ -2,7 +2,6 @@ namespace SplitIO\Test\Suite\Sdk; use \stdClass; -use SplitIO\Component\Common\Di; use SplitIO\Test\Suite\Redis\ReflectiveTools; use SplitIO\Component\Cache\ImpressionCache; use SplitIO\Component\Cache\EventsCache; @@ -20,7 +19,6 @@ class SdkClientTest extends \PHPUnit\Framework\TestCase { public function testLocalClient() { - Di::set(Di::KEY_FACTORY_TRACKER, false); $options['splitFile'] = dirname(dirname(__DIR__)).'/files/.splits'; $splitFactory = \SplitIO\Sdk::factory('localhost', $options); $splitSdk = $splitFactory->client(); @@ -37,7 +35,6 @@ public function testLocalClient() public function testLocalClientYAML() { - Di::set(Di::KEY_FACTORY_TRACKER, false); $options['splitFile'] = dirname(dirname(__DIR__)).'/files/splits.yml'; $splitFactory = \SplitIO\Sdk::factory('localhost', $options); $splitSdk = $splitFactory->client(); @@ -210,7 +207,6 @@ private function validateLastImpression( public function testClient() { - Di::set(Di::KEY_FACTORY_TRACKER, false); //Testing version string $this->assertTrue(is_string(\SplitIO\version())); @@ -441,7 +437,6 @@ public function testClient() */ public function testCustomLog() { - Di::set(Di::KEY_FACTORY_TRACKER, false); // create a log channel $log = $this ->getMockBuilder('Psr\Log\LoggerInterface') @@ -477,7 +472,6 @@ public function testCustomLog() public function testInvalidCacheAdapter() { - Di::set(Di::KEY_FACTORY_TRACKER, false); $this->expectException('\SplitIO\Exception\Exception'); $sdkConfig = array( @@ -491,8 +485,6 @@ public function testInvalidCacheAdapter() public function testCacheExceptionReturnsControl() { - Di::set(Di::KEY_FACTORY_TRACKER, false); - $log = $this ->getMockBuilder('Psr\Log\LoggerInterface') ->disableOriginalConstructor() @@ -531,7 +523,6 @@ public function testCacheExceptionReturnsControl() public function testGetTreatmentsWithDistinctFeatures() { - Di::set(Di::KEY_FACTORY_TRACKER, false); //Testing version string $this->assertTrue(is_string(\SplitIO\version())); @@ -568,14 +559,13 @@ public function testGetTreatmentsWithDistinctFeatures() public function testGetTreatmentsWithRepeteadedFeatures() { - Di::set(Di::KEY_FACTORY_TRACKER, false); - //Testing version string $this->assertTrue(is_string(\SplitIO\version())); $parameters = array('scheme' => 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array('prefix' => TEST_PREFIX); + ReflectiveTools::resetIPAddress(); $sdkConfig = array( 'log' => array('adapter' => 'stdout'), 'cache' => array('adapter' => 'predis', 'parameters' => $parameters, 'options' => $options), @@ -607,18 +597,17 @@ public function testGetTreatmentsWithRepeteadedFeatures() public function testGetTreatmentsWithRepeteadedAndNullFeatures() { - Di::set(Di::KEY_FACTORY_TRACKER, false); - Di::set('ipAddress', null); // unset ipaddress from previous test - //Testing version string $this->assertTrue(is_string(\SplitIO\version())); $parameters = array('scheme' => 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array('prefix' => TEST_PREFIX); + ReflectiveTools::resetIPAddress(); $sdkConfig = array( 'log' => array('adapter' => 'stdout'), - 'cache' => array('adapter' => 'predis', 'parameters' => $parameters, 'options' => $options) + 'cache' => array('adapter' => 'predis', 'parameters' => $parameters, 'options' => $options), + 'ipAddress' => '' ); //Initializing the SDK instance. @@ -691,6 +680,67 @@ public function testGetTreatmentsFetchesSplitsInOneCall() $client->getTreatments('key1', array('split1', 'split2', 'split3')); } + public function testMultipleInstantiationNotOverrideIP() + { + //Testing version string + $this->assertTrue(is_string(\SplitIO\version())); + + $parameters = array('scheme' => 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); + $options = array('prefix' => TEST_PREFIX); + + ReflectiveTools::resetIPAddress(); + $sdkConfig = array( + 'log' => array('adapter' => 'stdout'), + 'cache' => array('adapter' => 'predis', 'parameters' => $parameters, 'options' => $options), + 'ipAddress' => '1.2.3.4' + ); + + //Initializing the SDK instance. + $splitFactory = \SplitIO\Sdk::factory('asdqwe123456', $sdkConfig); + $splitSdk = $splitFactory->client(); + + //Populating the cache. + Utils\Utils::addSplitsInCache(file_get_contents(__DIR__."/files/splitChanges.json")); + Utils\Utils::addSegmentsInCache(file_get_contents(__DIR__."/files/segmentEmployeesChanges.json")); + Utils\Utils::addSegmentsInCache(file_get_contents(__DIR__."/files/segmentHumanBeignsChanges.json")); + + $treatmentResult = $splitSdk->getTreatments('user1', array('sample_feature', 'invalid_feature', + 'sample_feature', 'sample_feature'), null); + + //Assertions + $this->assertEquals(2, count(array_keys($treatmentResult))); + + $this->assertEquals('on', $treatmentResult['sample_feature']); + $this->assertEquals('control', $treatmentResult['invalid_feature']); + + // Check impressions + $redisClient = ReflectiveTools::clientFromFactory($splitFactory); + $this->validateLastImpression($redisClient, 'sample_feature', 'user1', 'on', 'ip-1-2-3-4', '1.2.3.4'); + + $sdkConfig = array( + 'log' => array('adapter' => 'stdout'), + 'cache' => array('adapter' => 'predis', 'parameters' => $parameters, 'options' => $options), + 'ipAddress' => '1.2.3.4.5' + ); + + //Initializing the SDK instance. + $splitFactory2 = \SplitIO\Sdk::factory('asdqwe123456', $sdkConfig); + $splitSdk2 = $splitFactory2->client(); + + $treatmentResult2 = $splitSdk2->getTreatments('user1', array('sample_feature', 'invalid_feature', + 'sample_feature', 'sample_feature'), null); + + //Assertions + $this->assertEquals(2, count(array_keys($treatmentResult2))); + + $this->assertEquals('on', $treatmentResult2['sample_feature']); + $this->assertEquals('control', $treatmentResult2['invalid_feature']); + + // Check impressions + $redisClient = ReflectiveTools::clientFromFactory($splitFactory2); + $this->validateLastImpression($redisClient, 'sample_feature', 'user1', 'on', 'ip-1-2-3-4', '1.2.3.4'); + } + public static function tearDownAfterClass(): void { Utils\Utils::cleanCache(); diff --git a/tests/Suite/Sdk/SdkReadOnlyTest.php b/tests/Suite/Sdk/SdkReadOnlyTest.php index 01885856..8153aae9 100644 --- a/tests/Suite/Sdk/SdkReadOnlyTest.php +++ b/tests/Suite/Sdk/SdkReadOnlyTest.php @@ -18,8 +18,6 @@ class SdkReadOnlyTest extends \PHPUnit\Framework\TestCase { public function testClient() { - Di::set(Di::KEY_FACTORY_TRACKER, false); - $parameters = array('scheme' => 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array('prefix' => TEST_PREFIX); $sdkConfig = array( @@ -54,7 +52,7 @@ public function testClient() $this->equalTo('The SPLIT definition for \'mockedPRedisInvalid\' has not been found') )); - Di::set(Di::KEY_LOG, $logger); + Di::setLogger($logger); $this->assertEquals('on', $splitSdk->getTreatment('valid', 'mockedPRedis')); $this->assertEquals('off', $splitSdk->getTreatment('invalid', 'mockedPRedis')); diff --git a/tests/Suite/TrafficAllocation/TrafficAllocationTest.php b/tests/Suite/TrafficAllocation/TrafficAllocationTest.php index ee5e7af3..78e0ce3a 100644 --- a/tests/Suite/TrafficAllocation/TrafficAllocationTest.php +++ b/tests/Suite/TrafficAllocation/TrafficAllocationTest.php @@ -4,6 +4,7 @@ use SplitIO\Component\Initialization\LoggerFactory; use SplitIO\Component\Common\ServiceProvider; use SplitIO\Grammar\Split; +use SplitIO\Component\Common\Di; class TrafficAllocationTest extends \PHPUnit\Framework\TestCase { @@ -20,7 +21,7 @@ public function testTrafficAllocation() ]); $logger = LoggerFactory::setupLogger(array('adapter' => 'stdout', 'level' => 'error')); - ServiceProvider::registerLogger($logger); + Di::setLogger($logger); $rawSplit = array( 'name' => 'test1',