* * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ namespace WerkraumMedia\Watchlist\Tests\Functional; use Symfony\Component\HttpFoundation\Cookie; use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest; use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalResponse; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; class BasicsTest extends FunctionalTestCase { protected $coreExtensionsToLoad = [ 'fluid_styled_content', ]; protected $testExtensionsToLoad = [ 'typo3conf/ext/watchlist', 'typo3conf/ext/watchlist/Tests/Fixtures/watchlist_example', ]; protected $pathsToLinkInTestInstance = [ 'typo3conf/ext/watchlist/Tests/Fixtures/Sites' => 'typo3conf/sites', 'typo3conf/ext/watchlist/Tests/Fixtures/Fileadmin/Files' => 'fileadmin/Files', ]; protected function setUp(): void { parent::setUp(); $this->importCSVDataSet(__DIR__ . '/../Fixtures/BasicDatabase.csv'); } /** * @test */ public function watchlistIsRenderedAsEmptyByDefault(): void { $request = new InternalRequest(); $request = $request->withPageId(1); $result = $this->executeFrontendRequest($request); self::assertSame(200, $result->getStatusCode()); self::assertStringContainsString('Watchlist is empty', $result->getBody()->__toString()); } /** * @test */ public function canStorePagesOnWatchlistAccrossPageCalls(): void { $request = new InternalRequest(); $request = $request->withPageId(1); $request = $request->withQueryParameter('tx_watchlist_watchlist[redirectUri]', $request->getUri()->__toString()); $request = $request->withQueryParameter('tx_watchlist_watchlist[action]', 'add'); $request = $request->withQueryParameter('tx_watchlist_watchlist[item]', 'page-1'); $result = $this->executeFrontendRequest($request); self::assertIsRedirect('http://localhost/?id=1', $result); self::assertCookie('page-1', $this->getCookie($result)); $request = new InternalRequest(); $request = $request->withPageId(1); $request = $request->withHeader('Cookie', 'watchlist=page-1'); $result = $this->executeFrontendRequest($request); self::assertMatchesRegularExpression('#