コード例 #1
0
 /**
  * @param object $entity
  * @param string $resultType
  * @param string $scope
  * @return int|null
  */
 protected function getProcessedIdentifier($entity, $resultType, $scope = EntityPaginationManager::VIEW_SCOPE)
 {
     $entityIds = $this->storage->getEntityIds($entity, $scope);
     $entityId = null;
     switch ($resultType) {
         case self::LAST:
             $entityId = end($entityIds);
             break;
         case self::FIRST:
             $entityId = reset($entityIds);
             break;
         case self::PREVIOUS:
             $currentPosition = $this->storage->getCurrentPosition($entity, $scope);
             if (isset($entityIds[$currentPosition - 1])) {
                 $entityId = $entityIds[$currentPosition - 1];
             }
             break;
         case self::NEXT:
             $currentPosition = $this->storage->getCurrentPosition($entity, $scope);
             if (isset($entityIds[$currentPosition + 1])) {
                 $entityId = $entityIds[$currentPosition + 1];
             }
             break;
     }
     return $entityId;
 }
コード例 #2
0
 /**
  * @param boolean $enabled
  * @param boolean $request
  * @param array $source
  * @param boolean $expected
  *
  * @dataProvider clearDataDataProvider
  */
 public function testClearData($enabled, $request, $source, $expected)
 {
     $this->setEnabled($enabled);
     if (true === $request) {
         $this->setRequest();
     }
     $this->setStorage($source['storage_data']);
     $result = $this->storage->clearData(self::ENTITY_NAME, $source['scope']);
     $viewScopesIds = $this->storage->getEntityIds($this->entity, EntityPaginationManager::VIEW_SCOPE);
     $editScopesIds = $this->storage->getEntityIds($this->entity, EntityPaginationManager::EDIT_SCOPE);
     $this->assertEquals($expected['result'], $result);
     if ($expected['result'] === true) {
         $this->assertEquals($expected['view_scope_ids'], $viewScopesIds);
         $this->assertEquals($expected['edit_scope_ids'], $editScopesIds);
     }
 }