1 | <?php |
||
11 | class OpcacheResetCommandHelperTest extends \PHPUnit\Framework\TestCase |
||
12 | { |
||
13 | /** |
||
14 | * @var KernelInterface |
||
15 | */ |
||
16 | protected $kernel; |
||
17 | |||
18 | /** |
||
19 | * @var OpcacheResetCommandHelper |
||
20 | */ |
||
21 | protected $helper; |
||
22 | |||
23 | /** |
||
24 | * @var Filesystem |
||
25 | */ |
||
26 | protected $filesystem; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | protected $workspace; |
||
32 | |||
33 | protected function setUp() |
||
38 | |||
39 | public function testGetFileName() |
||
40 | { |
||
41 | $fileName = $this->helper->getFileName('test'); |
||
42 | |||
43 | $this->assertEquals($fileName, 'opcache-reset-test.php'); |
||
44 | } |
||
45 | |||
46 | public function testGetFilePath() |
||
47 | { |
||
48 | $filePath = $this->helper->getFilePath('dirtest', 'test'); |
||
49 | |||
50 | $this->assertEquals($filePath, 'dirtest/opcache-reset-test.php'); |
||
51 | } |
||
52 | |||
53 | public function testGenerateUrl() |
||
59 | |||
60 | /** |
||
61 | * @expectedException RuntimeException |
||
62 | */ |
||
63 | public function testCreateFileDirNotExists() |
||
67 | |||
68 | protected function setUpFilesystem() |
||
69 | { |
||
70 | $this->filesystem = new Filesystem(); |
||
71 | $this->workspace = sys_get_temp_dir().'/'.microtime(true).'.'.mt_rand(); |
||
72 | |||
73 | mkdir($this->workspace, 0777, true); |
||
74 | |||
75 | $this->workspace = realpath($this->workspace); |
||
76 | } |
||
77 | |||
78 | protected function tearDownFilesystem() |
||
79 | { |
||
80 | $this->filesystem->remove($this->workspace); |
||
81 | } |
||
82 | |||
83 | public function testCreateFileDirExists() |
||
84 | { |
||
85 | $this->setUpFilesystem(); |
||
86 | |||
87 | $sourceFile = $this->workspace.DIRECTORY_SEPARATOR.'source_file'; |
||
88 | |||
89 | file_put_contents($sourceFile, 'SOURCE FILE'); |
||
90 | |||
91 | $this |
||
|
|||
92 | ->kernel |
||
93 | ->shouldReceive('locateResource') |
||
94 | ->andReturn($sourceFile) |
||
95 | ; |
||
96 | |||
97 | $return = $this->helper->createFile($this->workspace, 'token'); |
||
98 | |||
99 | $this->assertInstanceOf(OpcacheResetCommandHelper::class, $return); |
||
100 | |||
101 | $targetFilePath = $this->workspace.DIRECTORY_SEPARATOR.'opcache-reset-token.php'; |
||
102 | |||
103 | $this->assertFileExists($targetFilePath); |
||
104 | $this->assertEquals('SOURCE FILE', file_get_contents($targetFilePath)); |
||
105 | |||
106 | $this->tearDownFilesystem(); |
||
107 | } |
||
108 | |||
109 | public function testClean() |
||
110 | { |
||
111 | $this->setUpFilesystem(); |
||
112 | |||
113 | $fileToDelete1 = $this->workspace.DIRECTORY_SEPARATOR.'opcache-reset-1.php'; |
||
114 | touch($fileToDelete1); |
||
115 | |||
116 | $fileToDelete2 = $this->workspace.DIRECTORY_SEPARATOR.'opcache-reset-2.php'; |
||
117 | touch($fileToDelete2); |
||
118 | |||
119 | $fileNotToDelete = $this->workspace.DIRECTORY_SEPARATOR.'filenottodelete.php'; |
||
120 | touch($fileNotToDelete); |
||
121 | |||
122 | $return = $this->helper->clean($this->workspace); |
||
123 | |||
124 | $this->assertFileNotExists($fileToDelete1); |
||
125 | $this->assertFileNotExists($fileToDelete2); |
||
126 | $this->assertFileExists($fileNotToDelete); |
||
127 | |||
128 | $this->assertInstanceOf(OpcacheResetCommandHelper::class, $return); |
||
129 | |||
130 | $this->tearDownFilesystem(); |
||
131 | } |
||
132 | |||
133 | /** |
||
134 | * @expectedException RuntimeException |
||
135 | */ |
||
136 | public function testHandleResponseBadStatusCode() |
||
142 | |||
143 | /** |
||
144 | * @expectedException RuntimeException |
||
145 | */ |
||
146 | public function testHandleResponseBadJson() |
||
147 | { |
||
148 | $response = $this->getMockedResponse('bad-json'); |
||
152 | |||
153 | /** |
||
154 | * @expectedException InvalidArgumentException |
||
155 | */ |
||
156 | public function testHandleResponsePropertySuccessMissing() |
||
162 | |||
163 | /** |
||
164 | * @expectedException InvalidArgumentException |
||
165 | */ |
||
166 | public function testHandleResponsePropertyMessageMissing() |
||
172 | |||
173 | /** |
||
174 | * @expectedException RuntimeException |
||
175 | */ |
||
176 | public function testHandleResponseFailure() |
||
182 | |||
183 | public function testHandleResponseSuccess() |
||
191 | |||
192 | /** |
||
193 | * Mock Response. |
||
194 | * |
||
195 | * @param string $body |
||
196 | * @param int $status |
||
197 | * |
||
198 | * @return HttpResponse |
||
199 | */ |
||
200 | protected function getMockedResponse($body = null, $status = Response::HTTP_OK) |
||
218 | } |
||
219 |
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.