-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
136 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
/** | ||
* @author Kevin Bond <[email protected]> | ||
*/ | ||
class AcceleratorCacheClearerTest extends \PHPUnit_Framework_TestCase | ||
class AcceleratorCacheClearerTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testClearCache() | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
/** | ||
* @author Kevin Bond <[email protected]> | ||
*/ | ||
class CacheClearerServiceTest extends \PHPUnit_Framework_TestCase | ||
class CacheClearerServiceTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
/** | ||
* @expectedException \RuntimeException | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,50 +9,46 @@ | |
/** | ||
* @author Kevin Bond <[email protected]> | ||
*/ | ||
class AcceleratorCacheClearCommandTest extends \PHPUnit_Framework_TestCase | ||
class AcceleratorCacheClearCommandTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testClearCache() | ||
{ | ||
$cacheClearer = $this->getMock('SmartCore\Bundle\AcceleratorCacheBundle\CacheClearerService', array(), array(), '', false); | ||
$cacheClearer = $this->createCacheClearer(); | ||
$cacheClearer->expects($this->once()) | ||
->method('clearCache') | ||
->with(true, true) | ||
->willReturn(array('success' => true, 'message' => 'foobar')); | ||
|
||
$container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); | ||
$container->expects($this->once()) | ||
->method('get') | ||
->with('accelerator_cache.clearer') | ||
->willReturn($cacheClearer); | ||
|
||
$this->assertContains('(Web) foobar', $this->createCommandTester(array(), $container)->getDisplay()); | ||
$this->assertContains('(Web) foobar', $this->createCommandTester($cacheClearer, array())->getDisplay()); | ||
} | ||
|
||
public function testCliClearUser() | ||
{ | ||
$commandTester = $this->createCommandTester(array('--cli' => true, '--user' => true)); | ||
$commandTester = $this->createCommandTester($this->createCacheClearer(), array('--cli' => true, '--user' => true)); | ||
|
||
$this->assertContains('(cli) Clear PHP Accelerator Cache... APC User Cache: success.', $commandTester->getDisplay()); | ||
} | ||
|
||
public function testCliClearOpcode() | ||
{ | ||
if (PHP_VERSION_ID >= 50500) { | ||
$this->setExpectedException('\RuntimeException', 'Clear PHP Accelerator Cache... Opcode Cache: failure.'); | ||
$this->createCommandTester(array('--cli' => true, '--opcode' => true)); | ||
$this->expectException('\RuntimeException'); | ||
$this->expectExceptionMessage('Clear PHP Accelerator Cache... Opcode Cache: failure.'); | ||
$this->createCommandTester($this->createCacheClearer(), array('--cli' => true, '--opcode' => true)); | ||
} else { | ||
$commandTester = $this->createCommandTester(array('--cli' => true, '--opcode' => true)); | ||
$this->assertContains('(cli) Clear PHP Accelerator Cache... APC Opcode Cache: success.', $commandTester->getDisplay()); | ||
} | ||
} | ||
|
||
private function createCommandTester(array $options = array(), $container = null) | ||
private function createCacheClearer() | ||
{ | ||
$command = new AcceleratorCacheClearCommand(); | ||
return $this->createMock('SmartCore\Bundle\AcceleratorCacheBundle\CacheClearerService'); | ||
} | ||
|
||
if ($container) { | ||
$command->setContainer($container); | ||
} | ||
private function createCommandTester($cacheClearer, array $options = array()) | ||
{ | ||
$command = new AcceleratorCacheClearCommand($cacheClearer); | ||
|
||
$application = new Application(); | ||
$application->add($command); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters