Esempio n. 1
0
 public function testGetColumnId()
 {
     $fixtureRequestClient = new CM_Splittest_Fixture(new CM_Http_Request_Post('/foo/null'));
     $fixtureUser = new CM_Splittest_Fixture(CMTest_TH::createUser());
     $this->assertSame('requestClientId', $fixtureRequestClient->getColumnId());
     $this->assertSame('userId', $fixtureUser->getColumnId());
 }
Esempio n. 2
0
 public function testOutdatedLocalCache()
 {
     $test1 = CM_Model_Splittest_Mock::create('foo', range(1, 10));
     $test2 = CM_Model_Splittest_Mock::create('bar', range(1, 10));
     $mockBuilder = $this->getMockBuilder('CM_Model_User');
     $mockBuilder->setMethods(['getId']);
     $userMock = $mockBuilder->getMock();
     $userMock->expects($this->any())->method('getId')->will($this->returnValue(mt_rand()));
     /** @var CM_Model_User $userMock */
     $fixture = new CM_Splittest_Fixture($userMock);
     CM_Db_Db::insert('cm_splittestVariation_fixture', array('splittestId' => $test1->getId(), $fixture->getColumnId() => $fixture->getId(), 'variationId' => $test1->getVariations()->findByName(1)->getId(), 'createStamp' => time()));
     $this->assertTrue($test1->isVariationFixture($fixture, 1));
     CM_Db_Db::insert('cm_splittestVariation_fixture', array('splittestId' => $test2->getId(), $fixture->getColumnId() => $fixture->getId(), 'variationId' => $test2->getVariations()->findByName(10)->getId(), 'createStamp' => time()));
     $this->assertTrue($test2->isVariationFixture($fixture, 10));
 }
Esempio n. 3
0
    /**
     * @param CM_Splittest_Fixture $fixture
     * @param bool|null            $updateCache
     * @return array
     */
    protected function _getVariationListFixture(CM_Splittest_Fixture $fixture, $updateCache = null)
    {
        $columnId = $fixture->getColumnId();
        $columnIdQuoted = CM_Db_Db::getClient()->quoteIdentifier($columnId);
        $fixtureId = $fixture->getId();
        $updateCache = (bool) $updateCache;
        $cacheKey = self::_getCacheKeyFixture($fixture);
        $cache = CM_Cache_Local::getInstance();
        if ($updateCache || ($variationListFixture = $cache->get($cacheKey)) === false) {
            $variationListFixture = CM_Db_Db::exec('
				SELECT `variation`.`splittestId`, `variation`.`name` AS `variation`, `splittest`.`createStamp` AS `flushStamp`
					FROM `cm_splittestVariation_fixture` `fixture`
					JOIN `cm_splittestVariation` `variation` ON(`variation`.`id` = `fixture`.`variationId`)
					JOIN `cm_splittest` `splittest` ON(`splittest`.`id` = `fixture`.`splittestId`)
					WHERE `fixture`.' . $columnIdQuoted . ' = ?', array($fixtureId))->fetchAllTree();
            $cache->set($cacheKey, $variationListFixture);
        }
        return $variationListFixture;
    }