mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-22 18:36:13 +01:00

[FEATURE] Add default sorting by title to the TeaRepository (#14)

This commit is contained in:
Oliver Klee 2018-05-25 17:38:51 +02:00 committed by GitHub
parent 2efde32056
commit 9b10334c0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View file

@ -3,6 +3,7 @@ declare(strict_types = 1);
namespace OliverKlee\Tea\Domain\Repository\Product; namespace OliverKlee\Tea\Domain\Repository\Product;
use OliverKlee\Tea\Domain\Repository\Traits\StoragePageAgnosticTrait; use OliverKlee\Tea\Domain\Repository\Traits\StoragePageAgnosticTrait;
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
use TYPO3\CMS\Extbase\Persistence\Repository; use TYPO3\CMS\Extbase\Persistence\Repository;
/** /**
@ -13,4 +14,9 @@ use TYPO3\CMS\Extbase\Persistence\Repository;
class TeaRepository extends Repository class TeaRepository extends Repository
{ {
use StoragePageAgnosticTrait; use StoragePageAgnosticTrait;
/**
* @var string[]
*/
protected $defaultOrderings = ['title' => QueryInterface::ORDER_ASCENDING];
} }

View file

@ -6,4 +6,10 @@
<title>Earl Grey</title> <title>Earl Grey</title>
<description>Fresh and hot.</description> <description>Fresh and hot.</description>
</tx_tea_domain_model_product_tea> </tx_tea_domain_model_product_tea>
<tx_tea_domain_model_product_tea>
<uid>2</uid>
<pid>1</pid>
<title>Assam</title>
<description>Dark ans strong.</description>
</tx_tea_domain_model_product_tea>
</dataset> </dataset>

View file

@ -56,6 +56,19 @@ class TeaRepositoryTest extends FunctionalTestCase
static::assertGreaterThanOrEqual(1, \count($container)); static::assertGreaterThanOrEqual(1, \count($container));
} }
/**
* @test
*/
public function findAllSortsByTitleInAscendingOrder()
{
$this->importDataSet(__DIR__ . '/../Fixtures/Product/Tea.xml');
$container = $this->subject->findAll();
$container->rewind();
static::assertSame(2, $container->current()->getUid());
}
/** /**
* @test * @test
*/ */