Skip to content

Commit 0d49b98

Browse files
committed
Merge pull request #96 from daniellienert/issue/IN-8
[TASK] Enable elasticsearch for functional tests in travis
2 parents d67949f + f5b774b commit 0d49b98

3 files changed

Lines changed: 65 additions & 4 deletions

File tree

.travis.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,23 @@ matrix:
33
include:
44
- php: 5.6
55
- php: 5.5
6-
# use modern infrastructure based on containers
76
sudo: false
87
before_install:
8+
- cd ..
9+
- wget --no-check-certificate https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.0.zip && unzip elasticsearch-1.7.0.zip
10+
- mv elasticsearch-1.7.0 elasticsearch
11+
- cd elasticsearch
12+
- bin/elasticsearch -d
913
- cd ..
1014
- git clone https://github.com/neos/neos-base-distribution.git
1115
- cd neos-base-distribution
1216
- composer require flowpack/elasticsearch-contentrepositoryadaptor dev-master
1317
install:
1418
- composer install
19+
- cd ..
20+
- rm -rf neos-base-distribution/Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor
21+
- mv Flowpack.ElasticSearch.ContentRepositoryAdaptor neos-base-distribution/Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor
22+
- cd neos-base-distribution
1523
script:
1624
- bin/phpunit -c Build/BuildEssentials/PhpUnit/UnitTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Unit
25+
- FLOW_CONTEXT=Testing/WithoutLanguageFallback bin/phpunit -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Packages/Application/Flowpack.ElasticSearch.ContentRepositoryAdaptor/Tests/Functional
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
TYPO3:
2+
TYPO3CR:
3+
contentDimensions:
4+
'language':
5+
default: 'en_US'
6+
defaultPreset: 'en_US'
7+
presets:
8+
'all': ~
9+
'en_US':
10+
label: 'English (US)'
11+
values: ['en_US']
12+
uriSegment: 'en'
13+
'en_UK': ~
14+
'de':
15+
label: 'German'
16+
values: ['de']
17+
uriSegment: 'de'
18+
'fr': ~
19+
'nl': ~
20+
'dk': ~
21+
'lv': ~

Tests/Functional/Eel/ElasticSearchQueryTest.php

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

14-
use Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQuery;
14+
use TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository;
1515

1616
/**
1717
* Testcase for ElasticSearchQuery
1818
*/
1919
class ElasticSearchQueryTest extends \TYPO3\Flow\Tests\FunctionalTestCase
2020
{
21+
/**
22+
* @var WorkspaceRepository
23+
*/
24+
protected $workspaceRepository;
25+
2126
/**
2227
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Command\NodeIndexCommandController
2328
*/
@@ -56,19 +61,28 @@ class ElasticSearchQueryTest extends \TYPO3\Flow\Tests\FunctionalTestCase
5661
public function setUp()
5762
{
5863
parent::setUp();
64+
$this->workspaceRepository = $this->objectManager->get('TYPO3\TYPO3CR\Domain\Repository\WorkspaceRepository');
65+
$liveWorkspace = new \TYPO3\TYPO3CR\Domain\Model\Workspace("live");
66+
$this->workspaceRepository->add($liveWorkspace);
67+
5968
$this->nodeTypeManager = $this->objectManager->get('TYPO3\TYPO3CR\Domain\Service\NodeTypeManager');
6069
$this->contextFactory = $this->objectManager->get('TYPO3\TYPO3CR\Domain\Service\ContextFactoryInterface');
6170
$this->context = $this->contextFactory->create(array('workspaceName' => 'live', 'dimensions' => array('language' => array('de'))));
71+
6272
$this->nodeDataRepository = $this->objectManager->get('TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository');
6373
$this->queryBuilder = $this->objectManager->get('Flowpack\ElasticSearch\ContentRepositoryAdaptor\Eel\ElasticSearchQueryBuilder');
6474

6575
$this->queryBuilder->log();
66-
$this->createNodesForNodeSearchTest();
76+
77+
// we need to make sure that the index will be prefixed with an unique name. so we add a sleet as it is not
78+
// possible right now to set the index name
79+
sleep(4);
6780

6881
$this->nodeIndexCommandController = $this->objectManager->get('Flowpack\ElasticSearch\ContentRepositoryAdaptor\Command\NodeIndexCommandController');
6982
$this->nodeIndexCommandController->buildCommand();
70-
}
7183

84+
$this->createNodesForNodeSearchTest();
85+
}
7286

7387
public function tearDown()
7488
{
@@ -109,7 +123,23 @@ public function filterLimitQuery()
109123
$this->assertCount(1, $result->toArray(), 'Asserting the executed query returns a valid number of items.');
110124
}
111125

126+
/**
127+
* @test
128+
*/
129+
public function aggregationsCanAdded()
130+
{
131+
$aggregationTitle = "titleagg";
132+
$result = $this->queryBuilder->query($this->context->getRootNode())->fieldBasedAggregation($aggregationTitle, "title")->execute()->getAggregations();
133+
134+
$this->assertArrayHasKey($aggregationTitle, $result);
112135

136+
// assume three results because there are three nodes created with an title set
137+
$this->assertCount(3, $result[$aggregationTitle]);
138+
}
139+
140+
/**
141+
* Creates some sample nodes to run tests against
142+
*/
113143
protected function createNodesForNodeSearchTest()
114144
{
115145
$rootNode = $this->context->getRootNode();
@@ -124,5 +154,6 @@ protected function createNodesForNodeSearchTest()
124154
$newNode2->setProperty('title', 'egg');
125155

126156
$this->persistenceManager->persistAll();
157+
$this->nodeIndexCommandController->buildCommand();
127158
}
128159
}

0 commit comments

Comments
 (0)