public function testSetUserForRequestClient_usersFromSameClientGetSameVariation()
 {
     /** @var CM_Model_Splittest_RequestClient_Mock $splittestRequestClient */
     $splittestRequestClient = CM_Model_Splittest_RequestClient_Mock::create('foo', range(1, 100));
     /** @var CM_Model_Splittest_User_Mock $splittestUser */
     $splittestUser = CM_Model_Splittest_User_Mock::findId($splittestRequestClient->getId());
     $request1 = new CM_Http_Request_Post('/foo/null');
     $variationRequest1 = $splittestRequestClient->getVariationFixture($request1);
     $userA = CMTest_TH::createUser();
     CM_Splittest_Fixture::setUserForRequestClient($request1, $userA);
     $this->assertSame($variationRequest1, $splittestUser->getVariationFixture($userA));
     for ($i = 0; $i < 10; $i++) {
         $userNew = CMTest_TH::createUser();
         CM_Splittest_Fixture::setUserForRequestClient($request1, $userNew);
         $this->assertSame($variationRequest1, $splittestUser->getVariationFixture($userNew));
     }
     $this->assertSame($variationRequest1, $splittestUser->getVariationFixture($userA));
     $splittestRequestClient->delete();
     CMTest_TH::clearCache();
 }
Beispiel #2
0
 /**
  * @param CM_Model_User $user
  */
 public function setUser(CM_Model_User $user)
 {
     $user->setOnline(true);
     $this->set('userId', $user->getId());
     $this->regenerateId();
     if ($request = $this->getRequest()) {
         CM_Splittest_Fixture::setUserForRequestClient($request, $user);
         $user->getUseragents()->addFromRequest($request);
     }
 }
Beispiel #3
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));
 }
Beispiel #4
0
 public function trackSplittest(CM_Splittest_Fixture $fixture, CM_Model_SplittestVariation $variation)
 {
     $nameSplittest = $variation->getSplittest()->getName();
     $nameVariation = $variation->getName();
     switch ($fixture->getFixtureType()) {
         case CM_Splittest_Fixture::TYPE_REQUEST_CLIENT:
             $this->setRequestClientId($fixture->getId());
             break;
         case CM_Splittest_Fixture::TYPE_USER:
             $this->setUserId($fixture->getId());
             break;
     }
     $trackEventJob = new CMService_KissMetrics_TrackPropertyListJob();
     $trackEventJob->queue(array('code' => $this->_getCode(), 'identityList' => $this->_getIdentityList(), 'propertyList' => array('Splittest ' . $nameSplittest => $nameVariation)));
 }
Beispiel #5
0
 /**
  * @param CM_Splittest_Fixture $fixture
  * @return string
  */
 protected static function _getCacheKeyFixture(CM_Splittest_Fixture $fixture)
 {
     return CM_CacheConst::Splittest_VariationFixtures . '_id:' . $fixture->getId() . '_type:' . $fixture->getFixtureType();
 }