summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJörn Friedrich Dreyer <jfd@butonic.de>2014-02-27 09:39:34 +0100
committerJörn Friedrich Dreyer <jfd@butonic.de>2014-02-27 09:39:34 +0100
commit39f2f564a99ebe719748f349aafe92ed9910bc0b (patch)
treeb6b2b469ed8708e194cc0b46bb6de96ed8c3702a
parent7f05c23231b7f77ccc155cdc229e1ae21267e0e5 (diff)
downloadnextcloud-server-39f2f564a99ebe719748f349aafe92ed9910bc0b.tar.gz
nextcloud-server-39f2f564a99ebe719748f349aafe92ed9910bc0b.zip
use assertSame and assertNotSame for etag checks
-rwxr-xr-xapps/files_encryption/tests/util.php4
-rw-r--r--tests/lib/appframework/http/ResponseTest.php2
-rw-r--r--tests/lib/files/cache/scanner.php26
-rw-r--r--tests/lib/files/etagtest.php6
-rw-r--r--tests/lib/files/view.php2
5 files changed, 27 insertions, 13 deletions
diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php
index f70e30c4d73..203ba55dbfd 100755
--- a/apps/files_encryption/tests/util.php
+++ b/apps/files_encryption/tests/util.php
@@ -344,7 +344,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
// check if mtime and etags unchanged
$this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
- $this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
+ $this->assertSame($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
$this->view->unlink($this->userId . '/files/' . $filename);
}
@@ -373,7 +373,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase {
// check if mtime and etags unchanged
$this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']);
- $this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
+ $this->assertSame($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']);
// file should no longer be encrypted
$this->assertEquals(0, $fileInfoUnencrypted['encrypted']);
diff --git a/tests/lib/appframework/http/ResponseTest.php b/tests/lib/appframework/http/ResponseTest.php
index 4f21d77a170..063ab8b5d33 100644
--- a/tests/lib/appframework/http/ResponseTest.php
+++ b/tests/lib/appframework/http/ResponseTest.php
@@ -78,7 +78,7 @@ class ResponseTest extends \PHPUnit_Framework_TestCase {
public function testGetEtag() {
$this->childResponse->setEtag('hi');
- $this->assertEquals('hi', $this->childResponse->getEtag());
+ $this->assertSame('hi', $this->childResponse->getEtag());
}
diff --git a/tests/lib/files/cache/scanner.php b/tests/lib/files/cache/scanner.php
index 3f5604b4d45..9df98c36fa8 100644
--- a/tests/lib/files/cache/scanner.php
+++ b/tests/lib/files/cache/scanner.php
@@ -150,13 +150,15 @@ class Scanner extends \PHPUnit_Framework_TestCase {
$this->cache->put('folder', array('mtime' => $this->storage->filemtime('folder'), 'storage_mtime' => $this->storage->filemtime('folder')));
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_SIZE);
$newData = $this->cache->get('');
- $this->assertNotEquals($oldData['etag'], $newData['etag']);
+ $this->assertTrue(is_string($oldData['etag']), 'Expected a string');
+ $this->assertTrue(is_string($newData['etag']), 'Expected a string');
+ $this->assertNotSame($oldData['etag'], $newData['etag']);
$this->assertEquals($oldData['size'], $newData['size']);
$oldData = $newData;
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG);
$newData = $this->cache->get('');
- $this->assertEquals($oldData['etag'], $newData['etag']);
+ $this->assertSame($oldData['etag'], $newData['etag']);
$this->assertEquals(-1, $newData['size']);
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE);
@@ -164,17 +166,17 @@ class Scanner extends \PHPUnit_Framework_TestCase {
$this->assertNotEquals(-1, $oldData['size']);
$this->scanner->scanFile('', \OC\Files\Cache\Scanner::REUSE_ETAG + \OC\Files\Cache\Scanner::REUSE_SIZE);
$newData = $this->cache->get('');
- $this->assertEquals($oldData['etag'], $newData['etag']);
+ $this->assertSame($oldData['etag'], $newData['etag']);
$this->assertEquals($oldData['size'], $newData['size']);
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG + \OC\Files\Cache\Scanner::REUSE_SIZE);
$newData = $this->cache->get('');
- $this->assertEquals($oldData['etag'], $newData['etag']);
+ $this->assertSame($oldData['etag'], $newData['etag']);
$this->assertEquals($oldData['size'], $newData['size']);
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG + \OC\Files\Cache\Scanner::REUSE_SIZE);
$newData = $this->cache->get('');
- $this->assertEquals($oldData['etag'], $newData['etag']);
+ $this->assertSame($oldData['etag'], $newData['etag']);
$this->assertEquals($oldData['size'], $newData['size']);
}
@@ -217,8 +219,11 @@ class Scanner extends \PHPUnit_Framework_TestCase {
// manipulate etag to simulate an empty etag
$this->scanner->scan('', \OC\Files\Cache\Scanner::SCAN_SHALLOW, \OC\Files\Cache\Scanner::REUSE_ETAG);
$data0 = $this->cache->get('folder/bar.txt');
+ $this->assertTrue(is_string($data0['etag']), 'Expected a string');
$data1 = $this->cache->get('folder');
+ $this->assertTrue(is_string($data1['etag']), 'Expected a string');
$data2 = $this->cache->get('');
+ $this->assertTrue(is_string($data2['etag']), 'Expected a string');
$data0['etag'] = '';
$this->cache->put('folder/bar.txt', $data0);
@@ -227,10 +232,15 @@ class Scanner extends \PHPUnit_Framework_TestCase {
// verify cache content
$newData0 = $this->cache->get('folder/bar.txt');
+ $this->assertTrue(is_string($newData0['etag']), 'Expected a string');
+ $this->assertNotEmpty($newData0['etag']);
+
$newData1 = $this->cache->get('folder');
+ $this->assertTrue(is_string($newData1['etag']), 'Expected a string');
+ $this->assertNotSame($data1['etag'], $newData1['etag']);
+
$newData2 = $this->cache->get('');
- $this->assertNotEmpty($newData0['etag']);
- $this->assertNotEquals($data1['etag'], $newData1['etag']);
- $this->assertNotEquals($data2['etag'], $newData2['etag']);
+ $this->assertTrue(is_string($newData2['etag']), 'Expected a string');
+ $this->assertNotSame($data2['etag'], $newData2['etag']);
}
}
diff --git a/tests/lib/files/etagtest.php b/tests/lib/files/etagtest.php
index ce05adb188a..af9f66835f0 100644
--- a/tests/lib/files/etagtest.php
+++ b/tests/lib/files/etagtest.php
@@ -65,7 +65,11 @@ class EtagTest extends \PHPUnit_Framework_TestCase {
$scanner = new \OC\Files\Utils\Scanner($user1);
$scanner->backgroundScan('/');
- $this->assertEquals($originalEtags, $this->getEtags($files));
+ $newEtags = $this->getEtags($files);
+ // loop over array and use assertSame over assertEquals to prevent false positives
+ foreach ($originalEtags as $file => $originalEtag) {
+ $this->assertSame($originalEtag, $newEtags[$file]);
+ }
}
/**
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 371d1ed1798..c85f1128dbe 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -563,6 +563,6 @@ class View extends \PHPUnit_Framework_TestCase {
$scanner->scanFile('test', \OC\Files\Cache\Scanner::REUSE_ETAG);
$info2 = $view->getFileInfo('/test/test');
- $this->assertEquals($info['etag'], $info2['etag']);
+ $this->assertSame($info['etag'], $info2['etag']);
}
}