Skip to content

Commit 3667988

Browse files
authored
Merge pull request #129 from kdambekalns/cleanup-tests
TASK: Clean up and adjust unit tests to PhpUnit 5.4
2 parents a19da10 + 66ace4e commit 3667988

4 files changed

Lines changed: 176 additions & 161 deletions

File tree

Tests/Functional/Eel/ElasticSearchQueryTest.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Command\NodeIndexCommandController;
1515
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQueryBuilder;
1616
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQueryResult;
17+
use TYPO3\Flow\Persistence\QueryResultInterface;
1718
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
1819
use TYPO3\TYPO3CR\Domain\Model\Workspace;
1920
use TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository;
@@ -67,19 +68,20 @@ class ElasticSearchQueryTest extends \TYPO3\Flow\Tests\FunctionalTestCase
6768
*/
6869
protected $nodeDataRepository;
6970

70-
71+
/**
72+
* @var boolean
73+
*/
7174
protected static $indexInitialized = false;
7275

73-
7476
public function setUp()
7577
{
7678
parent::setUp();
77-
$this->workspaceRepository = $this->objectManager->get('TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository');
79+
$this->workspaceRepository = $this->objectManager->get(WorkspaceRepository::class);
7880
$liveWorkspace = new Workspace('live');
7981
$this->workspaceRepository->add($liveWorkspace);
8082

81-
$this->nodeTypeManager = $this->objectManager->get('TYPO3\TYPO3CR\Domain\Service\NodeTypeManager');
82-
$this->contextFactory = $this->objectManager->get('TYPO3\TYPO3CR\Domain\Service\ContextFactoryInterface');
83+
$this->nodeTypeManager = $this->objectManager->get(NodeTypeManager::class);
84+
$this->contextFactory = $this->objectManager->get(ContextFactoryInterface::class);
8385
$this->context = $this->contextFactory->create([
8486
'workspaceName' => 'live',
8587
'dimensions' => ['language' => ['en_US']],
@@ -90,9 +92,9 @@ public function setUp()
9092
$this->siteNode = $rootNode->createNode('welcome', $this->nodeTypeManager->getNodeType('TYPO3.Neos.NodeTypes:Page'));
9193
$this->siteNode->setProperty('title', 'welcome');
9294

93-
$this->nodeDataRepository = $this->objectManager->get('TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository');
95+
$this->nodeDataRepository = $this->objectManager->get(NodeDataRepository::class);
9496

95-
$this->nodeIndexCommandController = $this->objectManager->get('Flowpack\ElasticSearch\ContentRepositoryAdaptor\Command\NodeIndexCommandController');
97+
$this->nodeIndexCommandController = $this->objectManager->get(NodeIndexCommandController::class);
9698

9799
$this->createNodesForNodeSearchTest();
98100
}
@@ -104,12 +106,13 @@ public function tearDown()
104106
}
105107

106108
/**
107-
* @return \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQueryBuilder
109+
* @return ElasticSearchQueryBuilder
108110
*/
109111
protected function getQueryBuilder()
110112
{
111113
/** @var ElasticSearchQueryBuilder $query */
112-
$query = $this->objectManager->get('Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQueryBuilder');
114+
$query = $this->objectManager->get(ElasticSearchQueryBuilder::class);
115+
113116
return $query->query($this->siteNode);
114117
}
115118

@@ -221,9 +224,9 @@ public function nodesWillBeSortedDesc()
221224
->sortDesc('title')
222225
->execute();
223226

224-
/** @var \TYPO3\Flow\Persistence\QueryResultInterface $result $node */
227+
/** @var QueryResultInterface $result $node */
225228

226-
$this->assertInstanceOf(\TYPO3\Flow\Persistence\QueryResultInterface::class, $result);
229+
$this->assertInstanceOf(QueryResultInterface::class, $result);
227230
$this->assertCount(3, $result, 'The result should have 3 items');
228231
$this->assertEquals(3, $result->count(), 'Count should be 3');
229232

Tests/Unit/Eel/ElasticSearchQueryBuilderResultTest.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* The TYPO3 project - inspiring people to share! *
1212
* */
1313

14+
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQuery;
1415
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQueryBuilder;
1516
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQueryResult;
1617

@@ -25,14 +26,14 @@ class ElasticSearchQueryBuilderResultTest extends \TYPO3\Flow\Tests\UnitTestCase
2526
*/
2627
public function ifNoAggregationsAreSetInTheQueyBuilderResultAnEmptyArrayWillBeReturnedIfYouFetchTheAggregations()
2728
{
28-
$resultArrayWithoutAggregations = array(
29-
"nodes" => array("some", "nodes")
30-
);
29+
$resultArrayWithoutAggregations = [
30+
"nodes" => ["some", "nodes"]
31+
];
3132

32-
$queryBuilder = $this->getMock(ElasticSearchQueryBuilder::class, array("fetch"));
33+
$queryBuilder = $this->getMockBuilder(ElasticSearchQueryBuilder::class)->setMethods(["fetch"])->getMock();
3334
$queryBuilder->method("fetch")->will($this->returnValue($resultArrayWithoutAggregations));
3435

35-
$esQuery = new \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQuery($queryBuilder);
36+
$esQuery = new ElasticSearchQuery($queryBuilder);
3637

3738
$queryResult = new ElasticSearchQueryResult($esQuery);
3839

0 commit comments

Comments
 (0)