'File', 'path' => CACHE]); } /** * Teardown * * @return void */ public function tearDown() { parent::tearDown(); Cache::drop('test'); } /** * Test that getOptionParser() returns an instance of \Cake\Console\ConsoleOptionParser * * @return void */ public function testGetOptionParser() { $this->exec('cache -h'); $this->assertExitCode(Shell::CODE_SUCCESS); $this->assertOutputContains('list_prefixes'); $this->assertOutputContains('clear_all'); } /** * Test that clear() throws \Cake\Console\Exception\StopException if cache prefix is invalid * * @return void */ public function testClearInvalidPrefix() { $this->exec('cache clear foo'); $this->assertExitCode(Shell::CODE_ERROR); $this->assertErrorContains('The "foo" cache configuration does not exist'); } /** * Test that clear() clears the specified cache when a valid prefix is used * * @return void */ public function testClearValidPrefix() { Cache::add('key', 'value', 'test'); $this->exec('cache clear test'); $this->assertExitCode(Shell::CODE_SUCCESS); $this->assertFalse(Cache::read('key', 'test')); } /** * Test that clear() only clears the specified cache * * @return void */ public function testClearIgnoresOtherCaches() { Cache::add('key', 'value', 'test'); $this->exec('cache clear _cake_core_'); $this->assertExitCode(Shell::CODE_SUCCESS); $this->assertEquals('value', Cache::read('key', 'test')); } /** * Test that clearAll() clears values from all defined caches * * @return void */ public function testClearAll() { Cache::add('key', 'value1', 'test'); Cache::add('key', 'value3', '_cake_core_'); $this->exec('cache clear_all'); $this->assertExitCode(Shell::CODE_SUCCESS); $this->assertFalse(Cache::read('key', 'test')); $this->assertFalse(Cache::read('key', '_cake_core_')); } }