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\Zed\FileManager\Business\FileContent; |
||
9 | |||
10 | use Codeception\Test\Unit; |
||
11 | use Generated\Shared\Transfer\FileTransfer; |
||
12 | use Spryker\Zed\FileManager\Business\FileContent\FileContent; |
||
13 | use Spryker\Zed\FileManager\Dependency\Service\FileManagerToFileSystemServiceInterface; |
||
14 | use Spryker\Zed\FileManager\FileManagerConfig; |
||
15 | |||
16 | /** |
||
17 | * Auto-generated group annotations |
||
18 | * |
||
19 | * @group SprykerTest |
||
20 | * @group Zed |
||
21 | * @group FileManager |
||
22 | * @group Business |
||
23 | * @group FileContent |
||
24 | * @group FileContentTest |
||
25 | * Add your own group annotations below this line |
||
26 | */ |
||
27 | class FileContentTest extends Unit |
||
28 | { |
||
29 | /** |
||
30 | * @return \Spryker\Zed\FileManager\Dependency\Service\FileManagerToFileSystemServiceInterface |
||
31 | */ |
||
32 | protected function getFileSystemServiceMock(): FileManagerToFileSystemServiceInterface |
||
33 | { |
||
34 | return $this->getMockBuilder(FileManagerToFileSystemServiceInterface::class)->getMock(); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return \PHPUnit\Framework\MockObject\MockObject|\Spryker\Zed\FileManager\FileManagerConfig |
||
39 | */ |
||
40 | protected function getConfigMock(): FileManagerConfig |
||
41 | { |
||
42 | return $this->getMockBuilder(FileManagerConfig::class)->getMock(); |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @return void |
||
47 | */ |
||
48 | public function testSave(): void |
||
49 | { |
||
50 | $fileSystemServiceMock = $this->getFileSystemServiceMock(); |
||
51 | $fileSystemServiceMock->expects($this->once()) |
||
0 ignored issues
–
show
|
|||
52 | ->method('write') |
||
53 | ->willReturn(null); |
||
54 | |||
55 | $fileContent = new FileContent( |
||
56 | $fileSystemServiceMock, |
||
57 | $this->getConfigMock(), |
||
58 | ); |
||
59 | |||
60 | $fileTransfer = new FileTransfer(); |
||
61 | $fileTransfer->setFileName('report.txt'); |
||
62 | $fileTransfer->setFileContent('this is the report'); |
||
63 | |||
64 | $fileContent->save($fileTransfer); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @return void |
||
69 | */ |
||
70 | public function testDelete(): void |
||
71 | { |
||
72 | $fileSystemServiceMock = $this->getFileSystemServiceMock(); |
||
73 | $fileSystemServiceMock->expects($this->any()) |
||
74 | ->method('delete') |
||
75 | ->willReturn(null); |
||
76 | |||
77 | $fileContent = new FileContent( |
||
78 | $fileSystemServiceMock, |
||
79 | $this->getConfigMock(), |
||
80 | ); |
||
81 | |||
82 | $fileContent->delete('report.txt'); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @return void |
||
87 | */ |
||
88 | public function testRead(): void |
||
89 | { |
||
90 | $fileSystemServiceMock = $this->getFileSystemServiceMock(); |
||
91 | $fileSystemServiceMock->expects($this->once()) |
||
92 | ->method('read') |
||
93 | ->willReturn('this is the report'); |
||
94 | |||
95 | $fileContent = new FileContent( |
||
96 | $fileSystemServiceMock, |
||
97 | $this->getConfigMock(), |
||
98 | ); |
||
99 | |||
100 | $fileContent = $fileContent->read('report.txt'); |
||
101 | $this->assertSame('this is the report', $fileContent); |
||
102 | } |
||
103 | } |
||
104 |
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.