/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The following requested cache types are not supported: */ public function testExecuteInvalidCacheType() { $this->cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']); $param = ['types' => ['A', 'D']]; $commandTester = new CommandTester($this->command); $commandTester->execute($param); }
public function testExecuteAllCacheType() { $this->cacheManager->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']); $this->cacheManager->expects($this->once())->method('clean')->with(['A', 'B', 'C']); $param = ['--all' => true]; $commandTester = new CommandTester($this->command); $commandTester->execute($param); $expect = 'Cleaned cache types:' . PHP_EOL . 'A' . PHP_EOL . 'B' . PHP_EOL . 'C' . PHP_EOL; $this->assertEquals($expect, $commandTester->getDisplay()); }
public function testLaunchAll() { $requestArgs = [ManagerApp::KEY_SET => true, ManagerApp::KEY_FLUSH => true, ManagerApp::KEY_CLEAN => true, ManagerApp::KEY_TYPES => 'foo,baz']; $this->cacheManager->expects($this->once())->method('setEnabled')->with(['foo', 'baz'], true)->will($this->returnValue(['baz'])); $this->cacheManager->expects($this->once())->method('flush')->with(['foo', 'baz']); $this->cacheManager->expects($this->never())->method('clean'); $this->response->expects($this->once())->method('setBody')->with($this->matches("Changed cache status:\n%abaz: 0 -> 1%aFlushed cache types:\nfoo\nbaz")); $model = new ManagerApp($this->cacheManager, $this->response, $requestArgs); $model->launch(); }
public function testExecute() { $cacheTypes = ['A' => 0, 'B' => 1, 'C' => 1]; $this->cacheManager->expects($this->once())->method('getStatus')->willReturn($cacheTypes); $commandTester = new CommandTester($this->command); $commandTester->execute([]); $expect = 'Current status:' . PHP_EOL; foreach ($cacheTypes as $cacheType => $status) { $expect .= sprintf('%30s: %d', $cacheType, $status) . PHP_EOL; } $this->assertEquals($expect, $commandTester->getDisplay()); }