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 | namespace SprykerTest\Client\ContentStorage; |
||
9 | |||
10 | use Codeception\Test\Unit; |
||
11 | use Generated\Shared\Transfer\ContentTypeContextTransfer; |
||
12 | use Spryker\Client\ContentStorage\ContentStorageClient; |
||
13 | use Spryker\Client\ContentStorage\ContentStorageClientInterface; |
||
14 | use Spryker\Client\ContentStorage\ContentStorageDependencyProvider; |
||
15 | use Spryker\Client\ContentStorage\Dependency\Client\ContentStorageToStorageClientInterface; |
||
16 | use Spryker\Shared\ContentStorage\ContentStorageConfig; |
||
17 | |||
18 | /** |
||
19 | * Auto-generated group annotations |
||
20 | * |
||
21 | * @group SprykerTest |
||
22 | * @group Client |
||
23 | * @group ContentStorage |
||
24 | * @group ContentStorageClientTest |
||
25 | * Add your own group annotations below this line |
||
26 | */ |
||
27 | class ContentStorageClientTest extends Unit |
||
28 | { |
||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | public const CONTENT_ITEM_KEY = '1'; |
||
33 | |||
34 | /** |
||
35 | * @var int |
||
36 | */ |
||
37 | public const CONTENT_ITEM_ID = 0; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | */ |
||
42 | public const LOCALE = 'zh-CN'; |
||
43 | |||
44 | /** |
||
45 | * @var \SprykerTest\Client\ContentStorage\ContentStorageClientTester |
||
46 | */ |
||
47 | protected $tester; |
||
48 | |||
49 | /** |
||
50 | * @return void |
||
51 | */ |
||
52 | public function testFindContentTypeContextByIdReturnsValidTransfer(): void |
||
53 | { |
||
54 | // Arrange |
||
55 | $content = [ |
||
56 | ContentStorageConfig::TERM_KEY => 'KEY', |
||
57 | ContentStorageConfig::CONTENT_KEY => ['CONTENT'], |
||
58 | ContentStorageConfig::ID_CONTENT => static::CONTENT_ITEM_ID, |
||
59 | ]; |
||
60 | $this->setStorageReturn($content); |
||
61 | |||
62 | // Act |
||
63 | $systemUnderTest = $this->createContentStorageClient() |
||
64 | ->findContentTypeContextByKey(static::CONTENT_ITEM_KEY, static::LOCALE); |
||
65 | |||
66 | // Assert |
||
67 | $this->assertSame(ContentTypeContextTransfer::class, get_class($systemUnderTest)); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
68 | } |
||
69 | |||
70 | /** |
||
71 | * @param array|null $returnedContent |
||
72 | * |
||
73 | * @return void |
||
74 | */ |
||
75 | protected function setStorageReturn(?array $returnedContent): void |
||
76 | { |
||
77 | $contentToStorageBridge = $this->getMockBuilder(ContentStorageToStorageClientInterface::class)->getMock(); |
||
78 | $contentToStorageBridge->method('get')->willReturn($returnedContent); |
||
79 | $this->tester->setDependency(ContentStorageDependencyProvider::CLIENT_STORAGE, $contentToStorageBridge); |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @return \Spryker\Client\ContentStorage\ContentStorageClientInterface |
||
84 | */ |
||
85 | protected function createContentStorageClient(): ContentStorageClientInterface |
||
86 | { |
||
87 | return new ContentStorageClient(); |
||
88 | } |
||
89 | } |
||
90 |