Passed
Push — master ( 4e21fd...4ae144 )
by Anton
08:23
created

assertSearchHttpConfigExistsForStore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Spryker Commerce OS.
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
declare(strict_types = 1);
9
10
namespace PyzTest\Zed\MessageBroker;
11
12
use Codeception\Actor;
13
use Generated\Shared\DataBuilder\SearchEndpointAvailableBuilder;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\DataBui...ndpointAvailableBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use Generated\Shared\DataBuilder\SearchEndpointRemovedBuilder;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\DataBui...hEndpointRemovedBuilder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use Generated\Shared\Transfer\SearchEndpointAvailableTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...dpointAvailableTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Generated\Shared\Transfer\SearchEndpointRemovedTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfe...EndpointRemovedTransfer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Orm\Zed\SearchHttp\Persistence\SpySearchHttpConfig;
18
use Orm\Zed\SearchHttp\Persistence\SpySearchHttpConfigQuery;
19
use Spryker\Shared\Kernel\Transfer\TransferInterface;
20
21
/**
22
 * Inherited Methods
23
 *
24
 * @method void wantToTest($text)
25
 * @method void wantTo($text)
26
 * @method void execute($callable)
27
 * @method void expectTo($prediction)
28
 * @method void expect($prediction)
29
 * @method void amGoingTo($argumentation)
30
 * @method void am($role)
31
 * @method void lookForwardTo($achieveValue)
32
 * @method void comment($description)
33
 * @method void pause()
34
 *
35
 * @SuppressWarnings(\PyzTest\Zed\SearchHttp\PHPMD)
36
 */
37
class SearchHttpCommunicationTester extends Actor
38
{
39
    use _generated\SearchHttpCommunicationTesterActions;
0 ignored issues
show
Bug introduced by
The type PyzTest\Zed\MessageBroke...municationTesterActions was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
40
41
    /**
42
     * @return void
43
     */
44
    public function assertSearchHttpConfigExistsForStore(): void
45
    {
46
        $searchHttpConfigEntity = $this->getSearchHttpConfigEntity();
47
48
        $this->assertNotNull($searchHttpConfigEntity);
49
    }
50
51
    /**
52
     * @return void
53
     */
54
    public function assertSearchHttpConfigIsRemoved(): void
55
    {
56
        $searchHttpConfigEntity = $this->getSearchHttpConfigEntity();
57
58
        $this->assertSame(
59
            ['search_http_configs' => []],
60
            $searchHttpConfigEntity->getData(),
61
        );
62
    }
63
64
    /**
65
     * @return \Generated\Shared\Transfer\SearchEndpointAvailableTransfer
66
     */
67
    public function buildSearchEndpointAvailableTransfer(): SearchEndpointAvailableTransfer
68
    {
69
        return (new SearchEndpointAvailableBuilder())
70
            ->withMessageAttributes()
71
            ->build();
72
    }
73
74
    /**
75
     * @return \Generated\Shared\Transfer\SearchEndpointRemovedTransfer
76
     */
77
    public function buildSearchEndpointRemovedTransfer(): SearchEndpointRemovedTransfer
78
    {
79
        return (new SearchEndpointRemovedBuilder())
80
            ->withMessageAttributes()
81
            ->build();
82
    }
83
84
    /**
85
     * @return void
86
     */
87
    public function removeHttpConfig(): void
88
    {
89
        (new SpySearchHttpConfigQuery())
90
            ->deleteAll();
91
    }
92
93
    /**
94
     * @param \Spryker\Shared\Kernel\Transfer\TransferInterface $searchMessageTransfer
95
     *
96
     * @return void
97
     */
98
    public function handleSearchMessage(TransferInterface $searchMessageTransfer): void
99
    {
100
        $channelName = 'search-commands';
101
        $this->setupMessageBroker($searchMessageTransfer::class, $channelName);
102
        $this->setupMessageBrokerPlugins();
103
        $messageBrokerFacade = $this->getLocator()->messageBroker()->facade();
104
        $messageBrokerFacade->sendMessage($searchMessageTransfer);
105
        $messageBrokerFacade->startWorker(
106
            $this->buildMessageBrokerWorkerConfigTransfer([$channelName], 1),
107
        );
108
        $this->resetInMemoryMessages();
109
    }
110
111
    /**
112
     * @return \Orm\Zed\SearchHttp\Persistence\SpySearchHttpConfig|null
113
     */
114
    protected function getSearchHttpConfigEntity(): ?SpySearchHttpConfig
115
    {
116
        return (new SpySearchHttpConfigQuery())
117
            ->findOne();
118
    }
119
}
120