[TASK] Shorten the extend class in all unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Database / Query / Restriction / AbstractRestrictionTestCase.php
1 <?php
2 declare(strict_types = 1);
3 namespace TYPO3\CMS\Core\Tests\Unit\Database\Query\Restriction;
4
5 /*
6 * This file is part of the TYPO3 CMS project.
7 *
8 * It is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, either version 2
10 * of the License, or any later version.
11 *
12 * For the full copyright and license information, please read the
13 * LICENSE.txt file that was distributed with this source code.
14 *
15 * The TYPO3 project - inspiring people to share!
16 */
17
18 use Prophecy\Argument;
19 use TYPO3\CMS\Core\Database\Connection;
20 use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
21 use TYPO3\CMS\Core\Tests\Unit\Database\Mocks\MockPlatform;
22 use TYPO3\CMS\Core\Utility\GeneralUtility;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24
25 class AbstractRestrictionTestCase extends UnitTestCase
26 {
27 /**
28 * @var \TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
29 */
30 protected $expressionBuilder;
31
32 /**
33 * Create a new database connection mock object for every test.
34 */
35 protected function setUp()
36 {
37 /** @var Connection|\Prophecy\Prophecy\ObjectProphecy $connection */
38 $connection = $this->prophesize(Connection::class);
39 $connection->quoteIdentifier(Argument::cetera())->will(function ($args) {
40 return '"' . implode('"."', explode('.', $args[0])) . '"';
41 });
42 $connection->quote(Argument::cetera())->will(function ($args) {
43 return '\'' . $args[0] . '\'';
44 });
45 $connection->getDatabasePlatform()->willReturn(new MockPlatform());
46
47 $this->expressionBuilder = GeneralUtility::makeInstance(ExpressionBuilder::class, $connection->reveal());
48 }
49 }