public function testClient() { //Testing version string $this->assertTrue(is_string(\SplitIO\version())); $parameters = array('scheme' => 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array(); $sdkConfig = array('log' => array('adapter' => 'stdout'), 'cache' => array('adapter' => 'predis', 'parameters' => $parameters, 'options' => $options)); //Initializing the SDK instance. $splitFactory = \SplitIO\Sdk::factory('asdqwe123456', $sdkConfig); $splitSdk = $splitFactory->client(); //Populating the cache. $this->addSplitsInCache(); $this->addSegmentsInCache(); //Assertions $this->assertEquals('on', $splitSdk->getTreatment('user1', 'sample_feature')); $this->assertEquals('off', $splitSdk->getTreatment('invalidKey', 'sample_feature')); $this->assertEquals('control', $splitSdk->getTreatment('invalidKey', 'invalid_feature')); $this->assertTrue($splitSdk->isTreatment('user1', 'sample_feature', 'on')); $this->assertFalse($splitSdk->isTreatment('user1', 'sample_feature', 'invalid_treatment')); //testing a killed feature. No matter what the key, must return default treatment $this->assertEquals('defTreatment', $splitSdk->getTreatment('invalidKey', 'killed_feature')); //testing ALL matcher $this->assertEquals('on', $splitSdk->getTreatment('invalidKey', 'all_feature')); //testing WHITELIST matcher $this->assertEquals('on', $splitSdk->getTreatment('whitelisted_user', 'whitelist_feature')); $this->assertEquals('off', $splitSdk->getTreatment('unwhitelisted_user', 'whitelist_feature')); }
public function testClient() { //Testing version string $this->assertTrue(is_string(\SplitIO\version())); $parameters = array('scheme' => 'redis', 'host' => REDIS_HOST, 'port' => REDIS_PORT, 'timeout' => 881); $options = array(); $sdkConfig = ['log' => ['adapter' => 'stdout', 'level' => 'info'], 'cache' => array('adapter' => 'predis', 'parameters' => $parameters, 'options' => $options)]; //Initializing the SDK instance. $splitFactory = \SplitIO\Sdk::factory('some-api-key', $sdkConfig); $splitSdk = $splitFactory->client(); //Populating the cache. $this->addSplitsInCache(); $this->addSegmentsInCache(); //Assertions $this->inOperator($splitSdk); $this->equalToOperator($splitSdk); $this->greaterThanOrEqualToOperator($splitSdk); $this->lessThanOrEqualToOperator($splitSdk); $this->betweenOperator($splitSdk); }