/** * Adds page cache tags by used storagePages. * This adds tags with the scheme tx_news_pid_[news:pid] * * @param \GeorgRinger\News\Domain\Model\Dto\NewsDemand $demand * @return void */ public static function addPageCacheTagsByDemandObject(\GeorgRinger\News\Domain\Model\Dto\NewsDemand $demand) { $cacheTags = array(); if ($demand->getStoragePage()) { // Add cache tags for each storage page foreach (GeneralUtility::trimExplode(',', $demand->getStoragePage()) as $pageId) { $cacheTags[] = 'tx_news_pid_' . $pageId; } } if (count($cacheTags) > 0) { $GLOBALS['TSFE']->addCacheTags($cacheTags); } }
/** * @test */ public function constraintsAreReturnedForDateFields() { $mockedQuery = $this->getMock('TYPO3\\CMS\\Extbase\\Persistence\\QueryInterface'); $mockedRepository = $this->getAccessibleMock('GeorgRinger\\News\\Domain\\Repository\\NewsRepository', ['dummy'], [], '', FALSE); $search = new Search(); $search->setMinimumDate('2014-01-01'); $search->setDateField('datetime'); $demand = new NewsDemand(); $demand->setSearch($search); $result = $mockedRepository->_call('getSearchConstraints', $mockedQuery, $demand); $this->assertEquals(1, count($result)); $search->setMaximumDate('2015-01-01'); $demand->setSearch($search); $result = $mockedRepository->_call('getSearchConstraints', $mockedQuery, $demand); $this->assertEquals(2, count($result)); $search->setMaximumDate('xyz'); $demand->setSearch($search); $result = $mockedRepository->_call('getSearchConstraints', $mockedQuery, $demand); $this->assertEquals(1, count($result)); }
/** * If no limit is set in the settings we fallback to the defaultLimit * setting and if this is empty for the current action we use the * default limit defined in the DEFAULT_LIMIT constant. * * @param \GeorgRinger\News\Domain\Model\Dto\NewsDemand $demand */ protected function initializeDefaultLimitForCurrentActionIfNotSet($demand) { if ($this->settings['limit'] !== '') { return; } $controllerActionName = $this->request->getControllerActionName(); if (isset($this->settings['defaultLimit'][$controllerActionName])) { $demand->setLimit($this->settings['defaultLimit'][$controllerActionName]); } else { $demand->setLimit(static::DEFAULT_LIMIT); } }
/** * @test * @return void */ public function excludeAlreadyDisplayedNewsCanBeSet() { $value = TRUE; $this->instance->setExcludeAlreadyDisplayedNews($value); $this->assertEquals($value, $this->instance->getExcludeAlreadyDisplayedNews()); }
/** * @test */ public function hideIdListCanBeSet() { $value = '123,456'; $this->instance->setHideIdList($value); $this->assertEquals($value, $this->instance->getHideIdList()); }