1616namespace Phpfastcache \Bundle \Tests \Command ;
1717
1818use Phpfastcache \Bundle \Service \Phpfastcache ;
19+ use Phpfastcache \CacheManager ;
1920use Phpfastcache \Core \Item \ExtendedCacheItemInterface ;
2021use Phpfastcache \Core \Pool \ExtendedCacheItemPoolInterface ;
2122use PHPUnit \Framework \MockObject \MockObject ;
2223use PHPUnit \Framework \TestCase ;
2324use Symfony \Bundle \FrameworkBundle \Console \Application ;
2425use Symfony \Component \HttpKernel \Kernel ;
26+ use Symfony \Component \Yaml \Yaml ;
2527
2628/**
2729 * Base Class for command tests
3133abstract class CommandTestCase extends TestCase
3234{
3335
36+ protected $ ymlConfigFile = __DIR__ . '/../Resources/Config/phpfastcache.yaml ' ;
37+
3438 /**
3539 * @var \Symfony\Bundle\FrameworkBundle\Console\Application
3640 */
@@ -57,6 +61,8 @@ abstract class CommandTestCase extends TestCase
5761 */
5862 public function setUp ()
5963 {
64+ CacheManager::clearInstances ();
65+ putenv ('COLUMNS=200 ' );// Prevent broken console rendering with unit tests
6066 $ this ->container = $ this ->getMockBuilder ('\\Symfony \\Component \\DependencyInjection \\ContainerInterface ' )->getMock ();
6167
6268 /** @var Kernel|MockObject $kernel */
@@ -71,26 +77,9 @@ public function setUp()
7177 ->will ($ this ->returnValue ($ this ->container ));
7278 $ this ->application = new Application ($ kernel );
7379
74- $ this ->phpfastcacheParameters = [
75- 'twig_driver ' => 'filecache ' ,
76- 'twig_block_debug ' => true ,
77- 'drivers ' =>
78- [
79- 'filecache ' =>
80- [
81- 'type ' => 'Files ' ,
82- 'parameters ' =>
83- [
84- 'path ' => \sys_get_temp_dir () . '/phpfastcache/ ' ,
85- ],
86- ],
87- 'staticcache ' =>
88- [
89- 'type ' => 'Memstatic ' ,
90- 'parameters ' => [],
91- ],
92- ],
93- ];
80+ $ parameters = Yaml::parse (\file_get_contents ($ this ->ymlConfigFile ));
81+
82+ $ this ->phpfastcacheParameters = $ parameters ['phpfastcache ' ];
9483
9584 $ this ->phpfastcache = new Phpfastcache ($ this ->phpfastcacheParameters );
9685
0 commit comments