diff --git a/.php_cs b/.php_cs new file mode 100644 index 00000000..d12e8ecc --- /dev/null +++ b/.php_cs @@ -0,0 +1,32 @@ +fixers(array( + 'header_comment', + '-psr0', + 'psr4', + 'symfony', + 'concat_without_spaces', + '-phpdoc_indent', + '-phpdoc_params', + )) + ->finder( + Symfony\CS\Finder\DefaultFinder::create() + ->exclude('vendor') + ->in(__DIR__) + ) +; diff --git a/LICENSE.txt b/LICENSE.txt index a946c0e6..111799d2 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -2,7 +2,7 @@ phpcr-api-tests is dual licensed under the MIT license and the Apache License Ve The MIT License (MIT) - Copyright (c) 2013 Liip and others + Copyright (c) 2015 Liip and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/bootstrap.dist.php b/bootstrap.dist.php index 9cc2b103..d3968c9c 100644 --- a/bootstrap.dist.php +++ b/bootstrap.dist.php @@ -1,8 +1,18 @@ =5.3.0", "phpcr/phpcr-implementation": "2.1.*" }, + "autoload": { + "psr-4": { + "PHPCR\\Test\\": "inc/", + "PHPCR\\Tests\\": "tests/" + } + }, "extra": { "branch-alias": { "dev-master": "2.1-dev" diff --git a/fixtures/06_Query/characters.xml b/fixtures/06_Query/characters.xml index cf15301d..5fd5f796 100644 --- a/fixtures/06_Query/characters.xml +++ b/fixtures/06_Query/characters.xml @@ -65,4 +65,4 @@ - \ No newline at end of file + diff --git a/fixtures/10_Writing/mixinreferenceable.xml b/fixtures/10_Writing/mixinreferenceable.xml index 58859230..b16ae34c 100644 --- a/fixtures/10_Writing/mixinreferenceable.xml +++ b/fixtures/10_Writing/mixinreferenceable.xml @@ -130,4 +130,3 @@ - diff --git a/fixtures/11_Import/simple.xml b/fixtures/11_Import/simple.xml index d867212a..54b7ddd4 100644 --- a/fixtures/11_Import/simple.xml +++ b/fixtures/11_Import/simple.xml @@ -8,4 +8,4 @@ - \ No newline at end of file + diff --git a/fixtures/general/query.xml b/fixtures/general/query.xml index 9784ebcd..a6e22565 100644 --- a/fixtures/general/query.xml +++ b/fixtures/general/query.xml @@ -24,4 +24,4 @@ SELECT * FROM [nt:file] WHERE [nt:file].[jcr:mimeType] = "text/plain" - \ No newline at end of file + diff --git a/inc/AbstractLoader.php b/inc/AbstractLoader.php index c26a6c56..0a621a6d 100644 --- a/inc/AbstractLoader.php +++ b/inc/AbstractLoader.php @@ -1,5 +1,14 @@ getRepositoryFactoryClass(); - $factory = new $factoryclass; - if (! $factory instanceof RepositoryFactoryInterface) { + $factory = new $factoryclass(); + if (!$factory instanceof RepositoryFactoryInterface) { throw new \Exception("$factoryclass is not of type RepositoryFactoryInterface"); } - /** @var $factory RepositoryFactoryInterface */ + /* @var $factory RepositoryFactoryInterface */ return $factory->getRepository($this->getRepositoryFactoryParameters()); } /** * @return \PHPCR\CredentialsInterface the login credentials that lead to successful login into the repository */ - public abstract function getCredentials(); + abstract public function getCredentials(); /** * @return \PHPCR\CredentialsInterface the login credentials that lead to login failure */ - public abstract function getInvalidCredentials(); + abstract public function getInvalidCredentials(); /** * Used when impersonating another user in Reading\SessionReadMethodsTests::testImpersonate - * And for Reading\SessionReadMethodsTest::testCheckPermissionAccessControlException + * And for Reading\SessionReadMethodsTest::testCheckPermissionAccessControlException. * * The user may not have write access to /tests_general_base/numberPropertyNode/jcr:content/foo * * @return \PHPCR\CredentialsInterface the login credentials with limited permissions for testing impersonate and access control */ - public abstract function getRestrictedCredentials(); + abstract public function getRestrictedCredentials(); /** * @return string the user id that is used in the credentials */ - public abstract function getUserId(); - + abstract public function getUserId(); /** * Make the repository ready for login with null credentials, handling the @@ -126,9 +134,9 @@ public abstract function getUserId(); * If the implementation does not support this feature, it must return * false for this method, otherwise true. * - * @return boolean true if anonymous login is supposed to work + * @return bool true if anonymous login is supposed to work */ - public abstract function prepareAnonymousLogin(); + abstract public function prepareAnonymousLogin(); /** * @return string the workspace name used for the tests @@ -158,6 +166,7 @@ public function getOtherWorkspaceName() * Get a session for this implementation. * * @param \PHPCR\CredentialsInterface $credentials The credentials to log into the repository. If omitted, self::getCredentials should be used + * * @return \PHPCR\SessionInterface the session resulting from logging into the repository with the provided credentials */ public function getSession($credentials = false) @@ -169,6 +178,7 @@ public function getSession($credentials = false) * Get a session corresponding to the additional workspace for this implementation. * * @param \PHPCR\CredentialsInterface $credentials The credentials to log into the repository. If omitted, self::getCredentials should be used + * * @return \PHPCR\SessionInterface the session resulting from logging into the repository with the provided credentials */ public function getAdditionalSession($credentials = false) @@ -202,7 +212,7 @@ public function getSessionWithLastModified() * mix:lastModified. If that is not possible, this method should return * true, which will skip the test about this feature. * - * @return boolean + * @return bool */ public function doesSessionLastModified() { @@ -223,7 +233,7 @@ public function doesSessionLastModified() */ public function getTestSupported($chapter, $case, $name) { - return ! ( in_array($chapter, $this->unsupportedChapters) + return !(in_array($chapter, $this->unsupportedChapters) || in_array($case, $this->unsupportedCases) || in_array($name, $this->unsupportedTests) ); @@ -232,11 +242,12 @@ public function getTestSupported($chapter, $case, $name) /** * @return \PHPCR\Test\FixtureLoaderInterface implementation that is used to load test fixtures */ - public abstract function getFixtureLoader(); + abstract public function getFixtureLoader(); /** * @param $credentials * @param $workspaceName + * * @return mixed */ private function getSessionForWorkspace($credentials, $workspaceName) diff --git a/inc/BaseCase.php b/inc/BaseCase.php index b4a27643..d1d4d462 100644 --- a/inc/BaseCase.php +++ b/inc/BaseCase.php @@ -1,9 +1,19 @@ getTestSupported($chapter, $case, null)) { + if (!self::$loader->getTestSupported($chapter, $case, null)) { throw new \PHPUnit_Framework_SkippedTestSuiteError('Test case not supported by this implementation'); } @@ -114,19 +123,19 @@ protected function setUp() { $fqn = get_called_class(); $parts = explode('\\', $fqn); - $case_n = count($parts)-1; + $case_n = count($parts) - 1; $case = $parts[$case_n]; $chapter = ''; for ($i = 2; $i < $case_n; $i++) { - $chapter .= $parts[$i] . '\\'; + $chapter .= $parts[$i].'\\'; } - $case = $chapter . $case; + $case = $chapter.$case; $test = "$case::".$this->getName(); - if (! self::$loader->getTestSupported($chapter, $case, $test)) { - $this->markTestSkipped('Test ' . $this->getName() . ' not supported by this implementation'); + if (!self::$loader->getTestSupported($chapter, $case, $test)) { + $this->markTestSkipped('Test '.$this->getName().' not supported by this implementation'); } $this->sharedFixture = self::$staticSharedFixture; @@ -143,7 +152,7 @@ public static function tearDownAfterClass() } /** - * Utility method for tests to get a new session + * Utility method for tests to get a new session. * * Logout from the old session but does *NOT* save the session * @@ -163,7 +172,7 @@ protected function renewSession() } /** - * Utility method for tests to save the session and get a new one + * Utility method for tests to save the session and get a new one. * * Saves the old session and logs it out. * @@ -173,6 +182,7 @@ protected function saveAndRenewSession() { $this->session->save(); $this->renewSession(); + return $this->sharedFixture['session']; } @@ -190,7 +200,7 @@ protected function initProperties() $this->rootNode = $this->session->getRootNode(); - $children = $this->rootNode->getNodes("tests_*"); + $children = $this->rootNode->getNodes('tests_*'); $child = $children->current(); if ($child && $child->hasNode($this->getName())) { $this->node = $child->getNode($this->getName()); @@ -202,7 +212,7 @@ protected function initProperties() *************************************************************************/ /** - * create a session with the given credentials and assert this is a session + * create a session with the given credentials and assert this is a session. * * this is similar to doing self::$loader->getSession($credentials) but * does error handling and asserts the session is a valid SessionInterface @@ -213,7 +223,7 @@ protected function assertSession($credentials = false) { try { $ses = self::$loader->getSession($credentials); - } catch(\PHPCR\RepositoryException $e) { + } catch (\PHPCR\RepositoryException $e) { if ($e->getMessage() == self::NOTSUPPORTEDLOGIN) { $this->markTestSkipped('This implementation does not support this type of login.'); } else { @@ -221,6 +231,7 @@ protected function assertSession($credentials = false) } } $this->assertInstanceOf('PHPCR\SessionInterface', $ses); + return $ses; } @@ -266,7 +277,7 @@ protected function assertSimilarDateTime($expected, $data) $this->assertInstanceOf('\DateTime', $expected); $this->assertInstanceOf('\DateTime', $data); $this->assertTrue(abs($expected->getTimestamp() - $data->getTimestamp()) <= 3, - $data->format('c') . ' is not close to the expected ' . $expected->format('c') + $data->format('c').' is not close to the expected '.$expected->format('c') ); } @@ -275,12 +286,12 @@ protected function assertSimilarDateTime($expected, $data) * * @param string $descriptor * - * @return boolean True if the test can be done. Otherwise the test is skipped. + * @return bool True if the test can be done. Otherwise the test is skipped. */ protected function skipIfNotSupported($descriptor) { if (false === $this->session->getRepository()->getDescriptor($descriptor)) { - $this->markTestSkipped('Descriptor "' . $descriptor . '" not supported'); + $this->markTestSkipped('Descriptor "'.$descriptor.'" not supported'); } return true; diff --git a/inc/FixtureLoaderInterface.php b/inc/FixtureLoaderInterface.php index 0bb5f2ec..7159ff7a 100644 --- a/inc/FixtureLoaderInterface.php +++ b/inc/FixtureLoaderInterface.php @@ -1,8 +1,18 @@ importXML - */ -return array( - 'jackrabbit_importexport' => __DIR__.'/importexport.php', -); diff --git a/tests/06_Query/Sql1/QueryBaseCase.php b/tests/06_Query/Sql1/QueryBaseCase.php deleted file mode 100644 index 1c06f0c3..00000000 --- a/tests/06_Query/Sql1/QueryBaseCase.php +++ /dev/null @@ -1,22 +0,0 @@ -query with a simple select query - */ - public function setUp() - { - parent::setUp(); - - $this->query = $this->sharedFixture['qm']->createQuery("SELECT * FROM nt:folder", \PHPCR\Query\QueryInterface::JCR_SQL2); - } - -} diff --git a/tests/06_Query/XPath/QueryBaseCase.php b/tests/06_Query/XPath/QueryBaseCase.php deleted file mode 100644 index 42d3c8a2..00000000 --- a/tests/06_Query/XPath/QueryBaseCase.php +++ /dev/null @@ -1,22 +0,0 @@ -query with a simple select query - */ - public function setUp() - { - parent::setUp(); - - $this->query = $this->sharedFixture['qm']->createQuery("//element(*,nt:folder)", \PHPCR\Query\QueryInterface::XPATH); - } - -} diff --git a/tests/14_ShareableNodes/TODO b/tests/AccessControlManagement/TODO similarity index 100% rename from tests/14_ShareableNodes/TODO rename to tests/AccessControlManagement/TODO diff --git a/tests/04_Connecting/RepositoryDescriptorsTest.php b/tests/Connecting/RepositoryDescriptorsTest.php similarity index 89% rename from tests/04_Connecting/RepositoryDescriptorsTest.php rename to tests/Connecting/RepositoryDescriptorsTest.php index af59d56f..18a07e11 100644 --- a/tests/04_Connecting/RepositoryDescriptorsTest.php +++ b/tests/Connecting/RepositoryDescriptorsTest.php @@ -1,7 +1,15 @@ getRepositoryFactoryClass(); /** @var $factory RepositoryFactoryInterface */ - $factory = new $class; + $factory = new $class(); $repo = $factory->getRepository(self::$loader->getRepositoryFactoryParameters()); $this->assertInstanceOf('PHPCR\RepositoryInterface', $repo); } - } diff --git a/tests/04_Connecting/RepositoryTest.php b/tests/Connecting/RepositoryTest.php similarity index 85% rename from tests/04_Connecting/RepositoryTest.php rename to tests/Connecting/RepositoryTest.php index 04bc60b1..4c9d01da 100644 --- a/tests/04_Connecting/RepositoryTest.php +++ b/tests/Connecting/RepositoryTest.php @@ -1,13 +1,19 @@ getRepository(); - if (! self::$loader->prepareAnonymousLogin()) { + if (!self::$loader->prepareAnonymousLogin()) { $this->setExpectedException('PHPCR\LoginException'); } $session = $repository->login(null, self::$loader->getWorkspaceName()); @@ -51,12 +57,12 @@ public function testNoLogin() } /** - * external authentication + * external authentication. */ public function testNoLoginAndWorkspace() { $repository = self::$loader->getRepository(); - if (! self::$loader->prepareAnonymousLogin()) { + if (!self::$loader->prepareAnonymousLogin()) { $this->setExpectedException('PHPCR\LoginException'); } $session = $repository->login(); diff --git a/tests/04_Connecting/SessionReadMethodsTest.php b/tests/Connecting/SessionReadMethodsTest.php similarity index 84% rename from tests/04_Connecting/SessionReadMethodsTest.php rename to tests/Connecting/SessionReadMethodsTest.php index 9a182b86..78f5505b 100644 --- a/tests/04_Connecting/SessionReadMethodsTest.php +++ b/tests/Connecting/SessionReadMethodsTest.php @@ -1,10 +1,18 @@ getCredentials(); - if (! $cr instanceof \PHPCR\SimpleCredentials) { + if (!$cr instanceof \PHPCR\SimpleCredentials) { $this->markTestSkipped('This implementation is not using the SimpleCredentials. We can not know if there is anything about attributes. You need to test getAttributeNames in your implementation specific tests'); } $cr->setAttribute('foo', 'bar'); @@ -47,7 +54,7 @@ public function testGetAttributeNames() public function testGetAttribute() { $cr = self::$loader->getCredentials(); - if (! $cr instanceof \PHPCR\SimpleCredentials) { + if (!$cr instanceof \PHPCR\SimpleCredentials) { $this->markTestSkipped('This implementation is not using the SimpleCredentials. We can not know if there is anything about attributes. You need to test getAttribute in your implementation specific tests'); } $cr->setAttribute('foo', 'bar'); diff --git a/tests/04_Connecting/SimpleCredentialsTest.php b/tests/Connecting/SimpleCredentialsTest.php similarity index 87% rename from tests/04_Connecting/SimpleCredentialsTest.php rename to tests/Connecting/SimpleCredentialsTest.php index f84136ba..76cd3ef0 100644 --- a/tests/04_Connecting/SimpleCredentialsTest.php +++ b/tests/Connecting/SimpleCredentialsTest.php @@ -1,10 +1,18 @@ tagName, array('sv:node', 'sv:property'))) { $name = $n->attributes->getNamedItem('name'); if ($name == null) { @@ -48,7 +60,7 @@ private function buildPath(DOMNode $n) } else { $elem = $n->nodeName; } - $ret = $elem . '/' . $ret; + $ret = $elem.'/'.$ret; $n = $n->parentNode; } diff --git a/tests/11_Import/ImportRepositoryContentTest.php b/tests/Import/ImportRepositoryContentTest.php similarity index 97% rename from tests/11_Import/ImportRepositoryContentTest.php rename to tests/Import/ImportRepositoryContentTest.php index 24f273e5..e2661211 100644 --- a/tests/11_Import/ImportRepositoryContentTest.php +++ b/tests/Import/ImportRepositoryContentTest.php @@ -1,10 +1,18 @@ doTestImportXMLSystem($session, $session); } /** - * Import to empty repository with various data + * Import to empty repository with various data. */ public function testImportXMLSystemWorkspace() { @@ -95,7 +103,8 @@ public function testImportXMLSystemIdCollisionWorkspace() } /** - * try to replace the path to which we are importing atm + * try to replace the path to which we are importing atm. + * * @expectedException \PHPCR\NodeType\ConstraintViolationException */ public function testImportXMLUuidRemoveParentSession() @@ -106,7 +115,8 @@ public function testImportXMLUuidRemoveParentSession() } /** - * try to replace the path to which we are importing atm + * try to replace the path to which we are importing atm. + * * @expectedException \PHPCR\NodeType\ConstraintViolationException */ public function testImportXMLUuidRemoveParentWorkspace() @@ -311,7 +321,7 @@ public function testImportXMLUuidReplaceRoot() } /** - * Provoke an io error + * Provoke an io error. * * @expectedException \RuntimeException */ diff --git a/tests/16_AccessControlManagement/TODO b/tests/LifecycleManagement/TODO similarity index 100% rename from tests/16_AccessControlManagement/TODO rename to tests/LifecycleManagement/TODO diff --git a/tests/17_Locking/LockManagerTest.php b/tests/Locking/LockManagerTest.php similarity index 87% rename from tests/17_Locking/LockManagerTest.php rename to tests/Locking/LockManagerTest.php index 5e1d3e70..17b57a59 100644 --- a/tests/17_Locking/LockManagerTest.php +++ b/tests/Locking/LockManagerTest.php @@ -1,10 +1,18 @@ recreateTestNode('non-lockable', false); - $this->lm->lock('/non-lockable', true, true, 3, ""); + $this->lm->lock('/non-lockable', true, true, 3, ''); } /** - * Try to lock an already locked node + * Try to lock an already locked node. + * * @expectedException \PHPCR\Lock\LockException */ public function testLockAlreadyLocked() @@ -44,18 +54,19 @@ public function testLockAlreadyLocked() // The first lock should work try { - $this->lm->lock('/lockable-node', true, true, 3, ""); + $this->lm->lock('/lockable-node', true, true, 3, ''); } catch (\PHPCR\Lock\LockException $ex) { // The lock didn't work, Huston, there is a problem... - $this->fail('An error occurred while trying to lock a valid node: ' . $ex->getMessage()); + $this->fail('An error occurred while trying to lock a valid node: '.$ex->getMessage()); } // The second lock should not work - $this->lm->lock('/lockable-node', true, true, 3, ""); + $this->lm->lock('/lockable-node', true, true, 3, ''); } /** - * Try to deep lock a node which subtree contains a locked node + * Try to deep lock a node which subtree contains a locked node. + * * @expectedException \PHPCR\Lock\LockException */ public function testLockDeepOnAlreadyLocked() @@ -65,28 +76,30 @@ public function testLockDeepOnAlreadyLocked() // The lock on the child should work try { - $this->lm->lock('/lockable-parent/lockable-child', true, true, 3, ""); + $this->lm->lock('/lockable-parent/lockable-child', true, true, 3, ''); } catch (\PHPCR\Lock\LockException $ex) { - $this->fail('An error occurred while trying to lock a valid node: ' . $ex->getMessage()); + $this->fail('An error occurred while trying to lock a valid node: '.$ex->getMessage()); } // The *deep* lock on the parent should not work - $this->lm->lock('/lockable-parent', true, true, 3, ""); + $this->lm->lock('/lockable-parent', true, true, 3, ''); } /** * Try to lock a node with non-saved pending changes. + * * @expectedException \PHPCR\InvalidItemStateException */ public function testLockNonSavedNode() { $node = $this->recreateTestNode('unsaved', true); $node->setProperty('testprop', 'foobar'); - $this->lm->lock('/unsaved', true, true, 3, ""); + $this->lm->lock('/unsaved', true, true, 3, ''); } /** - * Try to lock an unexisting node + * Try to lock an unexisting node. + * * @expectedException \PHPCR\PathNotFoundException */ public function testLockNonExistingNode() @@ -95,7 +108,7 @@ public function testLockNonExistingNode() } /** - * Test a simple lock on a lockable node + * Test a simple lock on a lockable node. */ public function testCanLockLockableNodes() { @@ -143,7 +156,7 @@ public function testCanLockLockableNodeInfiniteTimeout() } /** - * Check that a deep lock locks the children but still the lock is hold by the parent node + * Check that a deep lock locks the children but still the lock is hold by the parent node. */ public function testDeepLock() { @@ -156,7 +169,7 @@ public function testDeepLock() } /** - * Check deep lock with the LockInfo + * Check deep lock with the LockInfo. */ public function testDeepLockInfo() { @@ -183,7 +196,7 @@ private function assertDeepLock() } /** - * Check that a non-deep lock does not lock the children + * Check that a non-deep lock does not lock the children. */ public function testNonDeepLock() { @@ -202,7 +215,7 @@ public function testNonDeepLock() } /** - * Test a simple lock on a lockable node + * Test a simple lock on a lockable node. */ public function testLockOwner() { @@ -215,7 +228,8 @@ public function testLockOwner() // ----- ISLOCKED TESTS --------------------------------------------------- /** - * Check a locked node is locked + * Check a locked node is locked. + * * @depends testCanLockLockableNodeInfiniteTimeout */ public function testIsLockedOnLocked() @@ -224,7 +238,8 @@ public function testIsLockedOnLocked() } /** - * Check an unlocked node is not locked + * Check an unlocked node is not locked. + * * @depends testCannotLockNonLockableNodes */ public function testIsLockedOnUnlocked() @@ -235,7 +250,8 @@ public function testIsLockedOnUnlocked() // ----- HOLDSLOCK TESTS -------------------------------------------------- /** - * Try to test the lock on an unexisting node + * Try to test the lock on an unexisting node. + * * @expectedException \PHPCR\PathNotFoundException */ public function testHoldsLockUnexistingNode() @@ -262,7 +278,8 @@ public function testHoldsLockOnLocked() // ----- UNLOCK TESTS ----------------------------------------------------- /** - * Try to unlock a locked node + * Try to unlock a locked node. + * * @depends testCanLockLockableNodeInfiniteTimeout */ public function testUnlockOnLocked() @@ -273,7 +290,8 @@ public function testUnlockOnLocked() } /** - * Try to unlock a non-lockable node + * Try to unlock a non-lockable node. + * * @depends testIsLockedOnUnlocked * @expectedException \PHPCR\Lock\LockException */ @@ -283,19 +301,21 @@ public function testUnlockOnNonLocked() } /** - * Try to unlock a unsaved node + * Try to unlock a unsaved node. + * * @expectedException \PHPCR\InvalidItemStateException */ public function testUnlockInvalidState() { $node = $this->recreateTestNode('locked-unsaved', true); - $this->lm->lock('/locked-unsaved', true, true, 3, ""); + $this->lm->lock('/locked-unsaved', true, true, 3, ''); $node->setProperty('testprop', 'foobar'); $this->lm->unlock('/locked-unsaved'); } /** - * Try to unlock an unexisting node + * Try to unlock an unexisting node. + * * @expectedException \PHPCR\PathNotFoundException */ public function testUnlockUnexistingNode() @@ -303,16 +323,16 @@ public function testUnlockUnexistingNode() $this->lm->unlock('/some-unexisting-node'); } - // ----- HELPERS ---------------------------------------------------------- /** - * Helper function to simplify the test of valid Lock objects + * Helper function to simplify the test of valid Lock objects. + * * @param \PHPCR\Lock\LockInterface $lock The lock to check * @param NodeInterface the expected node of this lock * @param string $expectedOwner - * @param boolean $expectedIsDeep - * @param boolean $expectedIsSessionScoped + * @param bool $expectedIsDeep + * @param bool $expectedIsSessionScoped * @param int $timeout the expected seconds remaining. One second less remaining is accepted too to permit for one second change */ protected function assertLockEquals($lock, $expectedNode, $expectedOwner, $expectedIsDeep, $expectedIsSessionScoped, $timeout) @@ -362,5 +382,4 @@ protected function recreateTestNode($relPath, $lockable = true, $session = null) return $node; } - } diff --git a/tests/08_NodeTypeDiscovery/NodeDefinitionTest.php b/tests/NodeTypeDiscovery/NodeDefinitionTest.php similarity index 91% rename from tests/08_NodeTypeDiscovery/NodeDefinitionTest.php rename to tests/NodeTypeDiscovery/NodeDefinitionTest.php index 5f099d3f..c4c8522c 100644 --- a/tests/08_NodeTypeDiscovery/NodeDefinitionTest.php +++ b/tests/NodeTypeDiscovery/NodeDefinitionTest.php @@ -1,10 +1,18 @@ getNodeType and NodeTypeDefinition->getChildNodeDefinitions() works correctly */ @@ -23,8 +31,8 @@ public static function setupBeforeClass($fixtures = false) parent::setupBeforeClass($fixtures); $ntm = self::$staticSharedFixture['session']->getWorkspace()->getNodeTypeManager(); self::$file = $ntm->getNodeType('nt:file'); - self::$folder= $ntm->getNodeType('nt:folder'); - self::$hierarchyNodeType= $ntm->getNodeType('nt:hierarchyNode'); + self::$folder = $ntm->getNodeType('nt:folder'); + self::$hierarchyNodeType = $ntm->getNodeType('nt:hierarchyNode'); } public function setUp() @@ -43,7 +51,6 @@ public function setUp() list($key, $this->hierarchyNodeDef) = each($defs); $this->assertInstanceOf('\PHPCR\NodeType\NodeDefinitionInterface', $this->hierarchyNodeDef); $this->assertEquals('*', $this->hierarchyNodeDef->getName()); - } catch (\Exception $e) { $this->markTestSkipped('getChildNodeDefinitions not working as it should, skipping tests about NodeDefinitionInterface: '.$e->getMessage()); } diff --git a/tests/08_NodeTypeDiscovery/NodeNodeTypeReadMethodsTest.php b/tests/NodeTypeDiscovery/NodeNodeTypeReadMethodsTest.php similarity index 84% rename from tests/08_NodeTypeDiscovery/NodeNodeTypeReadMethodsTest.php rename to tests/NodeTypeDiscovery/NodeNodeTypeReadMethodsTest.php index 091779b1..059b0d44 100644 --- a/tests/08_NodeTypeDiscovery/NodeNodeTypeReadMethodsTest.php +++ b/tests/NodeTypeDiscovery/NodeNodeTypeReadMethodsTest.php @@ -1,10 +1,18 @@ getNodeType works correctly */ @@ -147,7 +155,7 @@ public function testGetPropertyDefinitions() $properties = self::$file->getPropertyDefinitions(); $this->assertInternalType('array', $properties); $this->assertCount(4, $properties); - $names=array(); + $names = array(); foreach ($properties as $prop) { $this->assertInstanceOf('\PHPCR\NodeType\PropertyDefinitionInterface', $prop); $names[] = $prop->getName(); @@ -173,7 +181,7 @@ public function testIsNodeTypeMixin() /** * If your implementation supports versioning, this test checks if isNodeType * works for parent mixin types as well. - * If the repository does not declare it supports versioning, this test is skipped + * If the repository does not declare it supports versioning, this test is skipped. */ public function testIsNodeTypeMixinVersion() { diff --git a/tests/08_NodeTypeDiscovery/PropertyDefinitionTest.php b/tests/NodeTypeDiscovery/PropertyDefinitionTest.php similarity index 97% rename from tests/08_NodeTypeDiscovery/PropertyDefinitionTest.php rename to tests/NodeTypeDiscovery/PropertyDefinitionTest.php index 49922b59..b32fe809 100644 --- a/tests/08_NodeTypeDiscovery/PropertyDefinitionTest.php +++ b/tests/NodeTypeDiscovery/PropertyDefinitionTest.php @@ -1,11 +1,20 @@ getNodeType and NodeTypeDefinition->getPropertyDefinitions() works correctly */ @@ -36,7 +45,6 @@ public static function setupBeforeClass($fixtures = false) self::$address = $ntm->getNodeType('nt:address'); self::$mix_created = $ntm->getNodeType('mix:created'); self::$resource = $ntm->getNodeType('nt:resource'); - } public function setUp() @@ -112,7 +120,7 @@ public function testGetAvailableQueryOperators() QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO, QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN, QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO, - QueryObjectModelConstantsInterface::JCR_OPERATOR_LIKE + QueryObjectModelConstantsInterface::JCR_OPERATOR_LIKE, ); asort($ops); diff --git a/tests/08_NodeTypeDiscovery/TODO b/tests/NodeTypeDiscovery/TODO similarity index 100% rename from tests/08_NodeTypeDiscovery/TODO rename to tests/NodeTypeDiscovery/TODO diff --git a/tests/19_NodeTypeManagement/CndTest.php b/tests/NodeTypeManagement/CndTest.php similarity index 83% rename from tests/19_NodeTypeManagement/CndTest.php rename to tests/NodeTypeManagement/CndTest.php index af1568cb..0fe00486 100644 --- a/tests/19_NodeTypeManagement/CndTest.php +++ b/tests/NodeTypeManagement/CndTest.php @@ -1,11 +1,19 @@ assertEquals('phpcr:apitest', $name); $this->assertInstanceOf('PHPCR\NodeType\NodeTypeDefinitionInterface', $type); - /** @var $type NodeTypeDefinitionInterface */ + /* @var $type NodeTypeDefinitionInterface */ $props = $type->getDeclaredPropertyDefinitions(); $this->assertCount(1, $props, 'Wrong number of properties in phpcr:apitest'); $this->assertEquals('phpcr:class', $props[0]->getName()); @@ -98,7 +105,7 @@ protected function assertTypes($types) list($name, $type) = each($types); $this->assertEquals('phpcr:test', $name); $this->assertInstanceOf('PHPCR\NodeType\NodeTypeDefinitionInterface', $type); - /** @var $type NodeTypeDefinitionInterface */ + /* @var $type NodeTypeDefinitionInterface */ $props = $type->getDeclaredPropertyDefinitions(); $this->assertCount(1, $props, 'Wrong number of properties in phpcr:test'); $this->assertEquals('phpcr:prop', $props[0]->getName()); @@ -158,7 +165,7 @@ public function testPrimaryItem() } $node = $root->addNode('test_node', 'phpcr:primary_item_test'); - $node->setProperty("phpcr:content", 'test'); + $node->setProperty('phpcr:content', 'test'); $this->session->save(); // Check the primary item of the new node diff --git a/tests/19_NodeTypeManagement/NodeTypeTest.php b/tests/NodeTypeManagement/NodeTypeTest.php similarity index 90% rename from tests/19_NodeTypeManagement/NodeTypeTest.php rename to tests/NodeTypeManagement/NodeTypeTest.php index 7c2a4b32..c7b94dcf 100644 --- a/tests/19_NodeTypeManagement/NodeTypeTest.php +++ b/tests/NodeTypeManagement/NodeTypeTest.php @@ -1,12 +1,20 @@ node to avoid confusion as we run several parallel sessions. + * * @var string */ private $nodePath; @@ -42,7 +50,7 @@ public function setUp() { parent::setUp(); //all tests in this suite rely on the trick to have the node populated from the fixtures - $this->assertInstanceOf('PHPCR\NodeInterface', $this->node, "Something went wrong with fixture loading"); + $this->assertInstanceOf('PHPCR\NodeInterface', $this->node, 'Something went wrong with fixture loading'); $this->nodePath = $this->node->getPath(); $this->node = null; } @@ -103,7 +111,7 @@ public function testFilteredEventJournalUuid() $journal = $om->getEventJournal($filter); $journal->skipTo($curTime); $this->assertTrue($journal->valid()); - $this->assertEquals($this->nodePath . '/ref', $journal->current()->getPath()); + $this->assertEquals($this->nodePath.'/ref', $journal->current()->getPath()); $this->assertEquals(EventInterface::PROPERTY_ADDED, $journal->current()->getType()); $journal->next(); @@ -132,7 +140,7 @@ public function testFilteredEventJournalNodeType() // At this point the journal should only contain the NODE_ADDED event $this->assertTrue($journal->valid()); - $this->assertEquals($this->nodePath . '/folder', $journal->current()->getPath()); + $this->assertEquals($this->nodePath.'/folder', $journal->current()->getPath()); $this->assertEquals(EventInterface::NODE_ADDED, $journal->current()->getType()); $type = $journal->current()->getPrimaryNodeType(); $this->assertInstanceOf('PHPCR\NodeType\NodeTypeInterface', $type); @@ -158,17 +166,16 @@ public function testUserData() $userDataValues = array( "somedifferent\" data\nnext line ä<>;&:,'x\txx", null, - "" + '', ); $expectedUserDataValues = array( "somedifferent\" data\nnext line ä<>;&:,'x\txx", null, - null + null, ); foreach ($userDataValues as $key => $userData) { - sleep(1); // To avoid having the same date as journal entries generated by previous tests $curTime = time() * 1000; @@ -202,7 +209,7 @@ protected function assertFilterOnEventType(ObservationManagerInterface $observat protected function assertFilterOnPathNoDeep(ObservationManagerInterface $observationManager, $curTime) { $filter = $observationManager->createEventFilter(); - $filter->setAbsPath($this->nodePath . '/child'); + $filter->setAbsPath($this->nodePath.'/child'); $journal = $observationManager->getEventJournal($filter); $journal->skipTo($curTime); @@ -211,14 +218,14 @@ protected function assertFilterOnPathNoDeep(ObservationManagerInterface $observa while ($journal->valid()) { $event = $journal->current(); $journal->next(); - $this->assertEquals($this->nodePath . '/child', $event->getPath()); + $this->assertEquals($this->nodePath.'/child', $event->getPath()); } } protected function assertFilterOnPathDeep(ObservationManagerInterface $observationManager, $curTime) { $filter = $observationManager->createEventFilter(); - $filter->setAbsPath($this->nodePath . '/child'); + $filter->setAbsPath($this->nodePath.'/child'); $filter->setIsDeep(true); $journal = $observationManager->getEventJournal($filter); $journal->skipTo($curTime); @@ -230,7 +237,7 @@ protected function assertFilterOnPathDeep(ObservationManagerInterface $observati $journal->next(); // Notice the assertion is slightly different from the one in testFilterOnPathNoDeep - $this->assertTrue(substr($event->getPath(), 0, strlen($this->nodePath . '/child')) === $this->nodePath . '/child'); + $this->assertTrue(substr($event->getPath(), 0, strlen($this->nodePath.'/child')) === $this->nodePath.'/child'); } } @@ -264,7 +271,7 @@ protected function assertFilterOnNodeTypeNoMatch(ObservationManagerInterface $ob } /** - * Produce the following entries at the end of the event journal: + * Produce the following entries at the end of the event journal:. * * PROPERTY_ADDED /child/jcr:primaryType * NODE_ADDED /child @@ -309,7 +316,7 @@ protected function produceEvents(SessionInterface $session) $session->save(); // Will cause a NODE_REMOVED + NODE_ADDED + NODE_MOVED events - $session->move($node->getPath(), $this->nodePath . '/moved'); + $session->move($node->getPath(), $this->nodePath.'/moved'); // Will cause a PERSIST event $session->save(); @@ -320,7 +327,7 @@ protected function produceEvents(SessionInterface $session) } /** - * Check that the journal only contains the given events (in any order) + * Check that the journal only contains the given events (in any order). * * Algorithm: * - construct an array of hash for the expected events @@ -343,9 +350,8 @@ protected function expectEventsInAnyOrder(EventJournalInterface $journal, $event // Construct an hash map with the expected events $expectedEvents = array(); foreach ($events as $event) { - if (!is_array($event) || count($event) !== 2) { - throw new \InvalidArgumentException("Invalid expected events array !"); + throw new \InvalidArgumentException('Invalid expected events array !'); } // Construct an hash based on the event type and path $hash = sprintf('%s-%s', md5($event[0]), md5($event[1])); @@ -368,7 +374,7 @@ protected function expectEventsInAnyOrder(EventJournalInterface $journal, $event if (array_key_exists($hash, $expectedEvents)) { unset($expectedEvents[$hash]); } else { - $this->Fail(sprintf("Unexpected event found, type = %s, path = %s, hash = %s", $event->getType(), $event->getPath(), $hash)); + $this->Fail(sprintf('Unexpected event found, type = %s, path = %s, hash = %s', $event->getType(), $event->getPath(), $hash)); } } @@ -399,15 +405,15 @@ protected function expectEvents(EventJournalInterface $journal, $startDate) // The order is implementation specific (Jackrabbit will trigger the prop added before the node added event) $this->expectEventsInAnyOrder($journal, array( - array(EventInterface::NODE_ADDED, $this->nodePath . '/child'), - array(EventInterface::PROPERTY_ADDED, $this->nodePath . '/child/jcr%3aprimaryType'), + array(EventInterface::NODE_ADDED, $this->nodePath.'/child'), + array(EventInterface::PROPERTY_ADDED, $this->nodePath.'/child/jcr%3aprimaryType'), ) ); $this->assertEvent(EventInterface::PERSIST, '', $journal->current()); $journal->next(); - $this->assertEvent(EventInterface::PROPERTY_ADDED, $this->nodePath . '/child/prop', $journal->current()); + $this->assertEvent(EventInterface::PROPERTY_ADDED, $this->nodePath.'/child/prop', $journal->current()); $journal->next(); $this->assertEvent(EventInterface::PERSIST, '', $journal->current()); @@ -426,13 +432,13 @@ protected function expectEvents(EventJournalInterface $journal, $startDate) } $journal->next(); - $this->assertEvent(EventInterface::PROPERTY_CHANGED, $this->nodePath . '/child/prop', $journal->current()); + $this->assertEvent(EventInterface::PROPERTY_CHANGED, $this->nodePath.'/child/prop', $journal->current()); $journal->next(); $this->assertEvent(EventInterface::PERSIST, '', $journal->current()); $journal->next(); - $this->assertEvent(EventInterface::PROPERTY_REMOVED, $this->nodePath . '/child/prop', $journal->current()); + $this->assertEvent(EventInterface::PROPERTY_REMOVED, $this->nodePath.'/child/prop', $journal->current()); $journal->next(); $this->assertEvent(EventInterface::PERSIST, '', $journal->current()); @@ -443,9 +449,9 @@ protected function expectEvents(EventJournalInterface $journal, $startDate) // The order of the events is implementation specific. $events = $this->expectEventsInAnyOrder($journal, array( - array(EventInterface::NODE_REMOVED, $this->nodePath . '/child'), - array(EventInterface::NODE_ADDED, $this->nodePath . '/moved'), - array(EventInterface::NODE_MOVED, $this->nodePath . '/moved'), + array(EventInterface::NODE_REMOVED, $this->nodePath.'/child'), + array(EventInterface::NODE_ADDED, $this->nodePath.'/moved'), + array(EventInterface::NODE_MOVED, $this->nodePath.'/moved'), ) ); foreach ($events as $event) { @@ -459,7 +465,7 @@ protected function expectEvents(EventJournalInterface $journal, $startDate) $this->assertEvent(EventInterface::PERSIST, '', $journal->current()); $journal->next(); - $this->assertEvent(EventInterface::NODE_REMOVED, $this->nodePath . '/moved', $journal->current()); + $this->assertEvent(EventInterface::NODE_REMOVED, $this->nodePath.'/moved', $journal->current()); $journal->next(); $this->assertEvent(EventInterface::PERSIST, '', $journal->current()); @@ -483,7 +489,7 @@ protected function assertEvent($expectedType, $expectedPath, EventInterface $eve } /** - * Assert events in the journal have the expected userdata + * Assert events in the journal have the expected userdata. * * @param EventJournalInterface $journal * @param int $startDate unix timestamp @@ -503,7 +509,7 @@ protected function expectEventsWithUserData(EventJournalInterface $journal, $sta } /** - * Internal function used to dump the events in the journal for debugging + * Internal function used to dump the events in the journal for debugging. * * @param $journal */ @@ -512,7 +518,7 @@ protected function varDumpJournal(EventJournalInterface $journal) echo "JOURNAL DUMP:\n"; while ($journal->valid()) { $event = $journal->current(); - echo sprintf("%s - %s - %s\n", $event->getDate(), $event->getType(), $event->getPath()) ; + echo sprintf("%s - %s - %s\n", $event->getDate(), $event->getType(), $event->getPath()); $journal->next(); } } diff --git a/tests/23_OrderableChildNodes/OrderBeforeTest.php b/tests/OrderableChildNodes/OrderBeforeTest.php similarity index 91% rename from tests/23_OrderableChildNodes/OrderBeforeTest.php rename to tests/OrderableChildNodes/OrderBeforeTest.php index 7983064c..b72cbeb1 100644 --- a/tests/23_OrderableChildNodes/OrderBeforeTest.php +++ b/tests/OrderableChildNodes/OrderBeforeTest.php @@ -1,14 +1,21 @@ orderBefore('three', 'two'); $dstParentNode->orderBefore('three', 'two'); - $this->session->move($src . '/three', $dst . '/moved-three'); - $dstNode = $this->session->getNode($dst . '/moved-three'); + $this->session->move($src.'/three', $dst.'/moved-three'); + $dstNode = $this->session->getNode($dst.'/moved-three'); $this->assertInstanceOf('PHPCR\NodeInterface', $dstNode); $dstParentNode = $this->session->getNode($dst); @@ -401,7 +410,7 @@ public function testNodeOrderAfterOrderAndMove() $session = $this->renewSession(); - $dstNode = $session->getNode($dst . '/moved-three'); + $dstNode = $session->getNode($dst.'/moved-three'); $this->assertInstanceOf('PHPCR\NodeInterface', $dstNode); $dstParentNode = $session->getNode($dst); diff --git a/tests/09_PermissionsAndCapabilities/PermissionReadTest.php b/tests/PermissionsAndCapabilities/PermissionReadTest.php similarity index 91% rename from tests/09_PermissionsAndCapabilities/PermissionReadTest.php rename to tests/PermissionsAndCapabilities/PermissionReadTest.php index 79f25e32..7774aec7 100644 --- a/tests/09_PermissionsAndCapabilities/PermissionReadTest.php +++ b/tests/PermissionsAndCapabilities/PermissionReadTest.php @@ -1,11 +1,18 @@ assertFalse($this->session->hasCapability('inexistentXXX', $property, array())); //actually, the repository is not required to know, it can always say that the info can not be determined and return true. this makes me think that this method is pretty useless... } - } diff --git a/tests/PhpcrUtils/CndParserTest.php b/tests/PhpcrUtils/CndParserTest.php index 5647fb82..5e53f2e3 100644 --- a/tests/PhpcrUtils/CndParserTest.php +++ b/tests/PhpcrUtils/CndParserTest.php @@ -1,14 +1,20 @@ cndParser->parseFile(__DIR__ . '/resources/cnd/example.cnd'); + $res = $this->cndParser->parseFile(__DIR__.'/resources/cnd/example.cnd'); $this->assertExampleCnd($res); } public function testParseCompact() { - $res = $this->cndParser->parseFile(__DIR__ . '/resources/cnd/example.compact.cnd'); + $res = $this->cndParser->parseFile(__DIR__.'/resources/cnd/example.compact.cnd'); $this->assertExampleCnd($res); - } public function testParseVerbose() { - $res = $this->cndParser->parseFile(__DIR__ . '/resources/cnd/example.verbose.cnd'); + $res = $this->cndParser->parseFile(__DIR__.'/resources/cnd/example.verbose.cnd'); $this->assertExampleCnd($res); } @@ -64,7 +69,7 @@ public function testParseString() } /** - * Have invalid-string in the middle of options for a property + * Have invalid-string in the middle of options for a property. * * @expectedException \PHPCR\Util\CND\Exception\ParserException */ @@ -112,7 +117,7 @@ public function testScannerErrorComment() } /** - * Have a newline in a name (here the ns declaration) + * Have a newline in a name (here the ns declaration). * * @expectedException \PHPCR\Util\CND\Exception\ScannerException */ @@ -138,7 +143,7 @@ public function testScannerErrorNewline() */ public function testNoStopAtEofError() { - $res = $this->cndParser->parseFile(__DIR__ . '/resources/cnd/no-stop-at-eof.cnd'); + $res = $this->cndParser->parseFile(__DIR__.'/resources/cnd/no-stop-at-eof.cnd'); $this->assertTrue(isset($res['namespaces'])); $this->assertEquals(array('phpcr' => 'http://www.doctrine-project.org/projects/phpcr_odm'), $res['namespaces']); @@ -149,7 +154,7 @@ public function testNoStopAtEofError() public function testBigFile() { //var_dump($this->session->getWorkspace()->getNodeTypeManager()->getNodeType('nt:file')->hasOrderableChildNodes());die; - $res = $this->cndParser->parseFile(__DIR__ . '/resources/cnd/jackrabbit_nodetypes.cnd'); + $res = $this->cndParser->parseFile(__DIR__.'/resources/cnd/jackrabbit_nodetypes.cnd'); // some random sanity checks $this->assertTrue(isset($res['nodeTypes'])); @@ -208,5 +213,4 @@ protected function assertExampleCnd($res) $this->assertTrue($prop->isFullTextSearchable()); // True because there was no "nofulltext" attribute $this->assertTrue($prop->isQueryOrderable()); // True because there was no "noqueryorder" attribute } - } diff --git a/tests/PhpcrUtils/CndWriterTest.php b/tests/PhpcrUtils/CndWriterTest.php index 970ebebc..60bb08c5 100644 --- a/tests/PhpcrUtils/CndWriterTest.php +++ b/tests/PhpcrUtils/CndWriterTest.php @@ -1,12 +1,18 @@ expects($this->any()) ->method('getUri') ->will($this->returnCallback( - function($prefix) { + function ($prefix) { switch ($prefix) { case 'ns': return 'http://namespace.com/ns'; @@ -93,4 +99,5 @@ function($prefix) { } abstract class MockNamespaceRegistry implements \Iterator, NamespaceRegistryInterface -{} +{ +} diff --git a/tests/PhpcrUtils/PurgeTest.php b/tests/PhpcrUtils/PurgeTest.php index dbb24967..5d2b54de 100644 --- a/tests/PhpcrUtils/PurgeTest.php +++ b/tests/PhpcrUtils/PurgeTest.php @@ -1,12 +1,18 @@ markTestSkipped('This testbed does not have phpcr-utils available'); } parent::setUp(); diff --git a/tests/06_Query/CharacterTest.php b/tests/Query/CharacterTest.php similarity index 94% rename from tests/06_Query/CharacterTest.php rename to tests/Query/CharacterTest.php index a1f6bdb5..9ab20423 100644 --- a/tests/06_Query/CharacterTest.php +++ b/tests/Query/CharacterTest.php @@ -1,12 +1,19 @@ createQuery( @@ -266,7 +277,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array() ); - /** + /* * 6.7.13. AndConstraint */ @@ -280,7 +291,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.14. OrConstraint */ @@ -294,7 +305,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.15. NotConstraint */ @@ -307,7 +318,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.16. Comparison */ @@ -322,7 +333,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.18. PropertyExistence */ @@ -334,7 +345,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.19. FullTextSearch */ @@ -352,7 +363,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.20. SameNode */ // SELECT * FROM [nt:file] AS file WHERE ISSAMENODE(file, /home) @@ -371,7 +382,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array()); */ - /** + /* * 6.7.21. ChildNode */ // SELECT * FROM [nt:file] AS file WHERE ISCHILDNODE(file, /home) @@ -382,7 +393,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.22. DescendantNode */ // SELECT * FROM [nt:file] AS file WHERE ISDESCENDANTNODE(file, /home) @@ -393,7 +404,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.27. ProperyValue */ @@ -419,7 +430,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.28. Length */ @@ -434,7 +445,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.29. NodeName */ @@ -449,7 +460,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.30. NodeLocalName */ @@ -464,7 +475,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.31. FullTextSearchScore */ @@ -479,7 +490,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.32. LowerCase */ @@ -494,7 +505,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.33. UpperCase */ @@ -509,7 +520,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.35. BindVariable */ @@ -524,7 +535,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) array(), array()); - /** + /* * 6.7.38 Order */ @@ -542,7 +553,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) $factory->selector('u', 'nt:unstructured'), null, array( - $factory->ascending($factory->propertyValue('u', 'prop1'))), + $factory->ascending($factory->propertyValue('u', 'prop1')), ), array()); // SELECT * FROM nt:unstructured ORDER BY prop1 DESC @@ -551,7 +562,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) $factory->selector('u', 'nt:unstructured'), null, array( - $factory->descending($factory->propertyValue('u', 'prop1'))), + $factory->descending($factory->propertyValue('u', 'prop1')), ), array()); // SELECT * FROM nt:unstructured ORDER BY prop1 ASC, prop2 DESC @@ -561,10 +572,10 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) null, array( $factory->ascending($factory->propertyValue('u', 'prop1')), - $factory->descending($factory->propertyValue('u', 'prop2'))), + $factory->descending($factory->propertyValue('u', 'prop2')), ), array()); - /** + /* * 6.7.39 Column */ @@ -583,8 +594,7 @@ public static function getQueries(QueryObjectModelFactoryInterface $factory) null, array(), array( - $factory->column('u', 'prop1', 'col1'))); - + $factory->column('u', 'prop1', 'col1'), )); // SELECT u.prop1, u.prop2 AS col2 FROM nt:unstructured $queries['6.7.39.Colum.Mixed'] = diff --git a/tests/06_Query/QOM/QomToSql2ConverterTest.php b/tests/Query/QOM/QomToSql2ConverterTest.php similarity index 92% rename from tests/06_Query/QOM/QomToSql2ConverterTest.php rename to tests/Query/QOM/QomToSql2ConverterTest.php index f1fb4f0c..8130c3c2 100644 --- a/tests/06_Query/QOM/QomToSql2ConverterTest.php +++ b/tests/Query/QOM/QomToSql2ConverterTest.php @@ -1,8 +1,15 @@ session->getWorkspace() instanceof \Jackalope\Workspace) { + if (!$this->session->getWorkspace() instanceof \Jackalope\Workspace) { $this->markTestSkipped('TODO: fix the dependency on jackalope and always use the factory'); } @@ -49,7 +56,7 @@ public function setUp() } /** - * 6.7.3. Selector + * 6.7.3. Selector. */ public function testSelector() { @@ -57,7 +64,7 @@ public function testSelector() } /** - * 6.7.8. EquiJoinCondition + * 6.7.8. EquiJoinCondition. */ public function testEquiJoin() { @@ -71,7 +78,7 @@ public function testEquiJoin() } /** - * 6.7.9. SameNodeJoinCondition + * 6.7.9. SameNodeJoinCondition. */ public function testSameNodeJoin() { @@ -86,7 +93,7 @@ public function testSameNodeJoin() } /** - * 6.7.9. SameNodeJoinCondition with space in path + * 6.7.9. SameNodeJoinCondition with space in path. */ public function testSameNodeJoinSpace() { @@ -98,7 +105,7 @@ public function testSameNodeJoinSpace() } /** - * 6.7.10 ChildNodeJoinCondition + * 6.7.10 ChildNodeJoinCondition. */ public function testChildNodeJoin() { @@ -110,7 +117,7 @@ public function testChildNodeJoin() } /** - * 6.7.11 DescendantNodeJoinCondition + * 6.7.11 DescendantNodeJoinCondition. */ public function testDescendantNodeJoin() { @@ -122,7 +129,7 @@ public function testDescendantNodeJoin() } /** - * 6.7.13. AndConstraint + * 6.7.13. AndConstraint. */ public function testAndConstraint() { @@ -133,7 +140,7 @@ public function testAndConstraint() } /** - * 6.7.14. OrConstraint + * 6.7.14. OrConstraint. */ public function testOrConstraint() { @@ -144,7 +151,7 @@ public function testOrConstraint() } /** - * 6.7.15. NotConstraint + * 6.7.15. NotConstraint. */ public function testNotConstraint() { @@ -154,7 +161,7 @@ public function testNotConstraint() } /** - * 6.7.16. Comparison + * 6.7.16. Comparison. */ public function testComparison() { @@ -166,7 +173,7 @@ public function testComparison() } /** - * 6.7.18. PropertyExistence + * 6.7.18. PropertyExistence. */ public function testPropertyExistence() { @@ -175,7 +182,7 @@ public function testPropertyExistence() } /** - * 6.7.19. FullTextSearch + * 6.7.19. FullTextSearch. */ public function testFullTextSearch() { @@ -184,7 +191,7 @@ public function testFullTextSearch() } /** - * 6.7.20. SameNode + * 6.7.20. SameNode. */ public function testSameNode() { @@ -193,7 +200,7 @@ public function testSameNode() } /** - * 6.7.20. SameNode with space in path + * 6.7.20. SameNode with space in path. */ public function testSameNodeSpace() { @@ -202,7 +209,7 @@ public function testSameNodeSpace() } /** - * 6.7.21. ChildNode + * 6.7.21. ChildNode. */ public function testChildNode() { @@ -211,7 +218,7 @@ public function testChildNode() } /** - * 6.7.21. ChildNode with space in path + * 6.7.21. ChildNode with space in path. */ public function testChildNodeSpace() { @@ -220,7 +227,7 @@ public function testChildNodeSpace() } /** - * 6.7.22. DescendantNode + * 6.7.22. DescendantNode. */ public function testDescendantNode() { @@ -229,7 +236,7 @@ public function testDescendantNode() } /** - * 6.7.22. DescendantNode with space in path + * 6.7.22. DescendantNode with space in path. */ public function testDescendantNodeSpace() { @@ -238,18 +245,17 @@ public function testDescendantNodeSpace() } /** - * 6.7.23. Path + * 6.7.23. Path. */ public function testPath() { $selector = $this->factory->selector('file', 'nt:file'); $this->assertQuery($this->queries['6.7.20.SameNode.Selector'], $selector, array(), $this->factory->sameNode('file', '/home'), array()); $this->assertQuery($this->queries['6.7.20.SameNode.Selector'], $selector, array(), $this->factory->sameNode('file', '[/home]'), array()); - } /** - * 6.7.27. ProperyValue + * 6.7.27. ProperyValue. */ public function testPropertyValue() { @@ -262,7 +268,7 @@ public function testPropertyValue() } /** - * 6.7.28. Length + * 6.7.28. Length. */ public function testLength() { @@ -275,7 +281,7 @@ public function testLength() } /** - * 6.7.29. NodeName + * 6.7.29. NodeName. */ public function testNodeName() { @@ -288,7 +294,7 @@ public function testNodeName() } /** - * 6.7.30. NodeLocalName + * 6.7.30. NodeLocalName. */ public function testNodeLocalName() { @@ -301,7 +307,7 @@ public function testNodeLocalName() } /** - * 6.7.31. FullTextSearchScore + * 6.7.31. FullTextSearchScore. */ public function testFullTextSearchScore() { @@ -314,7 +320,7 @@ public function testFullTextSearchScore() } /** - * 6.7.32. LowerCase + * 6.7.32. LowerCase. */ public function testLowerCase() { @@ -327,7 +333,7 @@ public function testLowerCase() } /** - * 6.7.33. UpperCase + * 6.7.33. UpperCase. */ public function testUpperCase() { @@ -340,7 +346,7 @@ public function testUpperCase() } /** - * 6.7.35. BindVariable + * 6.7.35. BindVariable. */ public function testBindVariable() { @@ -353,7 +359,7 @@ public function testBindVariable() } /** - * 6.7.38 Order + * 6.7.38 Order. */ public function testOrdering() { @@ -367,7 +373,7 @@ public function testOrdering() } /** - * 6.7.39 Column + * 6.7.39 Column. */ public function testColumns() { diff --git a/tests/06_Query/QOM/Sql2ScannerTest.php b/tests/Query/QOM/Sql2ScannerTest.php similarity index 81% rename from tests/06_Query/QOM/Sql2ScannerTest.php rename to tests/Query/QOM/Sql2ScannerTest.php index 7d0e5764..a8becee5 100644 --- a/tests/06_Query/QOM/Sql2ScannerTest.php +++ b/tests/Query/QOM/Sql2ScannerTest.php @@ -1,12 +1,20 @@ tokens = array( 'SELECT', '*', 'FROM','[nt:file]', 'INNER', 'JOIN', '[nt:folder]', - 'ON', 'ISSAMENODE', '(', 'sel1', ',', 'sel2', ',', '[/home]', ')'); + 'ON', 'ISSAMENODE', '(', 'sel1', ',', 'sel2', ',', '[/home]', ')', ); } public function testConstructor() diff --git a/tests/06_Query/QOM/Sql2TestQueries.php b/tests/Query/QOM/Sql2TestQueries.php similarity index 93% rename from tests/06_Query/QOM/Sql2TestQueries.php rename to tests/Query/QOM/Sql2TestQueries.php index 5f482049..945b719d 100644 --- a/tests/06_Query/QOM/Sql2TestQueries.php +++ b/tests/Query/QOM/Sql2TestQueries.php @@ -1,10 +1,21 @@ \'hello\'))', ); - /** + /* * 6.7.13. AndConstraint */ $queries['6.7.13.And'] = array( @@ -89,7 +100,7 @@ public static function getQueries() 'SELECT * FROM [nt:file] AS file WHERE (file.prop1 IS NOT NULL AND file.prop2 IS NOT NULL)', ); - /** + /* * 6.7.14. OrConstraint */ $queries['6.7.14.Or'] = array( @@ -97,7 +108,7 @@ public static function getQueries() 'SELECT * FROM [nt:file] AS file WHERE (file.prop1 IS NOT NULL OR file.prop2 IS NOT NULL)', ); - /** + /* * 6.7.15. NotConstraint */ $queries['6.7.15.Not'] = array( @@ -105,23 +116,23 @@ public static function getQueries() 'SELECT * FROM [nt:file] AS file WHERE (NOT file.prop1 IS NOT NULL)', ); - /** + /* * 6.7.16. Comparison */ - $queries['6.7.16.Comparison'] = 'SELECT * FROM [nt:file] AS file WHERE NAME(file) LIKE \'literal2\'';; + $queries['6.7.16.Comparison'] = 'SELECT * FROM [nt:file] AS file WHERE NAME(file) LIKE \'literal2\''; - /** + /* * 6.7.18. PropertyExistence */ $queries['6.7.18.PropertyExistence'] = 'SELECT * FROM [nt:file] AS file WHERE file.prop1 IS NOT NULL'; - /** + /* * 6.7.19. FullTextSearch */ $queries['6.7.19.FullTextSearch'] = 'SELECT * FROM [nt:file] AS file WHERE CONTAINS(file.prop, \'expr\')'; $queries['6.7.19.FullTextSearch_With_Single_Quote'] = "SELECT * FROM [nt:file] AS file WHERE CONTAINS(file.prop, 'expr''')"; - /** + /* * 6.7.20. SameNode */ $queries['6.7.20.SameNode.Selector'] = 'SELECT * FROM [nt:file] AS file WHERE ISSAMENODE(file, [/home])'; @@ -130,7 +141,7 @@ public static function getQueries() 'SELECT * FROM [nt:file] AS file WHERE ISSAMENODE(file, [/home node])', ); - /** + /* * 6.7.21. ChildNode */ $queries['6.7.21.ChildNode.Selector'] = 'SELECT * FROM [nt:file] AS file WHERE ISCHILDNODE(file, [/home])'; @@ -139,57 +150,57 @@ public static function getQueries() 'SELECT * FROM [nt:file] AS file WHERE ISCHILDNODE(file, [/home node])', ); - /** + /* * 6.7.22. DescendantNode */ $queries['6.7.22.DescendantNode.Selector'] = 'SELECT * FROM [nt:file] AS file WHERE ISDESCENDANTNODE(file, [/home])'; $queries['6.7.22.DescendantNode.Selector_Space'] = array( 'SELECT * FROM [nt:file] AS file WHERE ISDESCENDANTNODE(file, ["/home node"])', - 'SELECT * FROM [nt:file] AS file WHERE ISDESCENDANTNODE(file, [/home node])' + 'SELECT * FROM [nt:file] AS file WHERE ISDESCENDANTNODE(file, [/home node])', ); - /** + /* * 6.7.27. PropertyValue */ $queries['6.7.27.PropertyValue'] = 'SELECT * FROM [nt:file] AS file WHERE file.prop LIKE \'literal\''; $queries['6.7.27.1.PropertyValue'] = 'SELECT * FROM [nt:unstructured] AS sel WHERE sel.prop > CAST(\'2013-04-15T00:00:00.000+02:00\' AS DATE)'; - /** + /* * 6.7.28. Length */ $queries['6.7.28.Length'] = 'SELECT * FROM [nt:file] AS file WHERE LENGTH(file.prop) LIKE \'literal\''; - /** + /* * 6.7.29. NodeName */ $queries['6.7.29.NodeName'] = 'SELECT * FROM [nt:file] AS file WHERE NAME(file) LIKE \'literal\''; - /** + /* * 6.7.30. NodeLocalName */ $queries['6.7.30.NodeLocalName'] = 'SELECT * FROM [nt:file] AS file WHERE LOCALNAME(file) LIKE \'literal\''; - /** + /* * 6.7.31. FullTextSearchScore */ $queries['6.7.31.FullTextSearchScore'] = 'SELECT * FROM [nt:file] AS file WHERE SCORE(file) LIKE \'literal\''; - /** + /* * 6.7.32. LowerCase */ $queries['6.7.32.LowerCase'] = 'SELECT * FROM [nt:file] AS file WHERE LOWER(NAME(file)) LIKE \'literal\''; - /** + /* * 6.7.33. UpperCase */ $queries['6.7.33.UpperCase'] = 'SELECT * FROM [nt:file] AS file WHERE UPPER(NAME(file)) LIKE \'literal\''; - /** + /* * 6.7.35. BindVariable */ $queries['6.7.35.BindValue'] = 'SELECT * FROM [nt:file] AS file WHERE UPPER(NAME(file)) LIKE $var'; - /** + /* * 6.7.38 Order */ $queries['6.7.38.Order.None'] = 'SELECT * FROM [nt:unstructured] AS u'; @@ -197,7 +208,7 @@ public static function getQueries() $queries['6.7.38.Order.Desc'] = 'SELECT * FROM [nt:unstructured] AS u ORDER BY u.prop1 DESC'; $queries['6.7.38.Order.Mixed'] = 'SELECT * FROM [nt:unstructured] AS u ORDER BY u.prop1 ASC, u.prop2 DESC'; - /** + /* * 6.7.39 Column */ $queries['6.7.39.Colum.Wildcard'] = 'SELECT * FROM [nt:unstructured] AS u'; diff --git a/tests/06_Query/QOM/Sql2ToQomConverterTest.php b/tests/Query/QOM/Sql2ToQomConverterTest.php similarity index 94% rename from tests/06_Query/QOM/Sql2ToQomConverterTest.php rename to tests/Query/QOM/Sql2ToQomConverterTest.php index ff2a6e46..0530b848 100644 --- a/tests/06_Query/QOM/Sql2ToQomConverterTest.php +++ b/tests/Query/QOM/Sql2ToQomConverterTest.php @@ -1,9 +1,15 @@ query + * The results to be expected in $this->query. * * @var array */ protected $resultPaths; /** - * in addition to base stuff, prepare the query manager and load general/query fixture + * in addition to base stuff, prepare the query manager and load general/query fixture. * * @param string $fixture name of the fixture to load, defaults to general/base */ @@ -32,26 +40,26 @@ public static function setupBeforeClass($fixture = 'general/base') } /** - * in addition to base stuff, prepare $this->query with a simple select query + * in addition to base stuff, prepare $this->query with a simple select query. */ public function setUp() { parent::setUp(); - $this->query = $this->sharedFixture['qm']->createQuery(" + $this->query = $this->sharedFixture['qm']->createQuery(' SELECT * FROM [nt:folder] WHERE ISDESCENDANTNODE([/tests_general_base]) OR ISSAMENODE([/tests_general_base]) - ", + ', \PHPCR\Query\QueryInterface::JCR_SQL2 ); // the query result is not ordered, but these are the nodes that are to be expected in any order - $this->resultPaths = array("/tests_general_base", - "/tests_general_base/test:namespacedNode", - "/tests_general_base/emptyExample", - "/tests_general_base/multiValueProperty/deepnode", - "/tests_general_base/multiValueProperty"); + $this->resultPaths = array('/tests_general_base', + '/tests_general_base/test:namespacedNode', + '/tests_general_base/emptyExample', + '/tests_general_base/multiValueProperty/deepnode', + '/tests_general_base/multiValueProperty', ); } } diff --git a/tests/06_Query/QueryManagerTest.php b/tests/Query/QueryManagerTest.php similarity index 86% rename from tests/06_Query/QueryManagerTest.php rename to tests/Query/QueryManagerTest.php index 1834d7c2..63e2353a 100644 --- a/tests/06_Query/QueryManagerTest.php +++ b/tests/Query/QueryManagerTest.php @@ -1,10 +1,18 @@ query = $this->factory->createQuery($source,$constraint,$orderings,$columns); + $this->query = $this->factory->createQuery($source, $constraint, $orderings, $columns); } public function testExecute() @@ -68,7 +75,7 @@ public function testExecuteInvalid() $orderings = array(); $columns = array(); - $query = $this->factory->createQuery($source,$constraint,$orderings,$columns); + $query = $this->factory->createQuery($source, $constraint, $orderings, $columns); $query->execute(); } @@ -80,7 +87,7 @@ public function testGetStatement() /** * Even though the query is defined with QOM, it must return JCR_SQL2 as langugae: - * http://www.day.com/specs/jcr/2.0/6_Query.html#6.9.3%20Getting%20the%20Language + * http://www.day.com/specs/jcr/2.0/6_Query.html#6.9.3%20Getting%20the%20Language. */ public function testGetLanguage() { @@ -88,7 +95,8 @@ public function testGetLanguage() } /** - * a transient query has no stored query path + * a transient query has no stored query path. + * * @expectedException \PHPCR\ItemNotFoundException */ public function testGetStoredQueryPathItemNotFound() diff --git a/tests/06_Query/QueryObjectSql2Test.php b/tests/Query/QueryObjectSql2Test.php similarity index 92% rename from tests/06_Query/QueryObjectSql2Test.php rename to tests/Query/QueryObjectSql2Test.php index 6ba516f0..354355e9 100644 --- a/tests/06_Query/QueryObjectSql2Test.php +++ b/tests/Query/QueryObjectSql2Test.php @@ -1,10 +1,18 @@ assertEquals($columnNamesExpected, $columnNames); + $this->assertEquals($columnNamesExpected, $columnNames); } public function testGetAliasColumnNames() { - $query = $this->sharedFixture['qm']->createQuery(" + $query = $this->sharedFixture['qm']->createQuery(' SELECT [jcr:mimeType] AS bar, stringToCompare as foo, [nt:unstructured].longNumberToCompare, ding FROM [nt:unstructured] WHERE stringToCompare IS NOT NULL - ", + ', \PHPCR\Query\QueryInterface::JCR_SQL2 ); $qr = $query->execute(); @@ -70,7 +78,6 @@ public function testGetAliasColumnNames() $this->assertNotNull($row->getValue('longNumberToCompare')); $this->assertEquals('', $row->getValue('ding')); } - } public function testGetNodes() @@ -131,7 +138,9 @@ public function testReadPropertyContentFromResults() $this->assertTrue(count($this->qr->getNodes()) > 0); foreach ($this->qr->getNodes() as $path => $node) { - if ($seekName == $path) break; + if ($seekName == $path) { + break; + } } $this->assertInstanceOf('PHPCR\NodeInterface', $node); @@ -196,7 +205,7 @@ public function testBooleanField() $this->assertCount(1, $rows); $this->assertEquals(false, $rows[0]->getValue('data.thisIsNo')); - $query = $this->sharedFixture['qm']->createQuery( + $query = $this->sharedFixture['qm']->createQuery( 'SELECT data.thisIsYes FROM [nt:unstructured] as data WHERE data.thisIsYes = true', \PHPCR\Query\QueryInterface::JCR_SQL2 ); diff --git a/tests/06_Query/QuerySql2OperationsTest.php b/tests/Query/QuerySql2OperationsTest.php similarity index 98% rename from tests/06_Query/QuerySql2OperationsTest.php rename to tests/Query/QuerySql2OperationsTest.php index c15bef49..7f354892 100644 --- a/tests/06_Query/QuerySql2OperationsTest.php +++ b/tests/Query/QuerySql2OperationsTest.php @@ -1,12 +1,20 @@ assertCount(3, $rows, 'Expected 3 nodes with a (binary) jcr:data property with length 121'); } - } diff --git a/tests/06_Query/RowIteratorTest.php b/tests/Query/RowIteratorTest.php similarity index 86% rename from tests/06_Query/RowIteratorTest.php rename to tests/Query/RowIteratorTest.php index 749e8d97..d0087ae4 100644 --- a/tests/06_Query/RowIteratorTest.php +++ b/tests/Query/RowIteratorTest.php @@ -1,10 +1,18 @@ assertEquals(array('nt:folder.jcr:created', 'nt:folder.jcr:createdBy', 'nt:folder.jcr:primaryType'), $keys); - } public function testGetValue() diff --git a/tests/Query/Sql1/QueryBaseCase.php b/tests/Query/Sql1/QueryBaseCase.php new file mode 100644 index 00000000..ab839c56 --- /dev/null +++ b/tests/Query/Sql1/QueryBaseCase.php @@ -0,0 +1,28 @@ +query with a simple select query. + */ + public function setUp() + { + parent::setUp(); + + $this->query = $this->sharedFixture['qm']->createQuery('SELECT * FROM nt:folder', \PHPCR\Query\QueryInterface::JCR_SQL2); + } +} diff --git a/tests/06_Query/Sql1/QueryOperationsTest.php b/tests/Query/Sql1/QueryOperationsTest.php similarity index 92% rename from tests/06_Query/Sql1/QueryOperationsTest.php rename to tests/Query/Sql1/QueryOperationsTest.php index e7f95b34..5237cae5 100644 --- a/tests/06_Query/Sql1/QueryOperationsTest.php +++ b/tests/Query/Sql1/QueryOperationsTest.php @@ -1,12 +1,20 @@ assertEquals(array(null, null, null, null, null, null, null, null, null, 0), $vals); } - } diff --git a/tests/Query/XPath/QueryBaseCase.php b/tests/Query/XPath/QueryBaseCase.php new file mode 100644 index 00000000..7a954da0 --- /dev/null +++ b/tests/Query/XPath/QueryBaseCase.php @@ -0,0 +1,28 @@ +query with a simple select query. + */ + public function setUp() + { + parent::setUp(); + + $this->query = $this->sharedFixture['qm']->createQuery('//element(*,nt:folder)', \PHPCR\Query\QueryInterface::XPATH); + } +} diff --git a/tests/06_Query/XPath/QueryOperationsTest.php b/tests/Query/XPath/QueryOperationsTest.php similarity index 92% rename from tests/06_Query/XPath/QueryOperationsTest.php rename to tests/Query/XPath/QueryOperationsTest.php index 1b9d0082..51f126fa 100644 --- a/tests/06_Query/XPath/QueryOperationsTest.php +++ b/tests/Query/XPath/QueryOperationsTest.php @@ -1,12 +1,20 @@ assertEquals(array(null, null, null, null, null, null, null, null, null, 0), $vals); } - } diff --git a/tests/05_Reading/BinaryReadMethodsTest.php b/tests/Reading/BinaryReadMethodsTest.php similarity index 95% rename from tests/05_Reading/BinaryReadMethodsTest.php rename to tests/Reading/BinaryReadMethodsTest.php index dc3ddecf..57370f5f 100644 --- a/tests/05_Reading/BinaryReadMethodsTest.php +++ b/tests/Reading/BinaryReadMethodsTest.php @@ -1,14 +1,22 @@ getNode('deepExample'); $this->assertEquals(array('deepExample'), (array) $deepExample->getNodeNames()); - } + } public function testGetNodesWithFetchDepth() { diff --git a/tests/05_Reading/NodeReadMethodsTest.php b/tests/Reading/NodeReadMethodsTest.php similarity index 93% rename from tests/05_Reading/NodeReadMethodsTest.php rename to tests/Reading/NodeReadMethodsTest.php index cdb788d2..4a5a188f 100644 --- a/tests/05_Reading/NodeReadMethodsTest.php +++ b/tests/Reading/NodeReadMethodsTest.php @@ -1,10 +1,18 @@ deepnode->getAncestor($this->deepnode->getDepth()+1); + $this->deepnode->getAncestor($this->deepnode->getDepth() + 1); } public function testGetDepth() @@ -170,11 +178,11 @@ public function testGetNodesRepositoryException() public function testGetNodesPattern() { - $iterator = $this->node->getNodes("idExample"); + $iterator = $this->node->getNodes('idExample'); $nodes = array(); foreach ($iterator as $n) { $this->assertInstanceOf('PHPCR\NodeInterface', $n); - /** @var $n \PHPCR\NodeInterface */ + /* @var $n \PHPCR\NodeInterface */ array_push($nodes, $n->getName()); } $this->assertContains('idExample', $nodes); @@ -188,7 +196,7 @@ public function testGetNodesTypeFilter() $nodes = array(); foreach ($iterator as $n) { $this->assertInstanceOf('PHPCR\NodeInterface', $n); - /** @var $n \PHPCR\NodeInterface */ + /* @var $n \PHPCR\NodeInterface */ array_push($nodes, $n->getName()); } $this->assertContains('index.txt', $nodes); @@ -204,11 +212,11 @@ public function testGetNodesTypeFilter() public function testGetNodesTypeFilterList() { $this->node = $this->rootNode->getNode('tests_general_base'); - $iterator = $this->node->getNodes("id*", array('nt:file', 'nt:folder')); + $iterator = $this->node->getNodes('id*', array('nt:file', 'nt:folder')); $nodes = array(); foreach ($iterator as $n) { $this->assertInstanceOf('PHPCR\NodeInterface', $n); - /** @var $n \PHPCR\NodeInterface */ + /* @var $n \PHPCR\NodeInterface */ array_push($nodes, $n->getName()); } $this->assertNotContains('index.txt', $nodes); @@ -228,7 +236,7 @@ public function testGetNodesNameGlobs() $nodes = array(); foreach ($iterator as $n) { $this->assertInstanceOf('PHPCR\NodeInterface', $n); - /** @var $n \PHPCR\NodeInterface */ + /* @var $n \PHPCR\NodeInterface */ array_push($nodes, $n->getName()); } $this->assertCount(2, $nodes); @@ -254,7 +262,7 @@ public function testGetNodeNames() public function testGetNodeNamesPattern() { - $iterator = $this->node->getNodeNames("id*"); + $iterator = $this->node->getNodeNames('id*'); $names = array(); foreach ($iterator as $n) { array_push($names, $n); @@ -369,7 +377,7 @@ public function testGetPropertiesValuesAll() public function testGetPropertiesValuesAllNoDereference() { $node = $this->session->getNode('/tests_general_base/idExample/jcr:content/weakreference_source1'); - $props = $node->getPropertiesValues(null,false); + $props = $node->getPropertiesValues(null, false); $this->assertInternalType('array', $props); $this->assertArrayHasKey('ref1', $props); $this->assertEquals('13543fc6-1abf-4708-bfcc-e49511754b40', $props['ref1']); @@ -378,7 +386,7 @@ public function testGetPropertiesValuesAllNoDereference() public function testGetPropertiesValuesGlob() { $node = $this->session->getNode('/tests_general_base/idExample/jcr:content/weakreference_source1'); - $props = $node->getPropertiesValues("jcr:*"); + $props = $node->getPropertiesValues('jcr:*'); $this->assertInternalType('array', $props); /* * jcr:mixinTypes is a protected multi-value NAME property @@ -485,7 +493,7 @@ public function testGetReferencesAll() $this->assertInstanceOf('Iterator', $iterator); //there are two nodes with reference to idExample. - $this->assertCount(2, $iterator, "Wrong number of references to idExample"); + $this->assertCount(2, $iterator, 'Wrong number of references to idExample'); foreach ($iterator as $prop) { $this->assertInstanceOf('\PHPCR\PropertyInterface', $prop); $this->assertTrue(in_array($prop, $source)); @@ -493,7 +501,8 @@ public function testGetReferencesAll() } /** - * Test that getReferences() on a non-referenced node will return no references + * Test that getReferences() on a non-referenced node will return no references. + * * @group getReferences */ public function testGetReferencesOnNonReferencedNode() @@ -504,7 +513,7 @@ public function testGetReferencesOnNonReferencedNode() $this->assertInstanceOf('Iterator', $iterator); //there is no node with reference to numberPropertyNode. - $this->assertCount(0, $iterator, "Wrong number of references to numberPropertyNode"); + $this->assertCount(0, $iterator, 'Wrong number of references to numberPropertyNode'); } /** @@ -519,7 +528,7 @@ public function testGetReferencesName() $this->assertInstanceOf('Iterator', $iterator); //there is exactly one node with reference to idExample. - $this->assertCount(1, $iterator, "Wrong number of references with name ref to idExample"); + $this->assertCount(1, $iterator, 'Wrong number of references with name ref to idExample'); foreach ($iterator as $prop) { $this->assertInstanceOf('\PHPCR\PropertyInterface', $prop); $this->assertEquals($source, $prop); @@ -538,7 +547,7 @@ public function testGetReferencesNonexistingName() $target = $this->rootNode->getNode('tests_general_base/idExample'); $iterator = $target->getReferences('notexisting'); $this->assertInstanceOf('Iterator', $iterator); - $this->assertCount(0, $iterator, "Wrong number of references with name notexisting to idExample"); + $this->assertCount(0, $iterator, 'Wrong number of references with name notexisting to idExample'); } /** @@ -555,7 +564,7 @@ public function testGetWeakReferencesAll() $this->assertInstanceOf('Iterator', $iterator); // there are 4 different references, but 2 come from the same property so should only count once. - $this->assertCount(3, $iterator, "Wrong number of weak references to weakreference_target"); + $this->assertCount(3, $iterator, 'Wrong number of weak references to weakreference_target'); foreach ($iterator as $prop) { $this->assertInstanceOf('\PHPCR\PropertyInterface', $prop); $this->assertTrue(in_array($prop, $source, true)); @@ -573,7 +582,7 @@ public function testGetWeakReferencesName() $iterator = $target->getWeakReferences('ref1'); $this->assertInstanceOf('Iterator', $iterator); - $this->assertCount(1, $iterator, "Wrong number of weak references to weakreference_target"); + $this->assertCount(1, $iterator, 'Wrong number of weak references to weakreference_target'); foreach ($iterator as $prop) { $this->assertInstanceOf('\PHPCR\PropertyInterface', $prop); $this->assertEquals($prop, $source); @@ -590,7 +599,7 @@ public function testGetWeakReferencesNonExistingName() $iterator = $target->getWeakReferences('unexisting_name'); $this->assertInstanceOf('Iterator', $iterator); - $this->assertCount(0, $iterator, "Wrong number of weak references to weakreference_target"); + $this->assertCount(0, $iterator, 'Wrong number of weak references to weakreference_target'); } /** @@ -604,7 +613,7 @@ public function testGetWeakReferencesOnNonReferencedNode() $this->assertInstanceOf('Iterator', $iterator); //there is no node with reference to numberPropertyNode. - $this->assertCount(0, $iterator, "Wrong number of references to numberPropertyNode"); + $this->assertCount(0, $iterator, 'Wrong number of references to numberPropertyNode'); } public function testGetSharedSetUnreferenced() diff --git a/tests/05_Reading/PropertyReadMethodsTest.php b/tests/Reading/PropertyReadMethodsTest.php similarity index 95% rename from tests/05_Reading/PropertyReadMethodsTest.php rename to tests/Reading/PropertyReadMethodsTest.php index 96aa9365..0cb2cdc5 100644 --- a/tests/05_Reading/PropertyReadMethodsTest.php +++ b/tests/Reading/PropertyReadMethodsTest.php @@ -1,11 +1,19 @@ valProperty->getString(); $this->assertInternalType('string', $str); $this->assertEquals('bar', $str); - } public function testJcrCreated() @@ -173,7 +180,7 @@ public function testGetStringMulti() } /** - * everything can be converted to string and then to binary + * everything can be converted to string and then to binary. */ public function testGetBinary() { @@ -219,7 +226,7 @@ public function testGetLongMulti() } } /** - * NAME can not be converted to long + * NAME can not be converted to long. * * @expectedException \PHPCR\ValueFormatException */ @@ -244,7 +251,7 @@ public function testGetDoubleMulti() } } /** - * NAME can not be converted to double + * NAME can not be converted to double. * * @expectedException \PHPCR\ValueFormatException */ @@ -262,7 +269,7 @@ public function testGetDecimal() $this->assertEquals(999, $num); } /** - * NAME can not be converted to decimal + * NAME can not be converted to decimal. * * @expectedException \PHPCR\ValueFormatException */ @@ -271,7 +278,7 @@ public function testGetDecimalValueFormatException() $this->node->getProperty('jcr:primaryType')->getDecimal(); } /** - * The PHP Implementation requires that getDouble and getDecimal return the same + * The PHP Implementation requires that getDouble and getDecimal return the same. */ public function testGetDoubleAndDecimalSame() { @@ -301,13 +308,13 @@ public function testGetDateMulti() $expectedArray = array( new \DateTime('2011-04-22T14:34:20+01:00'), new \DateTime('2011-10-23T14:34:20+01:00'), - new \DateTime('2010-10-23T14:34:20+01:00')); + new \DateTime('2010-10-23T14:34:20+01:00'), ); foreach ($expectedArray as $key => $expected) { $this->assertEqualDateTime($expected, $arr[$key]); } } /** - * arbitrary string can not be converted to date + * arbitrary string can not be converted to date. * * @expectedException \PHPCR\ValueFormatException */ @@ -327,7 +334,7 @@ public function testGetBoolean() $this->assertFalse($prop->getBoolean()); // php interprets everything as true except null, 0, '' and boolean false. thus even the string "false" is true. // we require getString to return something that evaluates to false (the empty string makes sense) - $this->assertTrue(! $prop->getString(), 'boolean false returned as string should evaluate to php '); + $this->assertTrue(!$prop->getString(), 'boolean false returned as string should evaluate to php '); $prop = $this->node->getNode('numberPropertyNode/jcr:content')->getProperty('thisIsYes'); $this->assertTrue($prop->getBoolean()); @@ -347,7 +354,7 @@ public function testGetBooleanMulti() $this->assertTrue($arr[1]); } /** - * NAME can not be converted to boolean + * NAME can not be converted to boolean. * * @expectedException \PHPCR\ValueFormatException */ @@ -390,7 +397,8 @@ public function testGetNodeValueFormatException() $node = $this->dateProperty->getNode(); } /** - * only nodes but not properties can be found with getNode + * only nodes but not properties can be found with getNode. + * * @expectedException \PHPCR\ItemNotFoundException */ public function testGetNodePropertyItemNotFound() @@ -417,7 +425,7 @@ public function testGetNodeWeakItemNotFound() } /** - * PATH property, the path references another property + * PATH property, the path references another property. */ public function testGetProperty() { @@ -562,5 +570,4 @@ public function testIteratorMulti() } $this->assertEquals($expected, $returned); } - } diff --git a/tests/05_Reading/SessionNamespaceRemappingTest.php b/tests/Reading/SessionNamespaceRemappingTest.php similarity index 89% rename from tests/05_Reading/SessionNamespaceRemappingTest.php rename to tests/Reading/SessionNamespaceRemappingTest.php index 4e30ef60..dc23af1f 100644 --- a/tests/05_Reading/SessionNamespaceRemappingTest.php +++ b/tests/Reading/SessionNamespaceRemappingTest.php @@ -1,7 +1,15 @@ 'http://www.jcp.org/jcr/nt/1.0', 'mix' => 'http://www.jcp.org/jcr/mix/1.0', 'xml' => 'http://www.w3.org/XML/1998/namespace', - '' => ''); + '' => '', ); public function testSetNamespacePrefix() { diff --git a/tests/05_Reading/SessionReadMethodsTest.php b/tests/Reading/SessionReadMethodsTest.php similarity index 96% rename from tests/05_Reading/SessionReadMethodsTest.php rename to tests/Reading/SessionReadMethodsTest.php index 66d1745c..e5349d09 100644 --- a/tests/05_Reading/SessionReadMethodsTest.php +++ b/tests/Reading/SessionReadMethodsTest.php @@ -1,10 +1,18 @@ session->getRootNode(); $this->assertInstanceOf('PHPCR\NodeInterface', $node); - $this->assertEquals( '/', $node->getPath()); + $this->assertEquals('/', $node->getPath()); } /** @@ -84,7 +92,7 @@ public function testGetNodes() } /** - * make sure getNodes works with a traversable object as well + * make sure getNodes works with a traversable object as well. */ public function testGetNodesTraversable() { @@ -112,7 +120,8 @@ public function testGetNodesInvalidArgument() } /** - * Get something that is a property and not a node + * Get something that is a property and not a node. + * * @expectedException \PHPCR\PathNotFoundException */ public function testGetNodeInvalid() @@ -120,7 +129,8 @@ public function testGetNodeInvalid() $this->session->getNode('/tests_general_base/idExample/jcr:primaryType'); } /** - * Get something that is a node and not a property + * Get something that is a node and not a property. + * * @expectedException \PHPCR\PathNotFoundException */ public function testGetPropertyInvalid() @@ -180,7 +190,8 @@ public function testGetPropertiesInvalidArgument() } /** - * it is forbidden to call getItem on the session with a relative path + * it is forbidden to call getItem on the session with a relative path. + * * @expectedException \PHPCR\PathNotFoundException */ public function testGetItemRelativePathException() @@ -334,7 +345,8 @@ public function testGetNodeByIdentifierItemNotFoundException() } /** - * spec 4.3 + * spec 4.3. + * * @expectedException JavaException */ public function testImpersonate() diff --git a/tests/18_LifecycleManagement/TODO b/tests/RetentionAndHold/TODO similarity index 100% rename from tests/18_LifecycleManagement/TODO rename to tests/RetentionAndHold/TODO diff --git a/tests/22_SameNameSiblings/DeleteMethodsTest.php b/tests/SameNameSiblings/DeleteMethodsTest.php similarity index 89% rename from tests/22_SameNameSiblings/DeleteMethodsTest.php rename to tests/SameNameSiblings/DeleteMethodsTest.php index d8c3bd13..fc3b9fd5 100644 --- a/tests/22_SameNameSiblings/DeleteMethodsTest.php +++ b/tests/SameNameSiblings/DeleteMethodsTest.php @@ -1,7 +1,15 @@ removeItem() with multiple items before session->save() + * Call session->removeItem() with multiple items before session->save(). */ public function testRemoveItemMultiple() { @@ -34,19 +42,19 @@ public function testRemoveItemMultiple() foreach ($childNames as $childName) { $this->assertTrue($parent->hasNode($childName)); - $this->session->removeItem($parentPath . '/' . $childName); + $this->session->removeItem($parentPath.'/'.$childName); $this->assertFalse($parent->hasNode($childName), 'Node was not removed'); } $this->saveAndRenewSession(); foreach ($childNames as $childName) { - $this->assertFalse($this->session->nodeExists($parentPath . '/' . $childName)); + $this->assertFalse($this->session->nodeExists($parentPath.'/'.$childName)); } } /** - * Call node->remove() with multiple items before session->save() + * Call node->remove() with multiple items before session->save(). * * \PHPCR\ItemInterface::remove */ @@ -68,7 +76,7 @@ public function testRemoveNode() $this->saveAndRenewSession(); foreach ($childNames as $childName) { - $this->assertFalse($this->session->nodeExists($parentPath . '/' . $childName)); + $this->assertFalse($this->session->nodeExists($parentPath.'/'.$childName)); } } @@ -117,7 +125,7 @@ public function testDeleteManyNodes() } foreach ($childrenToDelete as $childName) { - $this->session->removeItem($parentPath . '/' . $childName); + $this->session->removeItem($parentPath.'/'.$childName); $this->assertFalse($parent->hasNode($childName), 'Node was not removed'); } @@ -128,7 +136,7 @@ public function testDeleteManyNodes() foreach ($parent->getNodes() as $node) { $child = each($childrenAtEnd); - $this->assertEquals($parentPath . '/' . $child['key'], $node->getPath()); + $this->assertEquals($parentPath.'/'.$child['key'], $node->getPath()); $this->assertEquals($child['value'], $node->getProperty('childNumber')->getValue()); } } @@ -136,6 +144,7 @@ public function testDeleteManyNodes() /** * @param $session * @param $parentPath + * * @return mixed */ private function getParentNode($session, $parentPath) diff --git a/tests/22_SameNameSiblings/TODO b/tests/SameNameSiblings/TODO similarity index 100% rename from tests/22_SameNameSiblings/TODO rename to tests/SameNameSiblings/TODO diff --git a/tests/20_RetentionAndHold/TODO b/tests/ShareableNodes/TODO similarity index 100% rename from tests/20_RetentionAndHold/TODO rename to tests/ShareableNodes/TODO diff --git a/tests/21_Transactions/TransactionMethodsTest.php b/tests/Transactions/TransactionMethodsTest.php similarity index 82% rename from tests/21_Transactions/TransactionMethodsTest.php rename to tests/Transactions/TransactionMethodsTest.php index 8976e084..aab5cb13 100644 --- a/tests/21_Transactions/TransactionMethodsTest.php +++ b/tests/Transactions/TransactionMethodsTest.php @@ -1,17 +1,23 @@ renewSession(); parent::setUp(); - $this->assertInstanceOf('PHPCR\NodeInterface', $this->node, "Something went wrong with fixture loading"); + $this->assertInstanceOf('PHPCR\NodeInterface', $this->node, 'Something went wrong with fixture loading'); } public function testGetTransactionManager() @@ -38,7 +44,7 @@ public function testTransactionCommit() $utx->begin(); $child = $this->node->addNode('insideTransaction'); - $this->assertEquals($this->node->getPath() . '/insideTransaction', $child->getPath()); + $this->assertEquals($this->node->getPath().'/insideTransaction', $child->getPath()); $this->session->save(); @@ -55,7 +61,7 @@ public function testTransactionCommit() public function testTransactionRollback() { $copy = $this->node->addNode('copyTransaction'); - $copiedNodePath = $this->node->getPath()."/copyTransactionCopy"; + $copiedNodePath = $this->node->getPath().'/copyTransactionCopy'; $this->session->save(); $utx = $this->session->getWorkspace()->getTransactionManager(); @@ -63,7 +69,7 @@ public function testTransactionRollback() $child = $this->node->addNode('insideTransaction'); $utx->begin(); //workspace operation - $this->session->getWorkspace()->copy($copy->getPath(),$copiedNodePath); + $this->session->getWorkspace()->copy($copy->getPath(), $copiedNodePath); $this->session->save(); $this->assertFalse($child->isNew()); $utx->rollback(); @@ -85,7 +91,7 @@ public function testTransactionRollback() public function testInTransaction() { - $utx= $this->session->getWorkspace()->getTransactionManager(); + $utx = $this->session->getWorkspace()->getTransactionManager(); $this->assertFalse($utx->inTransaction()); $utx->begin(); @@ -104,7 +110,7 @@ public function testInTransaction() } /** - * Testing interaction of transactions and versioning + * Testing interaction of transactions and versioning. * * @expectedException \PHPCR\InvalidItemStateException */ @@ -114,7 +120,7 @@ public function testIllegalCheckin() $vm = $this->session->getWorkspace()->getVersionManager(); - $utx= $this->session->getWorkspace()->getTransactionManager(); + $utx = $this->session->getWorkspace()->getTransactionManager(); $vm->checkout($this->node->getPath()); $this->node->setProperty('foo', 'bar2'); @@ -128,5 +134,4 @@ public function testTransactionTimeout() { $this->markTestIncomplete('This test has not been implemented yet.'); } - } diff --git a/tests/15_Versioning/CreateVersionableNodeTest.php b/tests/Versioning/CreateVersionableNodeTest.php similarity index 84% rename from tests/15_Versioning/CreateVersionableNodeTest.php rename to tests/Versioning/CreateVersionableNodeTest.php index a3fdbfeb..108aa360 100644 --- a/tests/15_Versioning/CreateVersionableNodeTest.php +++ b/tests/Versioning/CreateVersionableNodeTest.php @@ -1,10 +1,18 @@ node = $this->session->getNode('/tests_version_base/versionable'); $this->assertContains('mix:versionable', $mixins, 'Node does not have mix:versionable mixin'); - $this->assertTrue( $this->node->getProperty('jcr:isCheckedOut')->getBoolean(),'jcr:isCheckout is not true'); + $this->assertTrue($this->node->getProperty('jcr:isCheckedOut')->getBoolean(), 'jcr:isCheckout is not true'); } public function testNewVersionableNode() diff --git a/tests/15_Versioning/NodeTypeReadTest.php b/tests/Versioning/NodeTypeReadTest.php similarity index 87% rename from tests/15_Versioning/NodeTypeReadTest.php rename to tests/Versioning/NodeTypeReadTest.php index 117ab15a..fcfdd76b 100644 --- a/tests/15_Versioning/NodeTypeReadTest.php +++ b/tests/Versioning/NodeTypeReadTest.php @@ -1,10 +1,18 @@ assertInstanceOf('PHPCR\Version\VersionInterface', $firstVersion); $frozen2 = $firstVersion->getFrozenNode(); $this->assertInstanceOf('PHPCR\NodeInterface', $firstVersion); - /** @var $frozen2 NodeInterface */ + /* @var $frozen2 NodeInterface */ $this->assertTrue($frozen2->hasProperty('foo')); $this->assertEquals('bar2', $frozen2->getPropertyValue('foo')); } @@ -120,7 +128,7 @@ public function testGetSuccessors() } /** - * Check $version->remove() is not possible. This must go through VersionHistory::remove + * Check $version->remove() is not possible. This must go through VersionHistory::remove. * * @expectedException \PHPCR\RepositoryException */ diff --git a/tests/15_Versioning/VersionHistoryTest.php b/tests/Versioning/VersionHistoryTest.php similarity index 96% rename from tests/15_Versioning/VersionHistoryTest.php rename to tests/Versioning/VersionHistoryTest.php index c50f7ef0..cf4db720 100644 --- a/tests/15_Versioning/VersionHistoryTest.php +++ b/tests/Versioning/VersionHistoryTest.php @@ -1,14 +1,22 @@ vm->getBaseVersion('/tests_version_base/versioned')->getFrozenNode(); $this->assertSame($currentNode, $lastNode); - } public function testGetAllFrozenNodes() { @@ -245,7 +252,7 @@ public function testGetVersionableIdentifier() } /** - * Create two versions then delete the first version + * Create two versions then delete the first version. * * Note that you can not use $version->remove() although version is a node. */ @@ -280,7 +287,7 @@ public function testDeleteVersion() } /** - * Check the last version cannot be removed + * Check the last version cannot be removed. * * @expectedException \PHPCR\ReferentialIntegrityException */ @@ -292,7 +299,7 @@ public function testDeleteLatestVersion() } /** - * Try removing an unexisting version + * Try removing an unexisting version. * * @expectedException \PHPCR\Version\VersionException */ @@ -304,12 +311,12 @@ public function testDeleteUnexistingVersion() } /** - * Check if a version node with the given name exists in the version history + * Check if a version node with the given name exists in the version history. * * @param VersionHistoryInterface $history The version history node * @param string $versionName The name of the version to search for * - * @return boolean + * @return bool */ protected function versionExists($history, $versionName) { diff --git a/tests/15_Versioning/VersionManagerTest.php b/tests/Versioning/VersionManagerTest.php similarity index 97% rename from tests/15_Versioning/VersionManagerTest.php rename to tests/Versioning/VersionManagerTest.php index edd012b4..e2ab3048 100644 --- a/tests/15_Versioning/VersionManagerTest.php +++ b/tests/Versioning/VersionManagerTest.php @@ -1,10 +1,18 @@ setExpectedException('PHPCR\Version\VersionException'); $node->setProperty('foo', 'bar2'); $this->session->save(); - } /** @@ -325,5 +332,4 @@ public function testRestoreRootVersion() } // TODO: cancelMerge, merge, doneMerge, createConfiguration, createActivity, setActivity, getActivity, removeActivity, restoreByLabel - } diff --git a/tests/15_Versioning/VersionTest.php b/tests/Versioning/VersionTest.php similarity index 94% rename from tests/15_Versioning/VersionTest.php rename to tests/Versioning/VersionTest.php index 5deb923a..3ad8735d 100644 --- a/tests/15_Versioning/VersionTest.php +++ b/tests/Versioning/VersionTest.php @@ -1,14 +1,22 @@ assertInstanceOf('PHPCR\Version\VersionInterface', $firstVersion); $frozen2 = $firstVersion->getFrozenNode(); $this->assertInstanceOf('PHPCR\NodeInterface', $firstVersion); - /** @var $frozen2 NodeInterface */ + /* @var $frozen2 NodeInterface */ $this->assertTrue($frozen2->hasProperty('foo')); $this->assertEquals('bar2', $frozen2->getPropertyValue('foo')); } @@ -135,7 +143,7 @@ public function testGetSuccessors() } /** - * Check $version->remove() is not possible. This must go through VersionHistory::remove + * Check $version->remove() is not possible. This must go through VersionHistory::remove. * * @expectedException \PHPCR\RepositoryException */ diff --git a/tests/13_WorkspaceManagement/WorkspaceManagementTest.php b/tests/WorkspaceManagement/WorkspaceManagementTest.php similarity index 83% rename from tests/13_WorkspaceManagement/WorkspaceManagementTest.php rename to tests/WorkspaceManagement/WorkspaceManagementTest.php index f027cae1..1ce873ad 100644 --- a/tests/13_WorkspaceManagement/WorkspaceManagementTest.php +++ b/tests/WorkspaceManagement/WorkspaceManagementTest.php @@ -1,14 +1,22 @@ session->getWorkspace(); $workspace->createWorkspace($workspacename); @@ -30,7 +38,7 @@ public function testCreateWorkspaceExisting($workspacename) public function testCreateWorkspaceWithSource() { - $workspacename = 'testWithSource' . time(); + $workspacename = 'testWithSource'.time(); $workspace = $this->session->getWorkspace(); $workspace->createWorkspace($workspacename, $workspace->getName()); @@ -44,7 +52,7 @@ public function testCreateWorkspaceWithSource() */ public function testCreateWorkspaceWithInvalidSource() { - $workspacename = 'testWithSource' . time(); + $workspacename = 'testWithSource'.time(); $workspace = $this->session->getWorkspace(); $workspace->createWorkspace($workspacename, 'thisworkspaceisnotexisting'); } diff --git a/tests/10_Writing/AddMethodsTest.php b/tests/Writing/AddMethodsTest.php similarity index 86% rename from tests/10_Writing/AddMethodsTest.php rename to tests/Writing/AddMethodsTest.php index 699fa751..6a4e96d6 100644 --- a/tests/10_Writing/AddMethodsTest.php +++ b/tests/Writing/AddMethodsTest.php @@ -1,7 +1,15 @@ renewSession(); parent::setUp(); //all tests in this suite rely on the trick to have the node populated from the fixtures - $this->assertInstanceOf('PHPCR\NodeInterface', $this->node, "Something went wrong with fixture loading"); + $this->assertInstanceOf('PHPCR\NodeInterface', $this->node, 'Something went wrong with fixture loading'); } public function testAddNode() @@ -33,26 +40,25 @@ public function testAddNode() // should take the primaryType $new = $this->node->addNode('newNode'); - $this->assertNotNull($this->session->getNode($this->node->getPath() . '/newNode'), 'Node newNode was not created'); + $this->assertNotNull($this->session->getNode($this->node->getPath().'/newNode'), 'Node newNode was not created'); $this->session->save(); $this->assertFalse($new->isNew(), 'Node was not saved'); $this->renewSession(); - $this->assertNotNull($this->session->getNode($this->node->getPath() . '/newNode'), 'Node newNode was not properly saved'); - + $this->assertNotNull($this->session->getNode($this->node->getPath().'/newNode'), 'Node newNode was not properly saved'); } public function testAddNodeWithPath() { $new = $this->node->addNode('test:namespacedNode/newNode', 'nt:unstructured'); - $this->assertNotNull($this->session->getNode($this->node->getPath() . '/test:namespacedNode/newNode'), 'Node newNode was not created'); + $this->assertNotNull($this->session->getNode($this->node->getPath().'/test:namespacedNode/newNode'), 'Node newNode was not created'); $this->session->save(); $this->assertFalse($new->isNew(), 'Node was not saved'); $this->renewSession(); - $this->assertNotNull($this->session->getNode($this->node->getPath() . '/test:namespacedNode/newNode'), 'Node newNode was not properly saved'); + $this->assertNotNull($this->session->getNode($this->node->getPath().'/test:namespacedNode/newNode'), 'Node newNode was not properly saved'); } public function testAddNodeFileType() @@ -71,7 +77,7 @@ public function testAddNodeFileType() $this->renewSession(); - $newNode = $this->session->getNode($path . '/newFileNode'); + $newNode = $this->session->getNode($path.'/newFileNode'); $this->assertNotNull($newNode, 'Node newFileNode was not created'); $this->assertEquals('nt:file', $newNode->getPrimaryNodeType()->getName(), 'Node newFileNode was not created'); $lastModified = $newNode->getNode('jcr:content')->getPropertyValue('jcr:lastModified'); @@ -82,14 +88,13 @@ public function testAddNodeFileType() public function testAddNodeUnstructuredType() { $new = $this->node->addNode('newUnstructuredNode', 'nt:unstructured'); - $this->assertNotNull($this->session->getNode($this->node->getPath() . '/newUnstructuredNode'), 'Node newUnstructuredNode was not created'); + $this->assertNotNull($this->session->getNode($this->node->getPath().'/newUnstructuredNode'), 'Node newUnstructuredNode was not created'); $this->session->save(); $this->assertFalse($new->isNew(), 'Node was not saved'); $this->renewSession(); - $this->assertNotNull($this->session->getNode($this->node->getPath() . '/newUnstructuredNode'), 'Node newUnstructuredNode was not created'); - + $this->assertNotNull($this->session->getNode($this->node->getPath().'/newUnstructuredNode'), 'Node newUnstructuredNode was not created'); } /** @@ -116,7 +121,7 @@ public function testAddNodeAutoNamedEmptyNamehint() $this->renewSession(); - $this->assertNotNull($this->session->getNode($this->node->getPath() . '/jcr:content/' . $name), 'Node newNode was not properly saved'); + $this->assertNotNull($this->session->getNode($this->node->getPath().'/jcr:content/'.$name), 'Node newNode was not properly saved'); } public function testAddNodeAutoNamedNullNamehint() @@ -134,7 +139,7 @@ public function testAddNodeAutoNamedNullNamehint() $this->renewSession(); - $this->assertNotNull($this->session->getNode($this->node->getPath() . '/jcr:content/' . $name), 'Node newNode was not properly saved'); + $this->assertNotNull($this->session->getNode($this->node->getPath().'/jcr:content/'.$name), 'Node newNode was not properly saved'); } public function testAddNodeAutoNamedValidNamespaceNamehint() @@ -153,7 +158,7 @@ public function testAddNodeAutoNamedValidNamespaceNamehint() $this->renewSession(); - $this->assertNotNull($this->session->getNode($this->node->getPath() . '/jcr:content/' . $name), 'Node newNode was not properly saved'); + $this->assertNotNull($this->session->getNode($this->node->getPath().'/jcr:content/'.$name), 'Node newNode was not properly saved'); } public function testAddPropertyOnUnstructured() @@ -167,7 +172,7 @@ public function testAddPropertyOnUnstructured() $this->assertFalse($node->isNew(), 'Node was not saved'); $this->renewSession(); - $node = $this->session->getNode($path . '/unstructuredNode'); + $node = $this->session->getNode($path.'/unstructuredNode'); $this->assertNotNull($node, 'Node was not created'); $this->assertEquals('val', $node->getPropertyValue('testprop'), 'Property was not saved correctly'); @@ -178,7 +183,7 @@ public function testAddPropertyOnUnstructured() $this->assertFalse($node->isNew(), 'Node was not saved'); $this->assertFalse($node->getProperty('test2')->isNew(), 'Property was not saved'); $this->renewSession(); - $node = $this->session->getNode($path . '/unstructuredNode'); + $node = $this->session->getNode($path.'/unstructuredNode'); $this->assertEquals('val2', $node->getPropertyValue('test2'), 'Property was not added correctly'); } @@ -194,7 +199,7 @@ public function testAddMultiValuePropertyOnUnstructured() $this->assertFalse($node->isNew(), 'Node was not saved'); $this->renewSession(); - $node = $this->session->getNode($path . '/unstructuredNode2'); + $node = $this->session->getNode($path.'/unstructuredNode2'); $this->assertNotNull($node, 'Node was not created'); $this->assertEquals(array('val', 'val2'), $node->getPropertyValue('test'), 'Property was not saved correctly'); @@ -205,7 +210,7 @@ public function testAddMultiValuePropertyOnUnstructured() $this->assertFalse($node->isNew(), 'Node was not saved'); $this->assertFalse($node->getProperty('test2')->isNew(), 'Property was not saved'); $this->renewSession(); - $node = $this->session->getNode($path . '/unstructuredNode2'); + $node = $this->session->getNode($path.'/unstructuredNode2'); $this->assertEquals(array('val3', 'val4'), $node->getPropertyValue('test2'), 'Property was not added correctly'); } @@ -272,6 +277,7 @@ public function testAddNodeInParallel() /** * try to add a node below a not existing node. + * * @expectedException \PHPCR\PathNotFoundException */ public function testAddNodePathNotFound() @@ -280,7 +286,7 @@ public function testAddNodePathNotFound() } /** - * try to add a node below a property + * try to add a node below a property. * * @expectedException \PHPCR\NodeType\ConstraintViolationException */ @@ -290,7 +296,7 @@ public function testAddNodeToProperty() } /** - * try to add a property of the wrong type + * try to add a property of the wrong type. */ public function testAddPropertyWrongType() { @@ -306,8 +312,7 @@ public function testAddPropertyWrongType() //also correct return; } - $this->fail("Expected PHPCR\\NodeType\\ConstraintViolationException or PHPCR\\ValueFormatException"); - + $this->fail('Expected PHPCR\\NodeType\\ConstraintViolationException or PHPCR\\ValueFormatException'); } /** @@ -319,7 +324,7 @@ public function testAddNodeWithIndex() } /** - * Add a node and a child node to it + * Add a node and a child node to it. */ public function testAddNodeChild() { @@ -339,7 +344,7 @@ public function testAddNodeChild() } /** - * Add a node and a child node with some properties + * Add a node and a child node with some properties. */ public function testAddNodeChildProperties() { @@ -356,7 +361,8 @@ public function testAddNodeChildProperties() } /** - * try to add a node with an unregistered namespace + * try to add a node with an unregistered namespace. + * * @expectedException \PHPCR\RepositoryException */ public function testAddNodeWithUnregisteredNamespace() @@ -365,14 +371,15 @@ public function testAddNodeWithUnregisteredNamespace() $nodeName = 'child'; //add the node with an unregistered namespace, should throw a RepositoryException - $this->node->addNode($namespace . ':' . $nodeName, 'nt:unstructured'); + $this->node->addNode($namespace.':'.$nodeName, 'nt:unstructured'); //save the changes $this->saveAndRenewSession(); } /** - * try to add a property with an unregistered namespace + * try to add a property with an unregistered namespace. + * * @expectedException \PHPCR\RepositoryException */ public function testAddPropertyWithUnregisteredNamespace() @@ -381,7 +388,7 @@ public function testAddPropertyWithUnregisteredNamespace() $propertyName = 'prop'; //add a property with an unregistered namespace, should throw a RepositoryException - $this->node->setProperty($namespace . ':' . $propertyName, 'some value'); + $this->node->setProperty($namespace.':'.$propertyName, 'some value'); //save the changes $this->saveAndRenewSession(); @@ -399,20 +406,20 @@ public function testAddNodeWithAutoCreatedNode() $this->node->addNode('foo', 'test:testautocreate'); $this->session->save(); - $childNode = $this->session->getNode($this->node->getPath() . '/foo'); + $childNode = $this->session->getNode($this->node->getPath().'/foo'); $this->assertNotNull($childNode); - $childNode = $this->session->getNode($this->node->getPath() . '/foo/autocreated'); + $childNode = $this->session->getNode($this->node->getPath().'/foo/autocreated'); $this->assertNotNull($childNode); $primaryType = $childNode->getPrimaryNodeType(); $this->assertEquals('nt:unstructured', $primaryType->getName()); - $childNode = $this->session->getNode($this->node->getPath() . '/foo/autocreatedwithchild'); + $childNode = $this->session->getNode($this->node->getPath().'/foo/autocreatedwithchild'); $this->assertNotNull($childNode); $primaryType = $childNode->getPrimaryNodeType(); $this->assertEquals('test:testAutoCreateChild', $primaryType->getName()); - $childNode = $this->session->getNode($this->node->getPath() . '/foo/autocreatedwithchild/foo'); + $childNode = $this->session->getNode($this->node->getPath().'/foo/autocreatedwithchild/foo'); $this->assertNotNull($childNode); $primaryType = $childNode->getPrimaryNodeType(); $this->assertEquals('nt:unstructured', $primaryType->getName()); diff --git a/tests/10_Writing/CloneMethodsTest.php b/tests/Writing/CloneMethodsTest.php similarity index 96% rename from tests/10_Writing/CloneMethodsTest.php rename to tests/Writing/CloneMethodsTest.php index 9d10f698..be61d6eb 100644 --- a/tests/10_Writing/CloneMethodsTest.php +++ b/tests/Writing/CloneMethodsTest.php @@ -1,14 +1,22 @@ getSession(); self::$destWs->cloneFrom($this->srcWsName, $srcNode, $dstNode, false); @@ -89,7 +97,7 @@ public function testCloneReferenceableWithChild() /** * Clone a referenceable node, then clone again with removeExisting = true - * This should overwrite the existing, corresponding node (same UUID) + * This should overwrite the existing, corresponding node (same UUID). */ public function testCloneReferenceableRemoveExisting() { @@ -130,7 +138,7 @@ public function testCloneReferenceableRemoveExisting() /** * Clone a referenceable node, then clone again with removeExisting = false - * This should cause an exception, even with a corresponding node (same UUID) + * This should cause an exception, even with a corresponding node (same UUID). * * @expectedException \PHPCR\ItemExistsException */ @@ -164,7 +172,7 @@ public function testCloneNoRemoveExistingNewLocation() { $srcNode = '/tests_write_manipulation_clone/testWorkspaceClone/referenceableNoRemoveExisting_2'; $dstNode = $srcNode; - $secondDstNode = '/tests_write_manipulation_clone/testWorkspaceClone/thisShouldStillConflict';; + $secondDstNode = '/tests_write_manipulation_clone/testWorkspaceClone/thisShouldStillConflict'; $destSession = self::$destWs->getSession(); try { @@ -244,7 +252,7 @@ public function testExistingNonCorrespondingNodeNoRemoveExisting() } /** - * Test when source node is non-referenceable but a referenceable node exists at destination path + * Test when source node is non-referenceable but a referenceable node exists at destination path. * * @expectedException \PHPCR\ItemExistsException */ @@ -325,7 +333,7 @@ public function testCloneDstParentNotFound() } /** - * Main test for cloning a non-referenceable node + * Main test for cloning a non-referenceable node. */ public function testCloneNonReferenceable() { @@ -343,7 +351,7 @@ public function testCloneNonReferenceable() } /** - * Clone a non-referenceable node, then clone again with removeExisting = true + * Clone a non-referenceable node, then clone again with removeExisting = true. * * @expectedException \PHPCR\ItemExistsException */ @@ -394,7 +402,7 @@ public function testCloneNonReferenceableNoRemoveExisting() public function testGetCorrespondingNode() { $srcNode = '/tests_write_manipulation_clone/testWorkspaceCorrespondingNode/sourceNode'; - $dstNode = '/tests_write_manipulation_clone/testWorkspaceCorrespondingNode/destNode';; + $dstNode = '/tests_write_manipulation_clone/testWorkspaceCorrespondingNode/destNode'; $destSession = self::$destWs->getSession(); self::$destWs->cloneFrom($this->srcWsName, $srcNode, $dstNode, false); @@ -442,16 +450,16 @@ public function testGetCorrespondingNodeItemNotFound() /** * Main test for cloning and then updating a node and its children. - * Using two levels of children to make sure copy works recursively (and affected nodes not cached) + * Using two levels of children to make sure copy works recursively (and affected nodes not cached). */ public function testUpdateNodeWithChildren() { $srcNode = '/tests_write_manipulation_clone/testWorkspaceUpdateNode/sourceNode'; - $dstNode = '/tests_write_manipulation_clone/testWorkspaceUpdateNode/destNode';; - $srcChildNode = $srcNode . '/cloneChild'; - $dstChildNode = $dstNode . '/cloneChild'; - $srcChildOfChildNode = $srcChildNode . '/childOfChild'; - $dstChildOfChildNode = $dstChildNode . '/childOfChild'; + $dstNode = '/tests_write_manipulation_clone/testWorkspaceUpdateNode/destNode'; + $srcChildNode = $srcNode.'/cloneChild'; + $dstChildNode = $dstNode.'/cloneChild'; + $srcChildOfChildNode = $srcChildNode.'/childOfChild'; + $dstChildOfChildNode = $dstChildNode.'/childOfChild'; $destSession = self::$destWs->getSession(); $sourceSession = $this->srcWs->getSession(); @@ -525,7 +533,7 @@ public function testUpdateNoSuchWorkspace() /** * Test that update has no effect if the source node not found - * (from JCR spec 10.8.3: "If this node does not have a corresponding node in srcWorkspace, then the method has no effect.") + * (from JCR spec 10.8.3: "If this node does not have a corresponding node in srcWorkspace, then the method has no effect."). */ public function testUpdateSrcNotFound() { @@ -550,7 +558,7 @@ public function testUpdateSrcNotFound() try { $clonedNode->update($this->srcWsName); } catch (\Exception $exception) { - $this->fail("'update' method should not raise an error when source not found, got error: " . $exception->getMessage()); + $this->fail("'update' method should not raise an error when source not found, got error: ".$exception->getMessage()); } $destSession->refresh(false); diff --git a/tests/10_Writing/CombinedManipulationsTest.php b/tests/Writing/CombinedManipulationsTest.php similarity index 93% rename from tests/10_Writing/CombinedManipulationsTest.php rename to tests/Writing/CombinedManipulationsTest.php index c994230c..9d482b40 100644 --- a/tests/10_Writing/CombinedManipulationsTest.php +++ b/tests/Writing/CombinedManipulationsTest.php @@ -1,10 +1,18 @@ assertTrue($this->session->nodeExists($path)); $this->assertTrue($this->node->hasNode('child')); - } /** - * add a node and remove it immediately without persisting + * add a node and remove it immediately without persisting. * * should not do anything at the backend */ @@ -117,7 +124,7 @@ public function testAddAndRemove() } /** - * add a property and remove it immediately without persisting + * add a property and remove it immediately without persisting. * * should not do anything at the backend */ @@ -145,7 +152,7 @@ public function testAddAndRemoveProperty() } /** - * Remove a property and in the same session remove its containing node + * Remove a property and in the same session remove its containing node. */ public function testRemovePropertyAndNode() { @@ -171,7 +178,7 @@ public function testRemovePropertyAndNode() } /** - * remove a node and then add a new one at the same path and then remove again + * remove a node and then add a new one at the same path and then remove again. * * in the end, the node must disapear */ @@ -203,7 +210,7 @@ public function testRemoveAndAddAndRemove() } /** - * remove a node and then add a new one at the same path and then remove again + * remove a node and then add a new one at the same path and then remove again. * * in the end, the node must disapear */ @@ -244,7 +251,7 @@ public function testAddAndRemoveAndAdd() public function testRemoveAndAddToplevelNode() { $nodename = 'toBeDeleted'; - if (! $this->rootNode->hasNode($nodename)) { + if (!$this->rootNode->hasNode($nodename)) { $this->rootNode->addNode($nodename, 'nt:unstructured'); } $session = $this->saveAndRenewSession(); @@ -266,7 +273,7 @@ public function testRemoveAndAddToplevelNode() public function testRemoveAndAddAndRemoveToplevelNode() { $nodename = 'toBeDeleted'; - if (! $this->rootNode->hasNode($nodename)) { + if (!$this->rootNode->hasNode($nodename)) { $this->rootNode->addNode($nodename, 'nt:unstructured'); } $session = $this->saveAndRenewSession(); @@ -286,7 +293,7 @@ public function testRemoveAndAddAndRemoveToplevelNode() } /** - * remove a node and then move another node at the same path + * remove a node and then move another node at the same path. */ public function testRemoveAndMove() { @@ -350,7 +357,7 @@ public function testAddAndChildAddAndMove() } /** - * From /src/parent/child we remove child, then move parent to /target and then remove /src + * From /src/parent/child we remove child, then move parent to /target and then remove /src. * * We should be left with /target */ @@ -382,7 +389,7 @@ public function testRemoveMoveRemove() } /** - * Move a node, then remove one of its properties, then move it again + * Move a node, then remove one of its properties, then move it again. */ public function testMoveRemovepropertyMove() { @@ -414,7 +421,7 @@ public function testMoveRemovepropertyMove() } /** - * Move a node and then try to access one of its children (needs the new path) + * Move a node and then try to access one of its children (needs the new path). */ public function testLoadchildMovedNode() { @@ -439,7 +446,7 @@ public function testLoadchildMovedNode() public function testSessionHasPendingChanges() { $this->assertFalse($this->session->hasPendingChanges()); - $this->node->setProperty('prop', "New"); + $this->node->setProperty('prop', 'New'); $this->assertTrue($this->session->hasPendingChanges()); } @@ -513,15 +520,14 @@ public function testRemoveSessionRefresh() $child = $node->getNode('child'); $child->remove(); $this->assertFalse($node->hasNode('child')); - $this->assertFalse($this->session->nodeExists($node->getPath() . '/child')); + $this->assertFalse($this->session->nodeExists($node->getPath().'/child')); $this->session->refresh(false); $this->assertFalse($this->session->hasPendingChanges()); $this->assertEquals('Old', $node->getPropertyValue('prop')); $this->assertTrue($node->hasNode('child')); - $this->assertTrue($this->session->nodeExists($node->getPath() . '/child')); - $this->assertSame($child, $this->session->getNode($node->getPath() . '/child')); - + $this->assertTrue($this->session->nodeExists($node->getPath().'/child')); + $this->assertSame($child, $this->session->getNode($node->getPath().'/child')); } public function testRemoveSessionRefreshKeepChanges() @@ -531,36 +537,36 @@ public function testRemoveSessionRefreshKeepChanges() $node->setProperty('prop', null); $this->assertFalse($node->hasProperty('prop')); - $this->assertFalse($this->session->propertyExists($node->getPath() . '/prop')); + $this->assertFalse($this->session->propertyExists($node->getPath().'/prop')); $child = $node->getNode('child'); $child->remove(); $this->assertFalse($node->hasNode('child')); - $this->assertFalse($this->session->nodeExists($node->getPath() . '/child')); + $this->assertFalse($this->session->nodeExists($node->getPath().'/child')); $this->session->refresh(true); $this->assertTrue($this->session->hasPendingChanges()); $this->assertFalse($node->hasProperty('prop')); - $this->assertFalse($this->session->propertyExists($node->getPath() . '/prop')); + $this->assertFalse($this->session->propertyExists($node->getPath().'/prop')); $this->assertFalse($node->hasNode('child')); - $this->assertFalse($this->session->nodeExists($node->getPath() . '/child')); + $this->assertFalse($this->session->nodeExists($node->getPath().'/child')); $this->session->save(); $this->assertFalse($node->hasProperty('prop')); - $this->assertFalse($this->session->propertyExists($node->getPath() . '/prop')); + $this->assertFalse($this->session->propertyExists($node->getPath().'/prop')); $this->assertFalse($node->hasNode('child')); - $this->assertFalse($this->session->nodeExists($node->getPath() . '/child')); + $this->assertFalse($this->session->nodeExists($node->getPath().'/child')); $session = $this->renewSession(); $node = $session->getNode($path); $this->assertFalse($node->hasProperty('prop')); - $this->assertFalse($session->propertyExists($node->getPath() . '/prop')); + $this->assertFalse($session->propertyExists($node->getPath().'/prop')); $this->assertFalse($node->hasNode('child')); - $this->assertFalse($session->nodeExists($node->getPath() . '/child')); + $this->assertFalse($session->nodeExists($node->getPath().'/child')); } /** * remove a child node and a property in a different session. should - * disappear on refresh, even if we want to keep changes + * disappear on refresh, even if we want to keep changes. */ public function testRemoveOtherSessionRefreshKeepChanges() { @@ -617,18 +623,18 @@ public function testMoveSessionRefresh() $node = $this->node; $child = $node->getNode('src/child'); - $this->session->move($node->getPath() . '/src/child', $node->getPath() . '/target/childnew'); + $this->session->move($node->getPath().'/src/child', $node->getPath().'/target/childnew'); - $this->assertFalse($this->session->nodeExists($node->getPath() . '/src/child')); - $this->assertTrue($this->session->nodeExists($node->getPath() . '/target/childnew')); + $this->assertFalse($this->session->nodeExists($node->getPath().'/src/child')); + $this->assertTrue($this->session->nodeExists($node->getPath().'/target/childnew')); $this->assertTrue($this->session->hasPendingChanges()); $this->session->refresh(false); $this->assertFalse($this->session->hasPendingChanges()); - $this->assertTrue($this->session->nodeExists($node->getPath() . '/src/child')); - $this->assertFalse($this->session->nodeExists($node->getPath() . '/target/childnew')); - $this->assertEquals($node->getPath() . '/src/child', $child->getPath()); + $this->assertTrue($this->session->nodeExists($node->getPath().'/src/child')); + $this->assertFalse($this->session->nodeExists($node->getPath().'/target/childnew')); + $this->assertEquals($node->getPath().'/src/child', $child->getPath()); $src = $node->getNode('src'); $this->assertTrue($src->hasNode('child')); $this->assertSame($child, $src->getNode('child')); @@ -642,17 +648,17 @@ public function testMoveSessionRefreshKeepChanges() $path = $node->getPath(); $child = $node->getNode('src/child'); - $this->session->move($node->getPath() . '/src/child', $node->getPath() . '/target/childnew'); + $this->session->move($node->getPath().'/src/child', $node->getPath().'/target/childnew'); - $this->assertFalse($this->session->nodeExists($node->getPath() . '/src/child')); - $this->assertTrue($this->session->nodeExists($node->getPath() . '/target/childnew')); + $this->assertFalse($this->session->nodeExists($node->getPath().'/src/child')); + $this->assertTrue($this->session->nodeExists($node->getPath().'/target/childnew')); $this->session->refresh(true); $this->assertTrue($this->session->hasPendingChanges()); - $this->assertFalse($this->session->nodeExists($node->getPath() . '/src/child')); - $this->assertTrue($this->session->nodeExists($node->getPath() . '/target/childnew')); - $this->assertEquals($node->getPath() . '/target/childnew', $child->getPath()); + $this->assertFalse($this->session->nodeExists($node->getPath().'/src/child')); + $this->assertTrue($this->session->nodeExists($node->getPath().'/target/childnew')); + $this->assertEquals($node->getPath().'/target/childnew', $child->getPath()); $src = $node->getNode('src'); $this->assertFalse($src->hasNode('child')); $target = $node->getNode('target'); @@ -660,9 +666,9 @@ public function testMoveSessionRefreshKeepChanges() $this->assertSame($child, $target->getNode('childnew')); $this->session->save(); - $this->assertFalse($this->session->nodeExists($node->getPath() . '/src/child')); - $this->assertTrue($this->session->nodeExists($node->getPath() . '/target/childnew')); - $this->assertEquals($node->getPath() . '/target/childnew', $child->getPath()); + $this->assertFalse($this->session->nodeExists($node->getPath().'/src/child')); + $this->assertTrue($this->session->nodeExists($node->getPath().'/target/childnew')); + $this->assertEquals($node->getPath().'/target/childnew', $child->getPath()); $src = $node->getNode('src'); $this->assertFalse($src->hasNode('child')); $target = $node->getNode('target'); @@ -671,9 +677,9 @@ public function testMoveSessionRefreshKeepChanges() $session = $this->renewSession(); $node = $session->getNode($path); - $this->assertFalse($session->nodeExists($node->getPath() . '/src/child')); - $this->assertTrue($session->nodeExists($node->getPath() . '/target/childnew')); - $this->assertEquals($node->getPath() . '/target/childnew', $child->getPath()); + $this->assertFalse($session->nodeExists($node->getPath().'/src/child')); + $this->assertTrue($session->nodeExists($node->getPath().'/target/childnew')); + $this->assertEquals($node->getPath().'/target/childnew', $child->getPath()); $src = $node->getNode('src'); $this->assertFalse($src->hasNode('child')); $target = $node->getNode('target'); diff --git a/tests/10_Writing/CopyMethodsTest.php b/tests/Writing/CopyMethodsTest.php similarity index 96% rename from tests/10_Writing/CopyMethodsTest.php rename to tests/Writing/CopyMethodsTest.php index 9febb4e8..2094e8a5 100644 --- a/tests/10_Writing/CopyMethodsTest.php +++ b/tests/Writing/CopyMethodsTest.php @@ -1,12 +1,20 @@ getReferences(); $this->assertCount(2, $references); - $this->session->refresh(true ); + $this->session->refresh(true); $node = $this->session->getNode($ref); $references = $node->getReferences(); @@ -214,7 +222,7 @@ public function testCopyUpdateReferencesSingleValue() /** * Copied nodes which reference other nodes should be shown in the referrers list of references - * Multi-value + * Multi-value. */ public function testCopyUpdateReferencesMultiValue() { diff --git a/tests/10_Writing/DeleteMethodsTest.php b/tests/Writing/DeleteMethodsTest.php similarity index 93% rename from tests/10_Writing/DeleteMethodsTest.php rename to tests/Writing/DeleteMethodsTest.php index 618b3722..26549781 100644 --- a/tests/10_Writing/DeleteMethodsTest.php +++ b/tests/Writing/DeleteMethodsTest.php @@ -1,12 +1,20 @@ rootNode->hasNode($nodename)) { + if (!$this->rootNode->hasNode($nodename)) { $this->rootNode->addNode($nodename, 'nt:unstructured'); $this->session->save(); $this->renewSession(); @@ -165,7 +175,7 @@ public function testRemoveNodeFromBackend() } /** - * add a property, save it, remove it, save again, try to access the removed property + * add a property, save it, remove it, save again, try to access the removed property. */ public function testRemovePropertyFromBackend() { @@ -181,12 +191,11 @@ public function testRemovePropertyFromBackend() $this->setExpectedException('\PHPCR\PathNotFoundException'); $this->session->getNode('/')->getProperty('toBeDeletedProperty'); - } /** * \PHPCR\PropertyInterface::remove - * \PHPCR\PropertyInterface::setValue + * \PHPCR\PropertyInterface::setValue. */ public function testRemoveProperty() { @@ -209,7 +218,7 @@ public function testRemoveProperty() } /** - * \PHPCR\NodeInterface::setProperty + * \PHPCR\NodeInterface::setProperty. */ public function testNodeRemoveProperty() { @@ -223,11 +232,11 @@ public function testNodeRemoveProperty() } /** - * \PHPCR\NodeInterface::setProperty + * \PHPCR\NodeInterface::setProperty. */ public function testNodeRemovePropertyNotExisting() { -// $this->node->setProperty('inexistent', null); + // $this->node->setProperty('inexistent', null); $this->markTestIncomplete('TODO: figure out what should happen when inexistant property is removed'); //relies on the base class setup trick to have the node populated from the fixtures @@ -235,7 +244,8 @@ public function testNodeRemovePropertyNotExisting() } /** - * \PHPCR\NodeInterface::setProperty + * \PHPCR\NodeInterface::setProperty. + * * @expectedException \PHPCR\NodeType\ConstraintViolationException */ public function testNodeRemovePropertyConstraintViolation() @@ -247,7 +257,8 @@ public function testNodeRemovePropertyConstraintViolation() } /** - * \PHPCR\NodeInterface::setProperty + * \PHPCR\NodeInterface::setProperty. + * * @expectedException \PHPCR\NodeType\ConstraintViolationException */ public function testRemovePropertyConstraintViolation() @@ -260,7 +271,8 @@ public function testRemovePropertyConstraintViolation() /** * \PHPCR\NodeInterface::remove - * \PHPCR\SessionInterface::getNode + * \PHPCR\SessionInterface::getNode. + * * @expectedException \PHPCR\PathNotFoundException */ public function testGetRemovedNodeSession() @@ -275,7 +287,8 @@ public function testGetRemovedNodeSession() /** * \PHPCR\NodeInterface::remove - * \PHPCR\NodeInterface::getNode + * \PHPCR\NodeInterface::getNode. + * * @expectedException \PHPCR\PathNotFoundException */ public function testGetRemovedNodeNode() @@ -291,7 +304,8 @@ public function testGetRemovedNodeNode() /** * \PHPCR\NodeInterface::remove - * \PHPCR\SessionInterface::getNode + * \PHPCR\SessionInterface::getNode. + * * @expectedException \PHPCR\PathNotFoundException */ public function testGetRemovedPropertySession() @@ -307,7 +321,8 @@ public function testGetRemovedPropertySession() /** * \PHPCR\NodeInterface::remove - * \PHPCR\NodeInterface::getNode + * \PHPCR\NodeInterface::getNode. + * * @expectedException \PHPCR\PathNotFoundException */ public function testGetRemovedPropertyNode() @@ -322,7 +337,8 @@ public function testGetRemovedPropertyNode() } /** - * try to remove a node that has already been removed in this session + * try to remove a node that has already been removed in this session. + * * @expectedException \PHPCR\PathNotFoundException */ public function testRemoveRemovedNode() @@ -336,7 +352,7 @@ public function testRemoveRemovedNode() } /** - * Try to call revert on a property that has been removed in this session + * Try to call revert on a property that has been removed in this session. * * @expectedException \PHPCR\InvalidItemStateException */ @@ -350,7 +366,7 @@ public function testRevertRemovedProperty() } /** - * deleting a node must cascade to its children + * deleting a node must cascade to its children. */ public function testDeleteCascade() { @@ -398,7 +414,7 @@ public function testDeleteCascade() } /** - * It is not allowed to delete a referenced node + * It is not allowed to delete a referenced node. * * @expectedException \PHPCR\ReferentialIntegrityException */ @@ -414,7 +430,7 @@ public function testDeleteReferencedNodeException() /** * however, if the reference is first deleted, it must be possible to - * delete the node + * delete the node. */ public function testDeletePreviouslyReferencedNode() { @@ -435,7 +451,7 @@ public function testDeletePreviouslyReferencedNode() } /** - * it must be possible to delete a weakly referenced node + * it must be possible to delete a weakly referenced node. */ public function testDeleteWeakReferencedNode() { @@ -451,7 +467,7 @@ public function testDeleteWeakReferencedNode() /** * test if deleting a node and creating a node at the same path with a new UUID - * won't cause trouble with internally cached UUID's + * won't cause trouble with internally cached UUID's. */ public function testDeleteNodeAndReusePathWithReference() { @@ -470,13 +486,13 @@ public function testDeleteNodeAndReusePathWithReference() try { $this->session->getNodeByIdentifier($uuid); $this->fail('Removed node was still found'); - } catch(ItemNotFoundException $e) { + } catch (ItemNotFoundException $e) { // expected } try { $this->session->getNodeByIdentifier($childUuid); $this->fail('Removed child node was still found'); - } catch(ItemNotFoundException $e) { + } catch (ItemNotFoundException $e) { // expected } diff --git a/tests/10_Writing/EncodingTest.php b/tests/Writing/EncodingTest.php similarity index 78% rename from tests/10_Writing/EncodingTest.php rename to tests/Writing/EncodingTest.php index f96a3d58..78148362 100644 --- a/tests/10_Writing/EncodingTest.php +++ b/tests/Writing/EncodingTest.php @@ -1,7 +1,15 @@ session instanceof \Jackalope\Session) { + if (!$this->session instanceof \Jackalope\Session) { $this->markTestSkipped('This test is only meant for Jackalope'); //TODO: this is a unit test that belongs into jackalope } diff --git a/tests/10_Writing/LastModifiedTest.php b/tests/Writing/LastModifiedTest.php similarity index 94% rename from tests/10_Writing/LastModifiedTest.php rename to tests/Writing/LastModifiedTest.php index f66fcbed..90361b60 100644 --- a/tests/10_Writing/LastModifiedTest.php +++ b/tests/Writing/LastModifiedTest.php @@ -1,10 +1,17 @@ assertTrue($child->hasProperty('jcr:created')); $date = $child->getPropertyValue('jcr:created'); $this->assertInstanceOf('DateTime', $date); - /** @var $date \DateTime */ + /* @var $date \DateTime */ $diff = time() - $date->getTimestamp(); - $this->assertTrue($diff < 60*10, "jcr:created should be current date as fixture was just imported: ".$date->format('c')); + $this->assertTrue($diff < 60 * 10, 'jcr:created should be current date as fixture was just imported: '.$date->format('c')); // Re-read the node to be sure things got properly saved $this->renewSession(); @@ -47,6 +55,6 @@ public function testCreationNode() $date = $child->getPropertyValue('jcr:created'); $this->assertInstanceOf('DateTime', $date); $diff = time() - $date->getTimestamp(); - $this->assertTrue($diff < 60*10, "jcr:created should be current date as fixture was just imported: ".$date->format('c')); + $this->assertTrue($diff < 60 * 10, 'jcr:created should be current date as fixture was just imported: '.$date->format('c')); } } diff --git a/tests/10_Writing/MixinReferenceableTest.php b/tests/Writing/MixinReferenceableTest.php similarity index 95% rename from tests/10_Writing/MixinReferenceableTest.php rename to tests/Writing/MixinReferenceableTest.php index 1a12f830..6a3374b7 100644 --- a/tests/10_Writing/MixinReferenceableTest.php +++ b/tests/Writing/MixinReferenceableTest.php @@ -1,12 +1,20 @@ getNode('child'); $first->rename('otherName'); - $this->assertEquals($this->node->getPath() . '/otherName', $first->getPath()); - $this->assertEquals($first->getPath() . '/child', $child->getPath()); + $this->assertEquals($this->node->getPath().'/otherName', $first->getPath()); + $this->assertEquals($first->getPath().'/child', $child->getPath()); $session = $this->saveAndRenewSession(); @@ -76,7 +83,7 @@ public function testSessionMove() } /** - * Try to move nodes: + * Try to move nodes:. * * src: /my/path * dst: /my/new/path @@ -99,16 +106,16 @@ public function testSessionMoveSimilarSiblings() // Session $this->assertTrue($this->session->nodeExists($dst), 'Destination node not found [S]'); $this->assertFalse($this->session->nodeExists($src), 'Source node still exists [S]'); - $this->assertTrue($this->session->nodeExists($dst . '/another'), 'Destination child node not found [S]'); - $this->assertFalse($this->session->nodeExists($src . '/another'), 'Source child node still exists [S]'); + $this->assertTrue($this->session->nodeExists($dst.'/another'), 'Destination child node not found [S]'); + $this->assertFalse($this->session->nodeExists($src.'/another'), 'Source child node still exists [S]'); $this->assertTrue($this->session->nodeExists($probSrc), 'Sibling nodes should\'nt be moved'); $this->assertFalse($this->session->nodeExists($probDst), 'Sibling nodes should\'nt be moved'); $this->session->save(); $this->assertTrue($this->session->nodeExists($dst), 'Destination node not found [B]'); $this->assertFalse($this->session->nodeExists($src), 'Source node still exists [B]'); - $this->assertTrue($this->session->nodeExists($dst . '/another'), 'Destination child node not found [B]'); - $this->assertFalse($this->session->nodeExists($src . '/another'), 'Source child node still exists [B]'); + $this->assertTrue($this->session->nodeExists($dst.'/another'), 'Destination child node not found [B]'); + $this->assertFalse($this->session->nodeExists($src.'/another'), 'Source child node still exists [B]'); $this->assertTrue($this->session->nodeExists($probSrc), 'Sibling nodes should\'nt be moved'); $this->assertFalse($this->session->nodeExists($probDst), 'Sibling nodes should\'nt be moved'); @@ -116,14 +123,14 @@ public function testSessionMoveSimilarSiblings() $session = $this->renewSession(); $this->assertTrue($session->nodeExists($dst), 'Destination node not found [B]'); $this->assertFalse($session->nodeExists($src), 'Source node still exists [B]'); - $this->assertTrue($session->nodeExists($dst . '/another'), 'Destination child node not found [B]'); - $this->assertFalse($session->nodeExists($src. '/another'), 'Source child node still exists [B]'); + $this->assertTrue($session->nodeExists($dst.'/another'), 'Destination child node not found [B]'); + $this->assertFalse($session->nodeExists($src.'/another'), 'Source child node still exists [B]'); $this->assertTrue($session->nodeExists($probSrc), 'Sibling nodes should\'nt be moved'); $this->assertFalse($session->nodeExists($probDst), 'Sibling nodes should\'nt be moved'); } /** - * Try to move nodes that are already held in memory: + * Try to move nodes that are already held in memory:. * * src: /my/path * dst: /my/new/path @@ -149,16 +156,16 @@ public function testSessionMoveSimilarSiblingsInMemory() // Session $this->assertTrue($this->session->nodeExists($dst), 'Destination node not found [S]'); $this->assertFalse($this->session->nodeExists($src), 'Source node still exists [S]'); - $this->assertTrue($this->session->nodeExists($dst . '/another'), 'Destination child node not found [S]'); - $this->assertFalse($this->session->nodeExists($src . '/another'), 'Source child node still exists [S]'); + $this->assertTrue($this->session->nodeExists($dst.'/another'), 'Destination child node not found [S]'); + $this->assertFalse($this->session->nodeExists($src.'/another'), 'Source child node still exists [S]'); $this->assertTrue($this->session->nodeExists($probSrc), 'Sibling nodes should\'nt be moved'); $this->assertFalse($this->session->nodeExists($probDst), 'Sibling nodes should\'nt be moved'); $this->session->save(); $this->assertTrue($this->session->nodeExists($dst), 'Destination node not found [B]'); $this->assertFalse($this->session->nodeExists($src), 'Source node still exists [B]'); - $this->assertTrue($this->session->nodeExists($dst . '/another'), 'Destination child node not found [B]'); - $this->assertFalse($this->session->nodeExists($src . '/another'), 'Source child node still exists [B]'); + $this->assertTrue($this->session->nodeExists($dst.'/another'), 'Destination child node not found [B]'); + $this->assertFalse($this->session->nodeExists($src.'/another'), 'Source child node still exists [B]'); $this->assertTrue($this->session->nodeExists($probSrc), 'Sibling nodes should\'nt be moved'); $this->assertFalse($this->session->nodeExists($probDst), 'Sibling nodes should\'nt be moved'); @@ -166,8 +173,8 @@ public function testSessionMoveSimilarSiblingsInMemory() $session = $this->renewSession(); $this->assertTrue($session->nodeExists($dst), 'Destination node not found [B]'); $this->assertFalse($session->nodeExists($src), 'Source node still exists [B]'); - $this->assertTrue($session->nodeExists($dst . '/another'), 'Destination child node not found [B]'); - $this->assertFalse($session->nodeExists($src. '/another'), 'Source child node still exists [B]'); + $this->assertTrue($session->nodeExists($dst.'/another'), 'Destination child node not found [B]'); + $this->assertFalse($session->nodeExists($src.'/another'), 'Source child node still exists [B]'); $this->assertTrue($session->nodeExists($probSrc), 'Sibling nodes should\'nt be moved'); $this->assertFalse($session->nodeExists($probDst), 'Sibling nodes should\'nt be moved'); } @@ -200,11 +207,11 @@ public function testSessionMoveWhitespace() } /** - * Makes sure that UUID is not modified during a move for mix:referenceable nodes + * Makes sure that UUID is not modified during a move for mix:referenceable nodes. */ public function testSessionMoveReferenceable() { - $dst = $this->node->getPath() . '/dstNode/srcNode'; + $dst = $this->node->getPath().'/dstNode/srcNode'; $node = $this->node->getNode('srcNode'); $srcUuid = $node->getIdentifier(); $src = $node->getPath(); @@ -225,7 +232,7 @@ public function testSessionMoveReferenceable() /** * Verifies that locally cached node itself knows about the move and Node::getPath() - * returns the new path + * returns the new path. */ public function testSessionMovePathUpdated() { @@ -381,7 +388,7 @@ public function testSessionMoveAdded() } /** - * Adds a node, moves its child + * Adds a node, moves its child. */ public function testSessionMoveChildAdded() { @@ -407,7 +414,7 @@ public function testSessionMoveChildAdded() } /** - * Moves a node and then moves its child + * Moves a node and then moves its child. */ public function testSessionMoveChildMoved() { diff --git a/tests/10_Writing/NamespaceRegistryTest.php b/tests/Writing/NamespaceRegistryTest.php similarity index 92% rename from tests/10_Writing/NamespaceRegistryTest.php rename to tests/Writing/NamespaceRegistryTest.php index de579abc..f15e1587 100644 --- a/tests/10_Writing/NamespaceRegistryTest.php +++ b/tests/Writing/NamespaceRegistryTest.php @@ -1,10 +1,18 @@ 'http://www.jcp.org/jcr/nt/1.0', 'mix' => 'http://www.jcp.org/jcr/mix/1.0', 'xml' => 'http://www.w3.org/XML/1998/namespace', - '' => ''); + '' => '', ); public function setUp() { @@ -143,7 +151,6 @@ public function testIterator() $this->assertInternalType('string', $url); $this->assertEquals($url, $this->nr->getURI($prefix)); } - $this->assertTrue($results>3, 'Not enough namespaces'); + $this->assertTrue($results > 3, 'Not enough namespaces'); } - } diff --git a/tests/10_Writing/NodeTypeAssignementTest.php b/tests/Writing/NodeTypeAssignementTest.php similarity index 94% rename from tests/10_Writing/NodeTypeAssignementTest.php rename to tests/Writing/NodeTypeAssignementTest.php index 31971ca2..48ff48d7 100644 --- a/tests/10_Writing/NodeTypeAssignementTest.php +++ b/tests/Writing/NodeTypeAssignementTest.php @@ -1,7 +1,15 @@ assertTrue($this->file->canRemoveProperty('jcr:mimeType')); $this->assertFalse($this->file->canRemoveProperty('jcr:created')); } - } diff --git a/tests/10_Writing/SetPropertyDynamicRebindingTest.php b/tests/Writing/SetPropertyDynamicRebindingTest.php similarity index 93% rename from tests/10_Writing/SetPropertyDynamicRebindingTest.php rename to tests/Writing/SetPropertyDynamicRebindingTest.php index 7e3db61b..d693c9c2 100644 --- a/tests/10_Writing/SetPropertyDynamicRebindingTest.php +++ b/tests/Writing/SetPropertyDynamicRebindingTest.php @@ -1,7 +1,15 @@ saveAndRenewSession(); - $prop = $this->session->getProperty('/' . $propName); + $prop = $this->session->getProperty('/'.$propName); $this->assertInstanceOf('\PHPCR\PropertyInterface', $prop); $this->assertEquals($sourcePropType, $prop->getType(), 'Initial property type does not match after saving'); @@ -113,7 +121,7 @@ public function testDynamicRebinding($propName, $sourcePropType, $sourcePropValu // Finally re-read it from backend and check it's still ok $this->saveAndRenewSession(); - $prop = $this->session->getProperty('/' . $propName); + $prop = $this->session->getProperty('/'.$propName); $this->assertInstanceOf('\PHPCR\PropertyInterface', $prop); $this->assertEquals($destPropType, $prop->getType(), 'Property type does not match after re-binding and save'); @@ -128,7 +136,7 @@ public function testDynamicRebinding($propName, $sourcePropType, $sourcePropValu /** * Construct the test data for the testDynamicRebinding test. - * The resulting array is composed of arrays as follow: + * The resulting array is composed of arrays as follow:. * * array(new_property_name, * initial_property_type, initial_property_value, @@ -174,8 +182,8 @@ public function dynamicRebindingProvider() foreach ($typesAndValues as $destKey => $destVal) { if ($sourceKey !== $destKey) { $propName = - 'dynRebinding_' . PropertyType::nameFromValue($sourceKey) . - '_To_' . PropertyType::nameFromValue($destKey); + 'dynRebinding_'.PropertyType::nameFromValue($sourceKey). + '_To_'.PropertyType::nameFromValue($destKey); $provider[] = array($propName, $sourceKey, $sourceVal, $destKey, $destVal, $getters[$destKey]); } } diff --git a/tests/10_Writing/SetPropertyMethodsTest.php b/tests/Writing/SetPropertyMethodsTest.php similarity index 90% rename from tests/10_Writing/SetPropertyMethodsTest.php rename to tests/Writing/SetPropertyMethodsTest.php index e55faa75..19234b02 100644 --- a/tests/10_Writing/SetPropertyMethodsTest.php +++ b/tests/Writing/SetPropertyMethodsTest.php @@ -1,12 +1,20 @@ node->setProperty('multivalue', array(1, 2, 3)); - $this->assertEquals(array(1,2,3), $this->node->getPropertyValue('multivalue')); + $this->assertEquals(array(1, 2, 3), $this->node->getPropertyValue('multivalue')); $this->assertEquals(\PHPCR\PropertyType::LONG, $prop->getType()); $this->assertTrue($prop->isMultiple()); @@ -156,7 +164,7 @@ public function testSetPropertyMultivalue() $prop = $node->getProperty('multivalue'); $this->assertEquals(\PHPCR\PropertyType::LONG, $prop->getType()); $this->assertTrue($prop->isMultiple()); - $this->assertEquals(array(1,2,3), $prop->getValue()); + $this->assertEquals(array(1, 2, 3), $prop->getValue()); } public function testSetPropertyMultivalueOne() @@ -237,17 +245,17 @@ public function testSetPropertyMultivalueRef() public function testPropertyAddValue() { $prop = $this->node->getProperty('multiBoolean'); - $this->assertEquals(array(false,true), $prop->getValue()); + $this->assertEquals(array(false, true), $prop->getValue()); $this->assertTrue($prop->isMultiple()); $prop->addValue(true); - $this->assertEquals(array(false,true,true), $prop->getValue()); + $this->assertEquals(array(false, true, true), $prop->getValue()); $this->saveAndRenewSession(); $node = $this->session->getNode($this->nodePath); $prop = $node->getProperty('multiBoolean'); $this->assertEquals(\PHPCR\PropertyType::BOOLEAN, $prop->getType()); $this->assertTrue($prop->isMultiple()); - $this->assertEquals(array(false,true,true), $prop->getValue()); + $this->assertEquals(array(false, true, true), $prop->getValue()); } /** @@ -265,25 +273,25 @@ public function testPropertyAddValueNoMultivalue() public function testPropertySetValueNoMultivalue() { $prop = $this->node->getProperty('longNumber'); - $prop->setValue(array(33,34)); + $prop->setValue(array(33, 34)); } public function testNewNodeSetProperty() { $node = $this->node->addNode('child'); $prop = $node->setProperty('p', 'abc'); - $this->assertTrue($this->session->nodeExists($this->nodePath . '/child')); - $this->assertTrue($this->session->propertyExists($this->nodePath . '/child/p')); + $this->assertTrue($this->session->nodeExists($this->nodePath.'/child')); + $this->assertTrue($this->session->propertyExists($this->nodePath.'/child/p')); $this->assertInstanceOf('\PHPCR\PropertyInterface', $prop); $this->assertEquals(\PHPCR\PropertyType::STRING, $prop->getType()); $this->assertEquals('abc', $prop->getString()); $session = $this->saveAndRenewSession(); - $this->assertTrue($session->nodeExists($this->nodePath . '/child')); - $this->assertTrue($session->propertyExists($this->nodePath . '/child/p')); + $this->assertTrue($session->nodeExists($this->nodePath.'/child')); + $this->assertTrue($session->propertyExists($this->nodePath.'/child/p')); - $node = $session->getNode($this->nodePath . '/child'); + $node = $session->getNode($this->nodePath.'/child'); $prop = $node->getProperty('p'); $this->assertInstanceOf('\PHPCR\PropertyInterface', $prop); @@ -303,12 +311,12 @@ public function testRemoveProperty() { $nodePath = '/tests_general_base/index.txt/jcr:content'; - $this->assertTrue($this->session->propertyExists($nodePath . '/jcr:data')); + $this->assertTrue($this->session->propertyExists($nodePath.'/jcr:data')); $node = $this->session->getNode($nodePath); $node->setProperty('jcr:data', null); $this->saveAndRenewSession(); - $this->assertFalse($this->session->propertyExists($nodePath . '/jcr:data')); + $this->assertFalse($this->session->propertyExists($nodePath.'/jcr:data')); } } diff --git a/tests/10_Writing/SetPropertyTypesTest.php b/tests/Writing/SetPropertyTypesTest.php similarity index 98% rename from tests/10_Writing/SetPropertyTypesTest.php rename to tests/Writing/SetPropertyTypesTest.php index f8a436d8..ca0a18d9 100644 --- a/tests/10_Writing/SetPropertyTypesTest.php +++ b/tests/Writing/SetPropertyTypesTest.php @@ -1,13 +1,21 @@ assertEquals(\PHPCR\PropertyType::LONG, $value->getType()); } - public function testCreateValueDouble() { $value = $this->node->setProperty('propDouble', 10.6);