Issues (3412)

SearchHttp/_support/SearchHttpBusinessTester.php (1 issue)

1
<?php
2
3
/**
4
 * Copyright © 2016-present Spryker Systems GmbH. All rights reserved.
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
declare(strict_types=1);
9
10
namespace SprykerTest\Zed\SearchHttp;
11
12
use Codeception\Actor;
13
use Generated\Shared\Transfer\SearchHttpConfigTransfer;
14
use Generated\Shared\Transfer\StoreTransfer;
15
use Orm\Zed\SearchHttp\Persistence\SpySearchHttpConfig;
16
use Orm\Zed\SearchHttp\Persistence\SpySearchHttpConfigQuery;
17
18
/**
19
 * Inherited Methods
20
 *
21
 * @method void wantToTest($text)
22
 * @method void wantTo($text)
23
 * @method void execute($callable)
24
 * @method void expectTo($prediction)
25
 * @method void expect($prediction)
26
 * @method void amGoingTo($argumentation)
27
 * @method void am($role)
28
 * @method void lookForwardTo($achieveValue)
29
 * @method void comment($description)
30
 * @method void pause($vars = [])
31
 * @method \Spryker\Zed\SearchHttp\Business\SearchHttpFacadeInterface getFacade()
32
 *
33
 * @SuppressWarnings(\SprykerTest\Zed\SearchHttp\PHPMD)
34
 */
35
class SearchHttpBusinessTester extends Actor
36
{
37
    use _generated\SearchHttpBusinessTesterActions;
38
39
    /**
40
     * @return void
41
     */
42
    public function ensureSearchHttpConfigTableIsEmpty(): void
43
    {
44
        $this->ensureDatabaseTableIsEmpty($this->getSearchHttpConfigQuery());
45
    }
46
47
    /**
48
     * @return \Orm\Zed\SearchHttp\Persistence\SpySearchHttpConfigQuery
49
     */
50
    protected function getSearchHttpConfigQuery(): SpySearchHttpConfigQuery
51
    {
52
        return SpySearchHttpConfigQuery::create();
53
    }
54
55
    /**
56
     * @return \Orm\Zed\SearchHttp\Persistence\SpySearchHttpConfig|null
57
     */
58
    public function findSearchHttpConfig(): ?SpySearchHttpConfig
59
    {
60
        return $this->getSearchHttpConfigQuery()
61
            ->findOne();
62
    }
63
64
    /**
65
     * @param \Generated\Shared\Transfer\SearchHttpConfigTransfer $searchHttpConfigTransfer
66
     * @param \Orm\Zed\SearchHttp\Persistence\SpySearchHttpConfig|null $searchHttpConfigEntity
67
     *
68
     * @return void
69
     */
70
    public function assertSearchHttpConfigStoredProperly(
71
        SearchHttpConfigTransfer $searchHttpConfigTransfer,
72
        ?SpySearchHttpConfig $searchHttpConfigEntity = null
73
    ): void {
74
        $this->assertNotNull($searchHttpConfigEntity);
75
        $this->assertNotEmpty($searchHttpConfigEntity->getData());
0 ignored issues
show
The method getData() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

75
        $this->assertNotEmpty($searchHttpConfigEntity->/** @scrutinizer ignore-call */ getData());

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...
76
        $this->assertNotEmpty($searchHttpConfigEntity->getData()['search_http_configs']);
77
        $this->assertNotNull($searchHttpConfigEntity->getData()['search_http_configs'][0]['application_id']);
78
        $this->assertEquals(
79
            $searchHttpConfigTransfer->getApplicationId(),
80
            $searchHttpConfigEntity->getData()['search_http_configs'][0]['application_id'],
81
        );
82
        $this->assertNotNull($searchHttpConfigEntity->getData()['search_http_configs'][0]['url']);
83
        $this->assertEquals(
84
            $searchHttpConfigTransfer->getUrl(),
85
            $searchHttpConfigEntity->getData()['search_http_configs'][0]['url'],
86
        );
87
        $this->assertNotNull($searchHttpConfigEntity->getData()['search_http_configs'][0]['suggestion_url']);
88
        $this->assertEquals(
89
            $searchHttpConfigTransfer->getSuggestionUrl(),
90
            $searchHttpConfigEntity->getData()['search_http_configs'][0]['suggestion_url'],
91
        );
92
        $this->assertNotNull($searchHttpConfigEntity->getData()['search_http_configs'][0]['settings']);
93
        $this->assertEquals(
94
            $searchHttpConfigTransfer->getSettings(),
95
            $searchHttpConfigEntity->getData()['search_http_configs'][0]['settings'],
96
        );
97
    }
98
99
    /**
100
     * @param \Orm\Zed\SearchHttp\Persistence\SpySearchHttpConfig|null $searchHttpConfigEntity
101
     *
102
     * @return void
103
     */
104
    public function assertSearchHttpConfigRemovedProperly(
105
        ?SpySearchHttpConfig $searchHttpConfigEntity = null
106
    ): void {
107
        $this->assertNotNull($searchHttpConfigEntity);
108
        $this->assertNotEmpty($searchHttpConfigEntity->getData());
109
        $this->assertEquals([], $searchHttpConfigEntity->getData()['search_http_configs']);
110
    }
111
112
    /**
113
     * @return \Generated\Shared\Transfer\StoreTransfer
114
     */
115
    public function createStoreWithStoreReference(): StoreTransfer
116
    {
117
        return (new StoreTransfer())
118
            ->setName('test_store_name')
119
            ->setStoreReference('test_store_reference');
120
    }
121
}
122