Completed
Push — master ( a487eb...4e86ca )
by itkg-nanne
03:14 queued 26s
created

  A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 3
1
<?php
2
3
namespace OpenOrchestra\FunctionalTests\ModelBundle\Repository;
4
5
use OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractKernelTestCase;
6
use OpenOrchestra\Pagination\Configuration\FinderConfiguration;
7
use OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration;
8
use OpenOrchestra\ModelInterface\Repository\ContentRepositoryInterface;
9
use OpenOrchestra\ModelInterface\Repository\RepositoryTrait\KeywordableTraitInterface;
10
use OpenOrchestra\ModelInterface\ContentEvents;
11
use Phake;
12
use OpenOrchestra\ModelBundle\Document\ContentType;
13
use OpenOrchestra\ModelBundle\Document\Content;
14
15
/**
16
 * Class ContentRepositoryTest
17
 *
18
 * @group integrationTest
19
 */
20
class ContentRepositoryTest extends AbstractKernelTestCase
21
{
22
    /**
23
     * @var ContentRepositoryInterface
24
     */
25
    protected $repository;
26
    protected $keywordRepository;
27
    protected $userRepository;
28
    protected $statusRepository;
29
    protected $contentTypeRepository;
30
31
    protected $currentsiteManager;
32
33
    /**
34
     * Set up test
35
     */
36
    protected function setUp()
37
    {
38
        parent::setUp();
39
        static::bootKernel();
40
        $this->keywordRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.keyword');
41
        $this->userRepository = static::$kernel->getContainer()->get('open_orchestra_user.repository.user');
42
        $this->currentsiteManager = Phake::mock('OpenOrchestra\BaseBundle\Context\CurrentSiteIdInterface');
43
        Phake::when($this->currentsiteManager)->getCurrentSiteId()->thenReturn('2');
44
        Phake::when($this->currentsiteManager)->getCurrentSiteDefaultLanguage()->thenReturn('fr');
45
46
        $this->repository = static::$kernel->getContainer()->get('open_orchestra_model.repository.content');
47
        $this->statusRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.status');
48
        $this->contentTypeRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.content_type');
49
    }
50
51
    /**
52
     * @param string  $name
53
     * @param boolean $exists
54
     *
55
     * @dataProvider provideTestUniquenessInContext
56
     */
57
    public function testTestUniquenessInContext($name, $exists)
58
    {
59
        $test = $this->repository->testUniquenessInContext($name);
60
61
        $this->assertEquals($exists, $test);
62
63
    }
64
65
    /**
66
     * @return array
67
     */
68
    public function provideTestUniquenessInContext()
69
    {
70
        return array(
71
            array('welcome', true),
72
            array('fakeContentId', false),
73
        );
74
    }
75
76
    /**
77
     * @param string $contentId
78
     *
79
     * @dataProvider provideFindOneByContentId
80
     */
81
    public function testFindOneByContentId($contentId)
82
    {
83
        $content = $this->repository->findOneByContentId($contentId);
84
        $this->assertSameContent(null, null, null, $contentId, $content);
85
        $this->assertEquals($contentId, $content->getContentId());
86
    }
87
88
    /**
89
     * @return array
90
     */
91
    public function provideFindOneByContentId()
92
    {
93
        return array(
94
            array('notre_vision'),
95
            array('bien_vivre_en_france'),
96
        );
97
    }
98
99
    /**
100
     * @param $contentId
101
     * @param $version
102
     * @param string|null $language
103
     *
104
     * @dataProvider providefindLastPublishedVersion
105
     */
106
    public function testFindLastPublishedVersion($contentId, $version, $language)
107
    {
108
        $content = $this->repository->findLastPublishedVersion($contentId, $language);
109
        $this->assertSameContent($language, $version, null, $contentId, $content);
110
        $this->assertEquals($contentId, $content->getContentId());
111
    }
112
113
    /**
114
     * @param $contentId
115
     * @param $version
116
     * @param string|null $language
117
     *
118
     * @dataProvider providefindLastPublishedVersion
119
     */
120
    public function testFindOneCurrentlyPublished($contentId, $version, $language)
121
    {
122
        $content = $this->repository->findOneCurrentlyPublished($contentId, $language, '2');
123
        $this->assertSameContent($language, $version, null, $contentId, $content);
124
        $this->assertEquals($contentId, $content->getContentId());
125
    }
126
127
    /**
128
     * @return array
129
     */
130 View Code Duplication
    public function providefindLastPublishedVersion()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
131
    {
132
        return array(
133
            array('notre_vision', 1, 'fr'),
134
            array('bien_vivre_en_france', 1, 'fr'),
135
        );
136
    }
137
138
    /**
139
     * @param string      $contentType
140
     * @param string      $choiceType
141
     * @param string|null $keywords
142
     * @param int         $count
143
     *
144
     * @dataProvider provideContentTypeKeywordAndCount
145
     */
146
    public function testFindByContentTypeAndCondition($contentType = '', $choiceType, $keywords = null, $count)
147
    {
148
        $keywords = $this->replaceKeywordLabelById($keywords);
149
150
        $language = $this->currentsiteManager->getCurrentSiteDefaultLanguage();
0 ignored issues
show
Bug introduced by
The method getCurrentSiteDefaultLanguage() does not seem to exist on object<Phake_IMock>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
151
        $elements = $this->repository->findByContentTypeAndCondition($language, $contentType, $choiceType, $keywords);
152
153
        $this->assertCount($count, $elements);
154
    }
155
156
    /**
157
     * @return array
158
     */
159
    public function provideContentTypeKeywordAndCount()
160
    {
161
        return array(
162
            array('car', ContentRepositoryInterface::CHOICE_AND, 'lorem', 3),
163
            array('car',ContentRepositoryInterface::CHOICE_AND, 'sit', 1),
164
            array('car', ContentRepositoryInterface::CHOICE_AND, 'dolor', 0),
165
            array('car', ContentRepositoryInterface::CHOICE_AND, 'sit AND lorem', 1),
166
            array('news', ContentRepositoryInterface::CHOICE_AND, 'lorem', 1),
167
            array('news', ContentRepositoryInterface::CHOICE_AND, 'sit', 2),
168
            array('news', ContentRepositoryInterface::CHOICE_AND, 'dolor', 0),
169
            array('news', ContentRepositoryInterface::CHOICE_AND, 'lorem AND sit', 1),
170
            array('news', ContentRepositoryInterface::CHOICE_AND, '', 4),
171
            array('car', ContentRepositoryInterface::CHOICE_AND, '', 3),
172
            array('', ContentRepositoryInterface::CHOICE_AND, '', 9),
173
            array('', ContentRepositoryInterface::CHOICE_AND, '', 9),
174
            array('', ContentRepositoryInterface::CHOICE_AND, 'lorem', 5),
175
            array('', ContentRepositoryInterface::CHOICE_AND, 'sit', 4),
176
            array('', ContentRepositoryInterface::CHOICE_AND, 'dolor', 0),
177
            array('', ContentRepositoryInterface::CHOICE_AND, 'lorem AND sit', 3),
178
            array('car', ContentRepositoryInterface::CHOICE_OR, 'lorem', 5),
179
            array('car', ContentRepositoryInterface::CHOICE_OR, 'sit', 6),
180
            array('car', ContentRepositoryInterface::CHOICE_OR, 'dolor', 3),
181
            array('car', ContentRepositoryInterface::CHOICE_OR, 'lorem AND sit', 5),
182
            array('news', ContentRepositoryInterface::CHOICE_OR, 'lorem', 8),
183
            array('news', ContentRepositoryInterface::CHOICE_OR, 'sit', 6),
184
            array('news', ContentRepositoryInterface::CHOICE_OR, 'dolor', 4),
185
            array('news', ContentRepositoryInterface::CHOICE_OR, 'lorem AND sit', 6),
186
            array('news', ContentRepositoryInterface::CHOICE_OR, '', 4),
187
            array('car', ContentRepositoryInterface::CHOICE_OR, '', 3),
188
            array('', ContentRepositoryInterface::CHOICE_OR, '', 9),
189
            array('', ContentRepositoryInterface::CHOICE_OR, 'lorem', 5),
190
            array('', ContentRepositoryInterface::CHOICE_OR, 'sit', 4),
191
            array('', ContentRepositoryInterface::CHOICE_OR, 'dolor', 0),
192
            array('', ContentRepositoryInterface::CHOICE_OR, 'lorem AND sit', 3),
193
            array('', ContentRepositoryInterface::CHOICE_OR, '', 9),
194
        );
195
    }
196
197
    /**
198
     * @param string $contentId
199
     * @param string $language
200
     *
201
     * @dataProvider provideFindOneByContentIdAndLanguage
202
     */
203
    public function testFindOneByLanguage($contentId, $language)
204
    {
205
        $content = $this->repository->findOneByLanguage($contentId, $language);
206
207
        $this->assertSameContent($language, null, null, $contentId, $content);
208
    }
209
210
    /**
211
     * @return array
212
     */
213
    public function provideFindOneByContentIdAndLanguage()
214
    {
215
        return array(
216
            array('notre_vision', 'fr'),
217
            array('bien_vivre_en_france', 'fr'),
218
        );
219
    }
220
221
    /**
222
     * @param string $contentId
223
     * @param string $language
224
     *
225
     * @dataProvider provideFindByContentIdAndLanguage
226
     */
227
    public function testFindByLanguage($contentId, $language)
228
    {
229
        $contents = $this->repository->findByLanguage($contentId, $language);
230
231
        foreach ($contents as $content) {
232
            $this->assertSameContent($language, null, null, $contentId, $content);
233
        }
234
235
    }
236
237
    /**
238
     * @return array
239
     */
240
    public function provideFindByContentIdAndLanguage()
241
    {
242
        return array(
243
            array('notre_vision', 'fr'),
244
            array('bien_vivre_en_france', 'fr'),
245
        );
246
    }
247
248
    /**
249
     * @param string $contentId
250
     * @param string $language
251
     * @param int    $version
252
     *
253
     * @dataProvider provideFindOneByContentIdAndLanguageAndVersion
254
     */
255
    public function testFindOneByLanguageAndVersion($contentId, $language, $version)
256
    {
257
        $content = $this->repository->findOneByLanguageAndVersion($contentId, $language, $version);
258
259
        $this->assertSameContent($language, $version, null, $contentId, $content);
260
261
    }
262
263
    /**
264
     * @return array
265
     */
266 View Code Duplication
    public function provideFindOneByContentIdAndLanguageAndVersion()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
267
    {
268
        return array(
269
            array('notre_vision', 'fr', 1),
270
            array('bien_vivre_en_france', 'fr', 1),
271
        );
272
    }
273
274
    /**
275
     * @param string     $contentType
276
     * @param array|null $search
277
     * @param array|null $order
278
     * @param string     $siteId
279
     * @param int        $skip
280
     * @param int        $limit
281
     * @param string     $language
282
     * @param integer    $count
283
     * @param integer    $totalCount
284
     * @param string     $name
285
     *
286
     * @dataProvider provideContentTypeAndPaginateAndSearchAndsiteId
287
     */
288
    public function testFindForPaginateFilterByContentTypeSiteAndLanguage($contentType, $search, $order, $siteId, $skip, $limit, $language, $count, $totalCount, $name = null)
289
    {
290
        $mapping = array(
291
            'name' => 'name',
292
            'status_label' => 'status.labels.'.$language,
293
            'linked_to_site' => 'linkedToSite',
294
            'created_at' => 'createdAt',
295
            'created_by' => 'createdBy',
296
            'updated_at' => 'updatedAt',
297
            'updated_by' => 'updatedBy',
298
            'fields.car_name.string_value' => 'attributes.car_name.stringValue',
299
            'fields.description.string_value' => 'attributes.description.stringValue',
300
            'fields.on_market.string_value' => 'attributes.on_market.stringValue',
301
            'fields.tinimce_test.string_value' => 'attributes.tinimce_test.stringValue',
302
        );
303
304
        $searchTypes = array (
305
            'attributes.car_name' => 'text',
306
            'attributes.description' => 'text',
307
            'attributes.on_market' => 'date',
308
            'attributes.tinimce_test' => 'text',
309
        );
310
311
312
        $configuration = PaginateFinderConfiguration::generateFromVariable($order, $skip, $limit, $mapping, $search);
313
        $contents = $this->repository->findForPaginateFilterByContentTypeSiteAndLanguage($configuration, $contentType, $siteId, $language, $searchTypes);
0 ignored issues
show
Unused Code introduced by
The call to ContentRepositoryInterfa...ntTypeSiteAndLanguage() has too many arguments starting with $searchTypes.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
314
        $repositoryCount = $this->repository->countWithFilterAndContentTypeSiteAndLanguage($configuration, $contentType, $siteId, $language, $searchTypes);
0 ignored issues
show
Unused Code introduced by
The call to ContentRepositoryInterfa...ntTypeSiteAndLanguage() has too many arguments starting with $searchTypes.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
315
316
        if(!is_null($name)) {
317
            $this->assertEquals($name, $contents[0]->getName());
318
        }
319
        $this->assertCount($count, $contents);
320
        $this->assertEquals($totalCount, $repositoryCount);
321
    }
322
323
    /**
324
     * @return array
325
     */
326
    public function provideContentTypeAndPaginateAndSearchAndsiteId()
327
    {
328
        return array(
329
            1  => array('car', null, array("name" => "name", "dir" => "asc"), '2', 0 ,5 , 'en', 3, 3, '206 3 portes en'),
330
            2  => array('car', null, array("name" => "name", "dir" => "desc"), '2', 0 ,5 , 'en', 3, 3, 'R5 3 portes en'),
331
            3  => array('car', null, array("name" => "fields.car_name.string_value", "dir" => "asc"), '2', 0 ,5 , 'en', 3, 3, '206 3 portes en'),
332
            4  => array('car', null, array("name" => "fields.car_name.string_value", "dir" => "desc"),'2', 0 ,5 , 'en', 3, 3, 'R5 3 portes en'),
333
            5  => array('car', null, null, null, 0 ,1 , 'en', 1, 2),
334
            6  => array('car', array('attributes.car_name' => '206'), null, '2', 0 , 2 , 'en', 1, 1),
335
            7  => array('news', null, null, '2', 0 , 100, 'fr', 4, 4),
336
            8  => array('news', null, null, '2', 50 , 100, 'en', 0, 0),
337
            9 => array('news', array('name' => 'news'), null, '2', 0 , null, 'fr', 0, 0),
338
            10 => array('car', null, null, '2', 0 ,5 , 'en', 3, 3),
339
        );
340
    }
341
342
    /**
343
     * @param string  $contentType
344
     * @param string  $siteId
345
     * @param string  $language
346
     * @param integer $count
347
     *
348
     * @dataProvider provideCountByContentTypeAndSiteInLastVersion
349
     */
350
    public function testCountFilterByContentTypeSiteAndLanguage($contentType, $siteId, $language, $count)
351
    {
352
        $contents = $this->repository->countFilterByContentTypeSiteAndLanguage($contentType, $siteId, $language);
353
        $this->assertEquals($count, $contents);
354
    }
355
356
    /**
357
     * @return array
358
     */
359
    public function provideCountByContentTypeAndSiteInLastVersion()
360
    {
361
        return array(
362
            array('car', '1', 'en', 2),
363
            array('car', '2', 'en', 3),
364
            array('customer', '1', 'en', 1),
365
            array('customer', '2', 'en', 1),
366
            array('news', '1', 'en', 0),
367
            array('news', '2', 'fr', 4),
368
        );
369
    }
370
371
    /**
372
     * @param string       $user
373
     * @param string       $siteId
374
     * @param array        $eventTypes
375
     * @param boolean|null $published
376
     * @param int          $limit
377
     * @param array|null   $sort
378
     * @param int          $count
379
     *
380
     * @dataProvider provideFindByHistoryAndSiteId
381
     */
382 View Code Duplication
    public function testFindByHistoryAndSiteId($user, $siteId, array $eventTypes, $published, $limit, $sort, $count)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
383
    {
384
        $user = $this->userRepository->findOneByUsername($user);
385
386
        $contents = $this->repository->findByHistoryAndSiteId($user->getId(), $siteId, $eventTypes, $published, $limit, $sort);
387
        $this->assertCount($count, $contents);
388
    }
389
390
    /**
391
     * @return array
392
     */
393
    public function provideFindByHistoryAndSiteId()
394
    {
395
        return array(
396
            1 => array('p-admin', '2', array(ContentEvents::CONTENT_CREATION), null, 10, array('updatedAt' => -1), 0),
397
            2 => array('p-admin', '2', array(ContentEvents::CONTENT_CREATION), false, 10, null, 0),
398
            3 => array('p-admin', '2', array(ContentEvents::CONTENT_CREATION), true, 10, null, 0),
399
            4 => array('p-admin', '2', array(ContentEvents::CONTENT_UPDATE), true, 10, null, 0),
400
            5 => array('p-admin', '2', array(ContentEvents::CONTENT_CREATION, ContentEvents::CONTENT_UPDATE), true, 10, null, 0),
401
        );
402
    }
403
404
    /**
405
     * test updateStatusByContentType
406
     */
407
    public function testUpdateStatusByContentType()
408
    {
409
        $contentTypeId = 'test';
410
411
        $outOfWorkflow = $this->statusRepository->findOneByOutOfWorkflow();
412
413
        $dm = $this->contentTypeRepository->getDocumentManager();
414
415
        $contentType = new ContentType();
416
        $contentType->setContentTypeId($contentTypeId);
417
        $dm->persist($contentType);
418
        $dm->flush();
419
420
        $content = new Content();
421
        $content->setContentType($contentTypeId);
422
        $dm->persist($content);
423
        $dm->flush();
424
425
        $this->assertEquals('draft', $content->getStatus()->getName());
426
427
        $this->repository->updateStatusByContentType($outOfWorkflow, $contentTypeId);
428
        $dm->clear();
429
430
        $updatedContent = $this->repository->findOneBy(array('_id' => $content->getId()));
0 ignored issues
show
Bug introduced by
The method findOneBy() does not exist on OpenOrchestra\ModelInter...tentRepositoryInterface. Did you maybe mean findOneByContentId()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
431
        $this->assertEquals('outOfWorkflow', $updatedContent->getStatus()->getName());
432
433
        $contentType = $this->contentTypeRepository->findOneBy(array('contentTypeId' => $contentTypeId));
434
435
        $dm->remove($updatedContent);
436
        $dm->remove($contentType);
437
        $dm->flush();
438
    }
439
440
    /**
441
     * Generate columns of content with search value
442
     *
443
     * @param array|null $searchColumns
444
     * @param string     $globalSearch
445
     *
446
     * @return array
447
     */
448
    protected function generateColumnsProvider($searchColumns = null, $globalSearch = '')
449
    {
450
        $search = array();
451
        if (null !== $searchColumns) {
452
            $columns = array();
453
            foreach ($searchColumns as $name => $value) {
454
                $columns[$name] = $value;
455
            }
456
            $search['columns'] = $columns;
457
        }
458
459
        if (!empty($globalSearch)) {
460
            $search['global'] = $globalSearch;
461
        }
462
463
        return $search;
464
    }
465
466
    /**
467
     * Generate relation between columns names and entities attributes
468
     *
469
     * @return array
470
     */
471
    protected function getDescriptionColumnEntity()
472
    {
473
        return array (
474
            'name' =>
475
            array (
476
                'key' => 'name',
477
                'field' => 'name',
478
                'type' => 'string',
479
            ),
480
            'language' =>
481
            array (
482
                'key' => 'language',
483
                'field' => 'language',
484
                'type' => 'string',
485
            ),
486
            'status_label' =>
487
            array (
488
                'key' => 'status_label',
489
                'field' => 'status',
490
                'type' => 'multiLanguages',
491
            ),
492
            'version' =>
493
            array (
494
                'key' => 'version',
495
                'field' => 'version',
496
                'type' => 'integer',
497
            ),
498
            'linked_to_site' =>
499
            array (
500
                'key' => 'linked_to_site',
501
                'field' => 'linkedTosite',
502
                'type' => 'boolean',
503
            ),
504
            'created_by' =>
505
            array (
506
                'key' => 'created_by',
507
                'field' => 'createdBy',
508
                'type' => 'string',
509
            ),
510
            'updated_by' =>
511
            array (
512
                'key' => 'updated_by',
513
                'field' => 'updatedBy',
514
                'type' => 'string',
515
            ),
516
            'created_at' =>
517
            array (
518
                'key' => 'created_at',
519
                'field' => 'createdAt',
520
                'type' => 'date',
521
            ),
522
            'updated_at' =>
523
            array (
524
                'key' => 'updated_at',
525
                'field' => 'updatedAt',
526
                'type' => 'date',
527
            ),
528
            'deleted' =>
529
            array (
530
                'key' => 'deleted',
531
                'field' => 'deleted',
532
                'type' => 'boolean',
533
            ),
534
            'attributes.car_name.string_value' =>
535
            array(
536
                'key' => 'attributes.car_name.string_value',
537
                'field' => 'attributes.car_name.stringValue',
538
                'type' => 'string',
539
                'value' => NULL,
540
            ),
541
            'attributes.description.string_value' =>
542
            array(
543
                'key' => 'attributes.description.string_value',
544
                'field' => 'attributes.description.stringValue',
545
                'type' => 'string',
546
                'value' => NULL,
547
            ),
548
        );
549
    }
550
551
    /**
552
     * @param string                                               $language
553
     * @param int                                                  $version
554
     * @param string                                               $siteId
555
     * @param \OpenOrchestra\ModelInterface\Model\ContentInterface $content
556
     * @param string                                               $contentId
557
     */
558
    protected function assertSameContent($language, $version, $siteId, $contentId, $content)
559
    {
560
        $this->assertInstanceOf('OpenOrchestra\ModelInterface\Model\ContentInterface', $content);
561
        $this->assertSame($contentId, $content->getContentId());
562
        if (!is_null($language)) {
563
            $this->assertSame($language, $content->getLanguage());
564
        }
565
        if (!is_null($version)) {
566
            $this->assertSame($version, $content->getVersion());
567
        }
568
        if (!is_null($siteId)) {
569
            $this->assertSame($siteId, $content->getsiteId());
570
        }
571
        $this->assertSame(false, $content->isDeleted());
572
    }
573
574
    /**
575
     * Test has statused element
576
     */
577
    public function testHasStatusedElement()
578
    {
579
        $statusRepository = static::$kernel->getContainer()->get('open_orchestra_model.repository.status');
580
        $status = $statusRepository->findOneByInitial();
581
582
        $this->assertFalse($this->repository->hasStatusedElement($status));
583
    }
584
585
    /**
586
     * @param string $condition
587
     *
588
     * @return array
589
     */
590 View Code Duplication
    protected function replaceKeywordLabelById($condition)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
591
    {
592
        $conditionWithoutOperator = preg_replace(explode('|', KeywordableTraitInterface::OPERATOR_SPLIT), ' ', $condition);
593
        $conditionArray = explode(' ', $conditionWithoutOperator);
594
595
        foreach ($conditionArray as $keyword) {
596
            if ($keyword != '') {
597
                $keywordDocument = $this->keywordRepository->findOneByLabel($keyword);
598
                if (!is_null($keywordDocument)) {
599
                    $condition = str_replace($keyword, $keywordDocument->getId(), $condition);
600
                } else {
601
                    return '';
602
                }
603
            }
604
        }
605
606
        return $condition;
607
    }
608
}
609