Permalink
Browse files

Cache: added tests for get[Total|Avail]Space

  • Loading branch information...
marc-mabe authored and weierophinney committed Oct 4, 2012
1 parent f430f31 commit 023afbb02018b3239662fab05a256b934f64e06f
Showing with 32 additions and 0 deletions.
  1. +32 −0 tests/ZendTest/Cache/Storage/Adapter/CommonAdapterTest.php
@@ -19,6 +19,8 @@
use Zend\Cache\Storage\FlushableInterface;
use Zend\Cache\Storage\OptimizableInterface;
use Zend\Cache\Storage\TaggableInterface;
+use Zend\Cache\Storage\AvailableSpaceCapableInterface;
+use Zend\Cache\Storage\TotalSpaceCapableInterface;
use Zend\Http\Header\Expires;
use Zend\Stdlib\ErrorHandler;
@@ -1033,4 +1035,34 @@ public function testTagable()
$this->assertFalse($this->_storage->hasItem('key2'));
$this->assertFalse($this->_storage->hasItem('key3'));
}
+
+ public function testGetTotalSpace()
+ {
+ if (!($this->_storage instanceof TotalSpaceCapableInterface)) {
+ $this->markTestSkipped("Storage doesn't implement TotalSpaceCapableInterface");
+ }
+
+ $totalSpace = $this->_storage->getTotalSpace();
+ $this->assertGreaterThan(0, $totalSpace);
+
+ if ($this->_storage instanceof AvailableSpaceCapableInterface) {
+ $availableSpace = $this->_storage->getAvailableSpace();
+ $this->assertGreaterThanOrEqual($availableSpace, $totalSpace);
+ }
+ }
+
+ public function testGetAvailableSpace()
+ {
+ if (!($this->_storage instanceof AvailableSpaceCapableInterface)) {
+ $this->markTestSkipped("Storage doesn't implement AvailableSpaceCapableInterface");
+ }
+
+ $availableSpace = $this->_storage->getAvailableSpace();
+ $this->assertGreaterThanOrEqual(0, $availableSpace);
+
+ if ($this->_storage instanceof TotalSpaceCapableInterface) {
+ $totalSpace = $this->_storage->getTotalSpace();
+ $this->assertLessThanOrEqual($totalSpace, $availableSpace);
+ }
+ }
}

0 comments on commit 023afbb

Please sign in to comment.