-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathContentRepositoryNodeCreationTrait.php
More file actions
74 lines (60 loc) · 3.89 KB
/
ContentRepositoryNodeCreationTrait.php
File metadata and controls
74 lines (60 loc) · 3.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
declare(strict_types=1);
namespace Flowpack\ElasticSearch\ContentRepositoryAdaptor\Tests\Functional\Traits;
/*
* This file is part of the Flowpack.ElasticSearch.ContentRepositoryAdaptor package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
trait ContentRepositoryNodeCreationTrait
{
/**
* Creates some sample nodes to run tests against
*/
protected function createNodesForNodeSearchTest(): void
{
$this->context = $this->contextFactory->create([
'workspaceName' => 'live',
'dimensions' => ['language' => ['en_US']],
'targetDimensions' => ['language' => 'en_US']
]);
$rootNode = $this->context->getRootNode();
$this->siteNode = $rootNode->createNode('welcome', $this->nodeTypeManager->getNodeType('Flowpack.ElasticSearch.ContentRepositoryAdaptor:Document'));
$this->siteNode->setProperty('title', 'welcome');
$newDocumentNode1 = $this->siteNode->createNode('test-node-1', $this->nodeTypeManager->getNodeType('Flowpack.ElasticSearch.ContentRepositoryAdaptor:Document'));
$newDocumentNode1->setProperty('title', 'chicken');
$newDocumentNode1->setProperty('title_analyzed', 'chicken');
$newContentNode1 = $newDocumentNode1->getNode('main')->createNode('document-1-text-1', $this->nodeTypeManager->getNodeType('Flowpack.ElasticSearch.ContentRepositoryAdaptor:Content'));
$newContentNode1->setProperty('text', 'A Scout smiles and whistles under all circumstances.');
$newDocumentNode2 = $this->siteNode->createNode('test-node-2', $this->nodeTypeManager->getNodeType('Flowpack.ElasticSearch.ContentRepositoryAdaptor:Document'));
$newDocumentNode2->setProperty('title', 'chicken');
$newDocumentNode2->setProperty('title_analyzed', 'chicken');
// Nodes for cacheLifetime test
$newContentNode2 = $newDocumentNode2->getNode('main')->createNode('document-2-text-1', $this->nodeTypeManager->getNodeType('Flowpack.ElasticSearch.ContentRepositoryAdaptor:Content'));
$newContentNode2->setProperty('text', 'Hidden after 2025-01-01');
$newContentNode2->setHiddenAfterDateTime(new \DateTime('@1735686000'));
$newContentNode3 = $newDocumentNode2->getNode('main')->createNode('document-2-text-2', $this->nodeTypeManager->getNodeType('Flowpack.ElasticSearch.ContentRepositoryAdaptor:Content'));
$newContentNode3->setProperty('text', 'Hidden before 2018-07-18');
$newContentNode3->setHiddenBeforeDateTime(new \DateTime('@1531864800'));
$newDocumentNode3 = $this->siteNode->createNode('test-node-3', $this->nodeTypeManager->getNodeType('Flowpack.ElasticSearch.ContentRepositoryAdaptor:Document'));
$newDocumentNode3->setProperty('title', 'egg');
$newDocumentNode3->setProperty('title_analyzed', 'egg');
$newDocumentNode4 = $this->siteNode->createNode('test-node-4', $this->nodeTypeManager->getNodeType('Flowpack.ElasticSearch.ContentRepositoryAdaptor:Document2'));
$newDocumentNode4->setProperty('title', 'tiger');
$newDocumentNode4->setProperty('title_analyzed', 'tiger');
$newDocumentNode5 = $this->siteNode->createNode('test-node-5', $this->nodeTypeManager->getNodeType('Flowpack.ElasticSearch.ContentRepositoryAdaptor:Document2'));
$newDocumentNode5->setProperty('title', 'elephant');
$newDocumentNode5->setProperty('title_analyzed', 'elephant');
$dimensionContext = $this->contextFactory->create([
'workspaceName' => 'live',
'dimensions' => ['language' => ['de']]
]);
$translatedNode3 = $dimensionContext->adoptNode($newDocumentNode3, true);
$translatedNode3->setProperty('title', 'De');
$this->persistenceManager->persistAll();
}
}