Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2013-01-27 00:41:14 +0400
committerRobin Appelman <icewind@owncloud.com>2013-01-27 00:44:33 +0400
commit177537dbccac7c30ab42dfee56e92974e5cdf042 (patch)
tree5f312a204c65dd3489e38f105831a682b8481166 /tests
parent7237ebf08b5a20fe6072a99be33f3520d4bf3871 (diff)
Cache: port test cases to PHPUnit
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/files/cache/cache.php42
-rw-r--r--tests/lib/files/cache/scanner.php52
2 files changed, 47 insertions, 47 deletions
diff --git a/tests/lib/files/cache/cache.php b/tests/lib/files/cache/cache.php
index a2b131ac0ac..96a7623dac5 100644
--- a/tests/lib/files/cache/cache.php
+++ b/tests/lib/files/cache/cache.php
@@ -8,7 +8,7 @@
namespace Test\Files\Cache;
-class Cache extends \UnitTestCase {
+class Cache extends \PHPUnit_Framework_TestCase {
/**
* @var \OC\Files\Storage\Temporary $storage;
*/
@@ -26,56 +26,56 @@ class Cache extends \UnitTestCase {
$data2 = array('size' => 1000, 'mtime' => 20, 'mimetype' => 'foo/file');
$this->assertFalse($this->cache->inCache($file1));
- $this->assertEqual($this->cache->get($file1), null);
+ $this->assertEquals($this->cache->get($file1), null);
$id1 = $this->cache->put($file1, $data1);
$this->assertTrue($this->cache->inCache($file1));
$cacheData1 = $this->cache->get($file1);
foreach ($data1 as $key => $value) {
- $this->assertEqual($value, $cacheData1[$key]);
+ $this->assertEquals($value, $cacheData1[$key]);
}
- $this->assertEqual($cacheData1['mimepart'], 'foo');
- $this->assertEqual($cacheData1['fileid'], $id1);
- $this->assertEqual($id1, $this->cache->getId($file1));
+ $this->assertEquals($cacheData1['mimepart'], 'foo');
+ $this->assertEquals($cacheData1['fileid'], $id1);
+ $this->assertEquals($id1, $this->cache->getId($file1));
$this->assertFalse($this->cache->inCache($file2));
$id2 = $this->cache->put($file2, $data2);
$this->assertTrue($this->cache->inCache($file2));
$cacheData2 = $this->cache->get($file2);
foreach ($data2 as $key => $value) {
- $this->assertEqual($value, $cacheData2[$key]);
+ $this->assertEquals($value, $cacheData2[$key]);
}
- $this->assertEqual($cacheData1['fileid'], $cacheData2['parent']);
- $this->assertEqual($cacheData2['fileid'], $id2);
- $this->assertEqual($id2, $this->cache->getId($file2));
- $this->assertEqual($id1, $this->cache->getParentId($file2));
+ $this->assertEquals($cacheData1['fileid'], $cacheData2['parent']);
+ $this->assertEquals($cacheData2['fileid'], $id2);
+ $this->assertEquals($id2, $this->cache->getId($file2));
+ $this->assertEquals($id1, $this->cache->getParentId($file2));
$newSize = 1050;
$newId2 = $this->cache->put($file2, array('size' => $newSize));
$cacheData2 = $this->cache->get($file2);
- $this->assertEqual($newId2, $id2);
- $this->assertEqual($cacheData2['size'], $newSize);
- $this->assertEqual($cacheData1, $this->cache->get($file1));
+ $this->assertEquals($newId2, $id2);
+ $this->assertEquals($cacheData2['size'], $newSize);
+ $this->assertEquals($cacheData1, $this->cache->get($file1));
$this->cache->remove($file2);
$this->assertFalse($this->cache->inCache($file2));
- $this->assertEqual($this->cache->get($file2), null);
+ $this->assertEquals($this->cache->get($file2), null);
$this->assertTrue($this->cache->inCache($file1));
- $this->assertEqual($cacheData1, $this->cache->get($id1));
+ $this->assertEquals($cacheData1, $this->cache->get($id1));
}
public function testPartial() {
$file1 = 'foo';
$this->cache->put($file1, array('size' => 10));
- $this->assertEqual(array('size' => 10), $this->cache->get($file1));
+ $this->assertEquals(array('size' => 10), $this->cache->get($file1));
$this->cache->put($file1, array('mtime' => 15));
- $this->assertEqual(array('size' => 10, 'mtime' => 15), $this->cache->get($file1));
+ $this->assertEquals(array('size' => 10, 'mtime' => 15), $this->cache->get($file1));
$this->cache->put($file1, array('size' => 12));
- $this->assertEqual(array('size' => 12, 'mtime' => 15), $this->cache->get($file1));
+ $this->assertEquals(array('size' => 12, 'mtime' => 15), $this->cache->get($file1));
}
public function testFolder() {
@@ -92,11 +92,11 @@ class Cache extends \UnitTestCase {
$this->cache->put($file3, $fileData['foo']);
$content = $this->cache->getFolderContents($file1);
- $this->assertEqual(count($content), 2);
+ $this->assertEquals(count($content), 2);
foreach ($content as $cachedData) {
$data = $fileData[$cachedData['name']];
foreach ($data as $name => $value) {
- $this->assertEqual($value, $cachedData[$name]);
+ $this->assertEquals($value, $cachedData[$name]);
}
}
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php
index 6d26150d82b..3885c99e6d3 100644
--- a/tests/lib/files/cache/scanner.php
+++ b/tests/lib/files/cache/scanner.php
@@ -8,7 +8,7 @@
namespace Test\Files\Cache;
-class Scanner extends \UnitTestCase {
+class Scanner extends \PHPUnit_Framework_TestCase {
/**
* @var \OC\Files\Storage\Storage $storage
*/
@@ -29,20 +29,20 @@ class Scanner extends \UnitTestCase {
$this->storage->file_put_contents('foo.txt', $data);
$this->scanner->scanFile('foo.txt');
- $this->assertEqual($this->cache->inCache('foo.txt'), true);
+ $this->assertEquals($this->cache->inCache('foo.txt'), true);
$cachedData = $this->cache->get('foo.txt');
- $this->assertEqual($cachedData['size'], strlen($data));
- $this->assertEqual($cachedData['mimetype'], 'text/plain');
- $this->assertNotEqual($cachedData['parent'], -1); //parent folders should be scanned automatically
+ $this->assertEquals($cachedData['size'], strlen($data));
+ $this->assertEquals($cachedData['mimetype'], 'text/plain');
+ $this->assertNotEquals($cachedData['parent'], -1); //parent folders should be scanned automatically
$data = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png');
$this->storage->file_put_contents('foo.png', $data);
$this->scanner->scanFile('foo.png');
- $this->assertEqual($this->cache->inCache('foo.png'), true);
+ $this->assertEquals($this->cache->inCache('foo.png'), true);
$cachedData = $this->cache->get('foo.png');
- $this->assertEqual($cachedData['size'], strlen($data));
- $this->assertEqual($cachedData['mimetype'], 'image/png');
+ $this->assertEquals($cachedData['size'], strlen($data));
+ $this->assertEquals($cachedData['mimetype'], 'image/png');
}
private function fillTestFolders() {
@@ -58,11 +58,11 @@ class Scanner extends \UnitTestCase {
$this->fillTestFolders();
$this->scanner->scan('');
- $this->assertEqual($this->cache->inCache(''), true);
- $this->assertEqual($this->cache->inCache('foo.txt'), true);
- $this->assertEqual($this->cache->inCache('foo.png'), true);
- $this->assertEqual($this->cache->inCache('folder'), true);
- $this->assertEqual($this->cache->inCache('folder/bar.txt'), true);
+ $this->assertEquals($this->cache->inCache(''), true);
+ $this->assertEquals($this->cache->inCache('foo.txt'), true);
+ $this->assertEquals($this->cache->inCache('foo.png'), true);
+ $this->assertEquals($this->cache->inCache('folder'), true);
+ $this->assertEquals($this->cache->inCache('folder/bar.txt'), true);
$cachedDataText = $this->cache->get('foo.txt');
$cachedDataText2 = $this->cache->get('foo.txt');
@@ -70,38 +70,38 @@ class Scanner extends \UnitTestCase {
$cachedDataFolder = $this->cache->get('');
$cachedDataFolder2 = $this->cache->get('folder');
- $this->assertEqual($cachedDataImage['parent'], $cachedDataText['parent']);
- $this->assertEqual($cachedDataFolder['fileid'], $cachedDataImage['parent']);
- $this->assertEqual($cachedDataFolder['size'], $cachedDataImage['size'] + $cachedDataText['size'] + $cachedDataText2['size']);
- $this->assertEqual($cachedDataFolder2['size'], $cachedDataText2['size']);
+ $this->assertEquals($cachedDataImage['parent'], $cachedDataText['parent']);
+ $this->assertEquals($cachedDataFolder['fileid'], $cachedDataImage['parent']);
+ $this->assertEquals($cachedDataFolder['size'], $cachedDataImage['size'] + $cachedDataText['size'] + $cachedDataText2['size']);
+ $this->assertEquals($cachedDataFolder2['size'], $cachedDataText2['size']);
}
function testShallow() {
$this->fillTestFolders();
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW);
- $this->assertEqual($this->cache->inCache(''), true);
- $this->assertEqual($this->cache->inCache('foo.txt'), true);
- $this->assertEqual($this->cache->inCache('foo.png'), true);
- $this->assertEqual($this->cache->inCache('folder'), true);
- $this->assertEqual($this->cache->inCache('folder/bar.txt'), false);
+ $this->assertEquals($this->cache->inCache(''), true);
+ $this->assertEquals($this->cache->inCache('foo.txt'), true);
+ $this->assertEquals($this->cache->inCache('foo.png'), true);
+ $this->assertEquals($this->cache->inCache('folder'), true);
+ $this->assertEquals($this->cache->inCache('folder/bar.txt'), false);
$cachedDataFolder = $this->cache->get('');
$cachedDataFolder2 = $this->cache->get('folder');
- $this->assertEqual(-1, $cachedDataFolder['size']);
- $this->assertEqual(-1, $cachedDataFolder2['size']);
+ $this->assertEquals(-1, $cachedDataFolder['size']);
+ $this->assertEquals(-1, $cachedDataFolder2['size']);
$this->scanner->scan('folder', \OC\Files\Cache\Scanner::SCAN_SHALLOW);
$cachedDataFolder2 = $this->cache->get('folder');
- $this->assertNotEqual($cachedDataFolder2['size'], -1);
+ $this->assertNotEquals($cachedDataFolder2['size'], -1);
$this->cache->correctFolderSize('folder');
$cachedDataFolder = $this->cache->get('');
- $this->assertNotEqual($cachedDataFolder['size'], -1);
+ $this->assertNotEquals($cachedDataFolder['size'], -1);
}
function testBackgroundScan(){