Esempio n. 1
0
 public function testPaging()
 {
     CM_Model_Splitfeature::createStatic(array('name' => 'foo', 'percentage' => 50));
     CM_Model_Splitfeature::createStatic(array('name' => 'bar', 'percentage' => 10));
     $paging = new CM_Paging_Splitfeature_All();
     $this->assertInstanceOf('CM_Model_Splitfeature', $paging->getItem(0));
     $this->assertSame(2, count($paging->getItems()));
     CM_Model_Splitfeature::createStatic(array('name' => 'foobar', 'percentage' => 30));
     $splitfeature = CM_Model_Splitfeature::createStatic(array('name' => 'foofoobar', 'percentage' => 88));
     $paging = new CM_Paging_Splitfeature_All();
     $this->assertSame(4, count($paging->getItems()));
     $splitfeature->delete();
     $paging = new CM_Paging_Splitfeature_All();
     $this->assertSame(3, count($paging->getItems()));
 }
Esempio n. 2
0
 /**
  * @param string $itemRaw
  * @return CM_Model_Splitfeature
  */
 protected function _processItem($itemRaw)
 {
     return CM_Model_Splitfeature::factory($itemRaw);
 }
Esempio n. 3
0
 /**
  * @param CM_Model_User[]       $userList
  * @param CM_Model_Splitfeature $splitfeature
  */
 private function _checkEnabledFlag($userList, CM_Model_Splitfeature $splitfeature)
 {
     foreach ($userList as $key => $user) {
         if ($key % 100 < $splitfeature->getPercentage()) {
             $this->assertTrue($splitfeature->getEnabled($user));
         } else {
             $this->assertFalse($splitfeature->getEnabled($user));
         }
     }
 }