[Pkg-owncloud-commits] [php-sabredav] 48/66: 100% test coverage.
David Prévot
taffit at moszumanska.debian.org
Wed May 27 13:56:55 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to tag 3.0.0-alpha1
in repository php-sabredav.
commit 57155ae041c8a99227cc7d0ec635fafd102996d2
Author: Evert Pot <me at evertpot.com>
Date: Wed Apr 29 17:36:02 2015 -0400
100% test coverage.
---
tests/Sabre/DAVACL/FS/CollectionTest.php | 44 ++++++++++
tests/Sabre/DAVACL/FS/FileTest.php | 73 ++++++++++++++++
tests/Sabre/DAVACL/FS/HomeCollectionTest.php | 121 +++++++++++++++++++++++++++
tests/Sabre/DAVACL/PrincipalBackend/Mock.php | 9 +-
4 files changed, 245 insertions(+), 2 deletions(-)
diff --git a/tests/Sabre/DAVACL/FS/CollectionTest.php b/tests/Sabre/DAVACL/FS/CollectionTest.php
new file mode 100644
index 0000000..af18e7c
--- /dev/null
+++ b/tests/Sabre/DAVACL/FS/CollectionTest.php
@@ -0,0 +1,44 @@
+<?php
+
+namespace Sabre\DAVACL\FS;
+
+class CollectionTest extends FileTest {
+
+ function setUp() {
+
+ $this->path = SABRE_TEMPDIR;
+ $this->sut = new Collection($this->path, $this->acl, $this->owner);
+
+ }
+
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+ function testGetChildFile() {
+
+ file_put_contents(SABRE_TEMPDIR . '/file.txt', 'hello');
+ $child = $this->sut->getChild('file.txt');
+ $this->assertInstanceOf('Sabre\\DAVACL\\FS\\File', $child);
+
+ $this->assertEquals('file.txt', $child->getName());
+ $this->assertEquals($this->acl, $child->getACL());
+ $this->assertEquals($this->owner, $child->getOwner());
+
+ }
+
+ function testGetChildDirectory() {
+
+ mkdir(SABRE_TEMPDIR . '/dir');
+ $child = $this->sut->getChild('dir');
+ $this->assertInstanceOf('Sabre\\DAVACL\\FS\\Collection', $child);
+
+ $this->assertEquals('dir', $child->getName());
+ $this->assertEquals($this->acl, $child->getACL());
+ $this->assertEquals($this->owner, $child->getOwner());
+
+ }
+
+}
diff --git a/tests/Sabre/DAVACL/FS/FileTest.php b/tests/Sabre/DAVACL/FS/FileTest.php
new file mode 100644
index 0000000..f57b2fa
--- /dev/null
+++ b/tests/Sabre/DAVACL/FS/FileTest.php
@@ -0,0 +1,73 @@
+<?php
+
+namespace Sabre\DAVACL\FS;
+
+class FileTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * System under test
+ *
+ * @var File
+ */
+ protected $sut;
+
+ protected $path = 'foo';
+ protected $acl = [
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => '{DAV:}authenticated',
+ ]
+ ];
+
+ protected $owner = 'principals/evert';
+
+ function setUp() {
+
+ $this->sut = new File($this->path, $this->acl, $this->owner);
+
+ }
+
+ function testGetOwner() {
+
+ $this->assertEquals(
+ $this->owner,
+ $this->sut->getOwner()
+ );
+
+ }
+
+ function testGetGroup() {
+
+ $this->assertNull(
+ $this->sut->getGroup()
+ );
+
+ }
+
+ function testGetACL() {
+
+ $this->assertEquals(
+ $this->acl,
+ $this->sut->getACL()
+ );
+
+ }
+
+ /**
+ * @expectedException \Sabre\DAV\Exception\Forbidden
+ */
+ function testSetAcl() {
+
+ $this->sut->setACL([]);
+
+ }
+
+ function testGetSupportedPrivilegeSet() {
+
+ $this->assertNull(
+ $this->sut->getSupportedPrivilegeSet()
+ );
+
+ }
+
+}
diff --git a/tests/Sabre/DAVACL/FS/HomeCollectionTest.php b/tests/Sabre/DAVACL/FS/HomeCollectionTest.php
new file mode 100644
index 0000000..cccfc90
--- /dev/null
+++ b/tests/Sabre/DAVACL/FS/HomeCollectionTest.php
@@ -0,0 +1,121 @@
+<?php
+
+namespace Sabre\DAVACL\FS;
+
+use Sabre\DAVACL\PrincipalBackend\Mock as PrincipalBackend;
+
+class HomeCollectionTest extends \PHPUnit_Framework_TestCase {
+
+ /**
+ * System under test
+ *
+ * @var HomeCollection
+ */
+ protected $sut;
+
+ protected $path;
+ protected $name = 'thuis';
+
+ function setUp() {
+
+ $principalBackend = new PrincipalBackend();
+
+ $this->path = SABRE_TEMPDIR . '/home';
+
+ $this->sut = new HomeCollection($principalBackend, $this->path);
+ $this->sut->collectionName = $this->name;
+
+
+ }
+
+ function tearDown() {
+
+ \Sabre\TestUtil::clearTempDir();
+
+ }
+
+ function testGetName() {
+
+ $this->assertEquals(
+ $this->name,
+ $this->sut->getName()
+ );
+
+ }
+
+ function testGetChild() {
+
+ $child = $this->sut->getChild('user1');
+ $this->assertInstanceOf('Sabre\\DAVACL\\FS\\Collection', $child);
+ $this->assertEquals('user1', $child->getName());
+
+ $owner = 'principals/user1';
+ $acl = [
+ [
+ 'privilege' => '{DAV:}read',
+ 'principal' => $owner,
+ 'protected' => true,
+ ],
+ [
+ 'privilege' => '{DAV:}write',
+ 'principal' => $owner,
+ 'protected' => true,
+ ],
+ ];
+
+ $this->assertEquals($acl, $child->getACL());
+ $this->assertEquals($owner, $child->getOwner());
+
+ }
+
+ function testGetOwner() {
+
+ $this->assertNull(
+ $this->sut->getOwner()
+ );
+
+ }
+
+ function testGetGroup() {
+
+ $this->assertNull(
+ $this->sut->getGroup()
+ );
+
+ }
+
+ function testGetACL() {
+
+ $acl = [
+ [
+ 'principal' => '{DAV:}authenticated',
+ 'privilege' => '{DAV:}read',
+ 'protected' => true,
+ ]
+ ];
+
+ $this->assertEquals(
+ $acl,
+ $this->sut->getACL()
+ );
+
+ }
+
+ /**
+ * @expectedException \Sabre\DAV\Exception\Forbidden
+ */
+ function testSetAcl() {
+
+ $this->sut->setACL([]);
+
+ }
+
+ function testGetSupportedPrivilegeSet() {
+
+ $this->assertNull(
+ $this->sut->getSupportedPrivilegeSet()
+ );
+
+ }
+
+}
diff --git a/tests/Sabre/DAVACL/PrincipalBackend/Mock.php b/tests/Sabre/DAVACL/PrincipalBackend/Mock.php
index eeb61f9..19ef644 100644
--- a/tests/Sabre/DAVACL/PrincipalBackend/Mock.php
+++ b/tests/Sabre/DAVACL/PrincipalBackend/Mock.php
@@ -7,9 +7,13 @@ class Mock extends AbstractBackend {
public $groupMembers = array();
public $principals;
- function __construct() {
+ function __construct(array $principals = null) {
- $this->principals = array(
+ $this->principals = $principals;
+
+ if (is_null($principals)) {
+
+ $this->principals = array(
array(
'uri' => 'principals/user1',
'{DAV:}displayname' => 'User 1',
@@ -27,6 +31,7 @@ class Mock extends AbstractBackend {
),
);
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list