mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-22 03:36:10 +01:00
Do not fetch dates without available event
This commit is contained in:
parent
637c238372
commit
96a650c5aa
8 changed files with 150 additions and 21 deletions
|
@ -44,7 +44,9 @@ class DateRepository extends Repository
|
|||
protected function createDemandQuery(DateDemand $demand): QueryInterface
|
||||
{
|
||||
$query = $this->createQuery();
|
||||
$constraints = [];
|
||||
$constraints = [
|
||||
$this->createEventConstraint($query),
|
||||
];
|
||||
|
||||
$categoriesConstraint = $this->createCategoryConstraint($query, $demand);
|
||||
if ($categoriesConstraint instanceof ConstraintInterface) {
|
||||
|
@ -122,9 +124,7 @@ class DateRepository extends Repository
|
|||
$query->setLimit((int) $demand->getLimit());
|
||||
}
|
||||
|
||||
if (!empty($constraints)) {
|
||||
$query->matching($query->logicalAnd($constraints));
|
||||
}
|
||||
|
||||
$query->setOrderings([$demand->getSortBy() => $demand->getSortOrder()]);
|
||||
|
||||
|
@ -233,4 +233,13 @@ class DateRepository extends Repository
|
|||
|
||||
return $statement->execute()->fetchAll();
|
||||
}
|
||||
|
||||
private function createEventConstraint(
|
||||
QueryInterface $query
|
||||
): ConstraintInterface {
|
||||
return $query->logicalAnd(
|
||||
// Use sub property to trigger join and pulling in event table constraints (hidden)
|
||||
$query->logicalNot($query->equals('event.uid', null))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
33
Documentation/Changelog/2.6.3.rst
Normal file
33
Documentation/Changelog/2.6.3.rst
Normal file
|
@ -0,0 +1,33 @@
|
|||
2.6.3
|
||||
=====
|
||||
|
||||
Breaking
|
||||
--------
|
||||
|
||||
Nothing
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
Nothing
|
||||
|
||||
Fixes
|
||||
-----
|
||||
|
||||
* Do not fetch dates without available event
|
||||
|
||||
As dates don't make sense without an available event.
|
||||
The event provides necessary info like the title.
|
||||
Events might be hidden within system, while dates are still available.
|
||||
|
||||
Relates: #10075
|
||||
|
||||
Tasks
|
||||
-----
|
||||
|
||||
Nothing
|
||||
|
||||
Deprecation
|
||||
-----------
|
||||
|
||||
Nothing
|
87
Tests/Functional/Frontend/DatesTest.php
Normal file
87
Tests/Functional/Frontend/DatesTest.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Copyright (C) 2022 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* 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 Wrm\Events\Tests\Functional\Frontend;
|
||||
|
||||
use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
|
||||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
|
||||
use Wrm\Events\Frontend\Daest;
|
||||
|
||||
/**
|
||||
* @covers \Wrm\Events\Frontend\Daest
|
||||
*/
|
||||
class DatesTest extends FunctionalTestCase
|
||||
{
|
||||
protected $testExtensionsToLoad = [
|
||||
'typo3conf/ext/events',
|
||||
];
|
||||
|
||||
protected $coreExtensionsToLoad = [
|
||||
'fluid_styled_content',
|
||||
];
|
||||
|
||||
protected $pathsToProvideInTestInstance = [
|
||||
'typo3conf/ext/events/Tests/Functional/Frontend/Fixtures/Sites/' => 'typo3conf/sites',
|
||||
];
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->importCSVDataSet(__DIR__ . '/Fixtures/Database/SiteStructure.csv');
|
||||
$this->setUpFrontendRootPage(1, [
|
||||
'constants' => [
|
||||
'EXT:events/Configuration/TypoScript/constants.typoscript',
|
||||
],
|
||||
'setup' => [
|
||||
'EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript',
|
||||
'EXT:events/Configuration/TypoScript/setup.typoscript',
|
||||
'EXT:events/Tests/Functional/Frontend/Fixtures/TypoScript/Rendering.typoscript'
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Covers issue https://redmine.werkraum-media.de/issues/10075.
|
||||
* Editors can disable events. Dates will still be available.
|
||||
* Dates don't make any sense without an event, as they not even have a name.
|
||||
*
|
||||
* They therefore should not be fetched from persistence.
|
||||
*
|
||||
* @test
|
||||
*/
|
||||
public function returnsOnlyDatesWithAvailableEventByDemand(): void
|
||||
{
|
||||
$this->importCSVDataSet(__DIR__ . '/DatesTestFixtures/ReturnsOnlyDatesWithAvailableEventByDemand.csv');
|
||||
|
||||
$request = new InternalRequest();
|
||||
$request = $request->withPageId(1);
|
||||
$response = $this->executeFrontendRequest($request);
|
||||
|
||||
self::assertSame(200, $response->getStatusCode());
|
||||
$html = (string) $response->getBody();
|
||||
|
||||
self::assertStringNotContainsString('Event 1 hidden', $html);
|
||||
self::assertStringContainsString('Event 2 visible', $html);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
tt_content
|
||||
,uid,pid,CType,list_type,header
|
||||
,1,1,list,events_datelist,All Dates
|
||||
tx_events_domain_model_event
|
||||
,uid,pid,title,hidden
|
||||
,1,2,Event 1 hidden,1
|
||||
,2,2,Event 2 visible,0
|
||||
tx_events_domain_model_date
|
||||
,uid,pid,event,start,end
|
||||
,1,2,1,1662458400,1662469200
|
||||
,2,2,2,1662458400,1662469200
|
|
|
@ -29,7 +29,7 @@ class FilterTest extends FunctionalTestCase
|
|||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->importDataSet('EXT:events/Tests/Functional/Frontend/Fixtures/Database/SiteStructure.xml');
|
||||
$this->importCSVDataSet(__DIR__ . '/Fixtures/Database/SiteStructure.csv');
|
||||
$this->setUpFrontendRootPage(1, [
|
||||
'constants' => [
|
||||
'EXT:events/Configuration/TypoScript/constants.typoscript',
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
pages
|
||||
,uid,pid,title,slug
|
||||
,1,0,Page 1,/
|
||||
,2,1,Storage,/storage
|
|
|
@ -1,15 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<dataset>
|
||||
<pages>
|
||||
<pid>0</pid>
|
||||
<uid>1</uid>
|
||||
<title>Page 1</title>
|
||||
<slug>/</slug>
|
||||
</pages>
|
||||
<pages>
|
||||
<pid>1</pid>
|
||||
<uid>2</uid>
|
||||
<title>Storage</title>
|
||||
<slug>/storage</slug>
|
||||
</pages>
|
||||
</dataset>
|
|
@ -9,7 +9,7 @@ $EM_CONF['events'] = [
|
|||
'state' => 'alpha',
|
||||
'createDirs' => '',
|
||||
'clearCacheOnLoad' => 0,
|
||||
'version' => '2.6.2',
|
||||
'version' => '2.6.3',
|
||||
'constraints' => [
|
||||
'depends' => [
|
||||
'typo3' => '10.4.00-11.5.99',
|
||||
|
|
Loading…
Reference in a new issue