init without trunk
This commit is contained in:
parent
ed24ac4994
commit
bb809e7233
14652 changed files with 177862 additions and 94817 deletions
91
vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Command/CommandTestCase.php
vendored
Normal file
91
vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Command/CommandTestCase.php
vendored
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command;
|
||||
|
||||
use Doctrine\Bundle\DoctrineCacheBundle\Tests\FunctionalTestCase;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
||||
use Doctrine\Common\Cache\Cache;
|
||||
use Doctrine\Bundle\DoctrineCacheBundle\Command\CacheCommand;
|
||||
|
||||
class CommandTestCase extends FunctionalTestCase
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $cacheProviderClass = 'Doctrine\Common\Cache\ArrayCache';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $cacheName = 'my_array_cache';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $cacheId = 'test_cache_id';
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\Common\Cache\Cache
|
||||
*/
|
||||
protected $provider;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\HttpKernel\Kernel
|
||||
*/
|
||||
protected $kernel;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Bundle\FrameworkBundle\Console\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->container = $this->compileContainer('array');
|
||||
$this->provider = $this->container->get('doctrine_cache.providers.' . $this->cacheName);
|
||||
$this->kernel = $this->getMockKernel();
|
||||
$this->app = new Application($this->kernel);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\Bundle\DoctrineCacheBundle\Command\CacheCommand $command
|
||||
*
|
||||
* @return \Symfony\Component\Console\Tester\CommandTester
|
||||
*/
|
||||
protected function getTester(CacheCommand $command)
|
||||
{
|
||||
$command->setContainer($this->container);
|
||||
$command->setApplication($this->app);
|
||||
|
||||
return new CommandTester($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Kernel mock instance
|
||||
*
|
||||
* @return \Symfony\Component\HttpKernel\Kernel
|
||||
*/
|
||||
private function getMockKernel()
|
||||
{
|
||||
$mock = $this->getMock('\Symfony\Component\HttpKernel\Kernel', array(), array(), '', false, false);
|
||||
$mock->method('getBundles')->willReturn(array());
|
||||
$mock->method('getContainer')->willReturn($this->container);
|
||||
return $mock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Filesystem mock instance
|
||||
*
|
||||
* @return \Symfony\Bundle\FrameworkBundle\Util\Filesystem
|
||||
*/
|
||||
private function getMockFilesystem()
|
||||
{
|
||||
return $this->getMock('\Symfony\Bundle\FrameworkBundle\Util\Filesystem', array(), array(), '', false, false);
|
||||
}
|
||||
}
|
||||
60
vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Command/ContainsCommandTest.php
vendored
Normal file
60
vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Command/ContainsCommandTest.php
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command;
|
||||
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand;
|
||||
|
||||
/**
|
||||
* Functional test for delete command.
|
||||
*
|
||||
* @author Alan Doucette <dragonwize@gmail.com>
|
||||
*/
|
||||
class ContainsCommandTest extends CommandTestCase
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\Bundle\DoctrineCacheBundle\Command\ContainsCommand
|
||||
*/
|
||||
protected $command;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Console\Tester\CommandTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->command = new ContainsCommand();
|
||||
$this->tester = $this->getTester($this->command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a cache does not contain an entry.
|
||||
*/
|
||||
public function testContainsFalse()
|
||||
{
|
||||
$this->tester->execute(array(
|
||||
'cache-name' => $this->cacheName,
|
||||
'cache-id' => $this->cacheId,
|
||||
));
|
||||
$this->assertEquals("FALSE\n", $this->tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if a cache contains an entry.
|
||||
*/
|
||||
public function testContainsTrue()
|
||||
{
|
||||
$this->provider->save($this->cacheId, 'hello world');
|
||||
$this->tester->execute(array(
|
||||
'cache-name' => $this->cacheName,
|
||||
'cache-id' => $this->cacheId,
|
||||
));
|
||||
$this->assertEquals("TRUE\n", $this->tester->getDisplay());
|
||||
}
|
||||
}
|
||||
61
vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Command/DeleteCommandTest.php
vendored
Normal file
61
vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Command/DeleteCommandTest.php
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command;
|
||||
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Doctrine\Bundle\DoctrineCacheBundle\Command\DeleteCommand;
|
||||
|
||||
/**
|
||||
* Functional test for delete command.
|
||||
*
|
||||
* @author Alan Doucette <dragonwize@gmail.com>
|
||||
*/
|
||||
class DeleteCommandTest extends CommandTestCase
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\Bundle\DoctrineCacheBundle\Command\DeleteCommand
|
||||
*/
|
||||
protected $command;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Console\Tester\CommandTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->command = new DeleteCommand();
|
||||
$this->tester = $this->getTester($this->command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a cache delete success.
|
||||
*/
|
||||
public function testDeleteSuccess()
|
||||
{
|
||||
$this->provider->save($this->cacheId, 'hello world');
|
||||
$this->tester->execute(array(
|
||||
'cache-name' => $this->cacheName,
|
||||
'cache-id' => $this->cacheId,
|
||||
));
|
||||
$this->assertEquals("Deletion of {$this->cacheId} in {$this->cacheName} has succeeded\n", $this->tester->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a cache delete all.
|
||||
*/
|
||||
public function testDeleteAll()
|
||||
{
|
||||
$this->tester->execute(array(
|
||||
'cache-name' => $this->cacheName,
|
||||
'cache-id' => $this->cacheId,
|
||||
'--all' => true
|
||||
));
|
||||
$this->assertEquals("Deletion of all entries in {$this->cacheName} has succeeded\n", $this->tester->getDisplay());
|
||||
}
|
||||
}
|
||||
46
vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Command/FlushCommandTest.php
vendored
Normal file
46
vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Command/FlushCommandTest.php
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command;
|
||||
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Doctrine\Bundle\DoctrineCacheBundle\Command\FlushCommand;
|
||||
|
||||
/**
|
||||
* Functional test for delete command.
|
||||
*
|
||||
* @author Alan Doucette <dragonwize@gmail.com>
|
||||
*/
|
||||
class FlushCommandTest extends CommandTestCase
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\Bundle\DoctrineCacheBundle\Command\FlushCommand
|
||||
*/
|
||||
protected $command;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Console\Tester\CommandTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->command = new FlushCommand();
|
||||
$this->tester = $this->getTester($this->command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests flushing a cache.
|
||||
*/
|
||||
public function testFlush()
|
||||
{
|
||||
$this->tester->execute(array(
|
||||
'cache-name' => $this->cacheName,
|
||||
));
|
||||
$this->assertEquals("Clearing the cache for the {$this->cacheName} provider of type {$this->cacheProviderClass}\n", $this->tester->getDisplay());
|
||||
}
|
||||
}
|
||||
63
vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Command/StatsCommandTest.php
vendored
Normal file
63
vendor/doctrine/doctrine-cache-bundle/Tests/Functional/Command/StatsCommandTest.php
vendored
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?php
|
||||
|
||||
namespace Doctrine\Bundle\DoctrineCacheBundle\Tests\Functional\Command;
|
||||
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Doctrine\Bundle\DoctrineCacheBundle\Command\StatsCommand;
|
||||
|
||||
/**
|
||||
* Functional test for delete command.
|
||||
*
|
||||
* @author Alan Doucette <dragonwize@gmail.com>
|
||||
*/
|
||||
class StatsCommandTest extends CommandTestCase
|
||||
{
|
||||
/**
|
||||
* @var \Doctrine\Bundle\DoctrineCacheBundle\Command\StatsCommand
|
||||
*/
|
||||
protected $command;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\Console\Tester\CommandTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->command = new StatsCommand();
|
||||
$this->tester = $this->getTester($this->command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests getting cache provider stats.
|
||||
*/
|
||||
public function testStats()
|
||||
{
|
||||
$this->tester->execute(array(
|
||||
'cache-name' => $this->cacheName,
|
||||
));
|
||||
|
||||
$stats = $this->tester->getDisplay();
|
||||
|
||||
if (strpos($stats, 'Stats were not') === false) {
|
||||
// This test is for Doctrine/Cache >= 1.6.0 only
|
||||
$this->assertStringStartsWith(
|
||||
"Stats for the {$this->cacheName} provider of type Doctrine\\Common\\Cache\\ArrayCache:",
|
||||
$stats
|
||||
);
|
||||
$this->assertContains("[hits] 0\n", $stats);
|
||||
$this->assertContains("[misses] 0\n", $stats);
|
||||
$this->assertRegExp('/\[uptime\] [0-9]{10}' . "\n/", $stats);
|
||||
$this->assertContains("[memory_usage] \n", $stats);
|
||||
$this->assertContains("[memory_available] \n", $stats);
|
||||
} else {
|
||||
// This test is for Doctrine/Cache < 1.6.0 only
|
||||
$this->assertEquals("Stats were not provided for the {$this->cacheName} provider of type Doctrine\\Common\\Cache\\ArrayCache\n", $this->tester->getDisplay());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue