]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/CacheTest.php
lint: apply phpcbf to tests/
[github/shaarli/Shaarli.git] / tests / CacheTest.php
index aa5395b0ab8f16b1906dfa8ece3b1976a43d9d94..f60fad91099048ba5d1c8c2d3d34289175880a4f 100644 (file)
@@ -11,10 +11,10 @@ require_once 'application/Cache.php';
 /**
  * Unitary tests for cached pages
  */
-class CachedTest extends PHPUnit_Framework_TestCase
+class CacheTest extends PHPUnit_Framework_TestCase
 {
     // test cache directory
-    protected static $testCacheDir = 'tests/dummycache';
+    protected static $testCacheDir = 'sandbox/dummycache';
 
     // dummy cached file names / content
     protected static $pages = array('a', 'toto', 'd7b59c');
@@ -30,13 +30,22 @@ class CachedTest extends PHPUnit_Framework_TestCase
         } else {
             array_map('unlink', glob(self::$testCacheDir.'/*'));
         }
-        
+
         foreach (self::$pages as $page) {
             file_put_contents(self::$testCacheDir.'/'.$page.'.cache', $page);
         }
         file_put_contents(self::$testCacheDir.'/intru.der', 'ShouldNotBeThere');
     }
 
+    /**
+     * Remove dummycache folder after each tests.
+     */
+    public function tearDown()
+    {
+        array_map('unlink', glob(self::$testCacheDir.'/*'));
+        rmdir(self::$testCacheDir);
+    }
+
     /**
      * Purge cached pages
      */
@@ -55,10 +64,13 @@ class CachedTest extends PHPUnit_Framework_TestCase
      */
     public function testPurgeCachedPagesMissingDir()
     {
+        $oldlog = ini_get('error_log');
+        ini_set('error_log', '/dev/null');
         $this->assertEquals(
-            'Cannot purge tests/dummycache_missing: no directory',
+            'Cannot purge sandbox/dummycache_missing: no directory',
             purgeCachedPages(self::$testCacheDir.'_missing')
         );
+        ini_set('error_log', $oldlog);
     }
 
     /**
@@ -72,7 +84,7 @@ class CachedTest extends PHPUnit_Framework_TestCase
         invalidateCaches(self::$testCacheDir);
         foreach (self::$pages as $page) {
             $this->assertFileNotExists(self::$testCacheDir.'/'.$page.'.cache');
-        }        
+        }
 
         $this->assertArrayNotHasKey('tags', $_SESSION);
     }