Skip to content

non-changing cleanups #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions inc/BaseCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,16 @@ protected function assertSimilarDateTime($expected, $data)
}

/**
* Check to see if the given descriptor evaluates to false, if it does
* mark the test as skipped and return False, else return True.
* Check whether the repository supports this descriptor and skip the test if it is not supported.
*
* @param sting $descriptor
* @return boolean
* @param string $descriptor
*
* @return boolean 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');
return false;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

markTestSkipped throws an exception to skip the test.


return true;
Expand Down
28 changes: 24 additions & 4 deletions tests/08_NodeTypeDiscovery/NodeTypeTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
namespace PHPCR\Tests\NodeTypeDiscovery;

use PHPCR\NodeType\NodeTypeInterface;
use PHPCR\RepositoryInterface;

require_once(__DIR__ . '/../../inc/BaseCase.php');

/**
Expand All @@ -10,10 +13,29 @@
*/
class NodeTypeTest extends \PHPCR\Test\BaseCase
{
/**
* @var NodeTypeInterface
*/
private static $base;

/**
* @var NodeTypeInterface
*/
private static $hierarchyNode;

/**
* @var NodeTypeInterface
*/
private static $file;

/**
* @var NodeTypeInterface
*/
private static $resource;

/**
* @var NodeTypeInterface
*/
private static $created;

public static function setupBeforeClass($fixtures = false)
Expand Down Expand Up @@ -155,11 +177,9 @@ public function testIsNodeTypeMixin()
*/
public function testIsNodeTypeMixinVersion()
{
if (!self::$staticSharedFixture['session']->getRepository()->getDescriptor('option.versioning.supported')) {
$this->markTestSkipped('PHPCR repository doesn\'t support versioning');
}
$this->skipIfNotSupported(RepositoryInterface::OPTION_VERSIONING_SUPPORTED);

$ntm = self::$staticSharedFixture['session']->getWorkspace()->getNodeTypeManager();
$ntm = $this->session->getWorkspace()->getNodeTypeManager();
$versionable = $ntm->getNodeType('mix:versionable');
$this->assertTrue($versionable->isNodeType('mix:versionable'));
$this->assertTrue($versionable->isNodeType('mix:referenceable'));
Expand Down
18 changes: 10 additions & 8 deletions tests/10_Writing/AddMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

require_once(__DIR__ . '/../../inc/BaseCase.php');

use PHPCR\PropertyType as Type;
use PHPCR\NodeType\ConstraintViolationException;
use PHPCR\PropertyType;
use PHPCR\RepositoryInterface;
use PHPCR\ValueFormatException;

/**
* Covering jcr-283 spec $10.4
Expand Down Expand Up @@ -58,9 +60,9 @@ public function testAddNodeFileType()
$path = $this->node->getPath();
$newNode = $this->node->addNode('newFileNode', 'nt:file');
$contentNode = $newNode->addNode('jcr:content', 'nt:resource');
$contentNode->setProperty('jcr:mimeType', 'text/plain', Type::STRING);
$contentNode->setProperty('jcr:data', 'Hello', Type::BINARY);
$contentNode->setProperty('jcr:lastModified', new \DateTime('2010-12-12'), Type::DATE);
$contentNode->setProperty('jcr:mimeType', 'text/plain', PropertyType::STRING);
$contentNode->setProperty('jcr:data', 'Hello', PropertyType::BINARY);
$contentNode->setProperty('jcr:lastModified', new \DateTime('2010-12-12'), PropertyType::DATE);

$this->assertNotNull($newNode, 'Node newFileNode was not created');
$this->assertTrue($newNode->isNew(), 'Node newFileNode is not marked dirty');
Expand Down Expand Up @@ -274,7 +276,7 @@ public function testAddNodeInParallel()
*/
public function testAddNodePathNotFound()
{
$parent = $this->node->addNode('nonExistent/newNode', 'nt:unstructured');
$this->node->addNode('nonExistent/newNode', 'nt:unstructured');
}

/**
Expand All @@ -297,10 +299,10 @@ public function testAddPropertyWrongType()
try {
$data->setProperty('jcr:lastModified', true);
$this->saveAndRenewSession();
} catch (\PHPCR\ValueFormatException $e) {
} catch (ValueFormatException $e) {
//correct according to JSR-287 3.6.4 Property Type Conversion
return;
} catch (\PHPCR\NodeType\ConstraintViolationException $e) {
} catch (ConstraintViolationException $e) {
//also correct
return;
}
Expand Down Expand Up @@ -344,7 +346,7 @@ public function testAddNodeChildProperties()
$parent = $this->node->addNode('parent', 'nt:folder');
$child = $parent->addNode('child', 'nt:file');
$content = $child->addNode('jcr:content', 'nt:resource');
$content->setProperty('jcr:data', '1234', \PHPCR\PropertyType::BINARY);
$content->setProperty('jcr:data', '1234', PropertyType::BINARY);
$path = $child->getPath();

$this->saveAndRenewSession();
Expand Down
7 changes: 6 additions & 1 deletion tests/10_Writing/CloneMethodsTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace PHPCR\Tests\Writing;

use PHPCR\RepositoryInterface;
use PHPCR\WorkspaceInterface;
use PHPCR\Test\BaseCase;

Expand Down Expand Up @@ -567,9 +568,13 @@ private function renewDestinationSession()
self::$destWs = $destSession->getWorkspace();
}

/**
* Some of the tests in this test case assume that same name siblings are *not* supported.
* Those would fail if the repository supports same name siblings, so we skip them in that case.
*/
private function skipIfSameNameSiblingsSupported()
{
if ($this->session->getRepository()->getDescriptor('node.type.management.same.name.siblings.supported')) {
if ($this->session->getRepository()->getDescriptor(RepositoryInterface::NODE_TYPE_MANAGEMENT_SAME_NAME_SIBLINGS_SUPPORTED)) {
$this->markTestSkipped('Test does not yet cover repositories that support same name siblings.');
}
}
Expand Down
39 changes: 16 additions & 23 deletions tests/21_Transactions/TransactionMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

require_once(__DIR__ . '/../../inc/BaseCase.php');

use PHPCR\RepositoryInterface;
use \PHPCR\Transaction;

/**
Expand All @@ -25,23 +26,21 @@ public function setUp()

public function testGetTransactionManager()
{
$session = self::$staticSharedFixture['session'];
$utx = $session->getWorkspace()->getTransactionManager();
$utx = $this->session->getWorkspace()->getTransactionManager();

$this->assertInstanceOf('\PHPCR\Transaction\UserTransactionInterface', $utx);
}

public function testTransactionCommit()
{
$session = self::$staticSharedFixture['session'];
$utx = $session->getWorkspace()->getTransactionManager();
$utx = $this->session->getWorkspace()->getTransactionManager();

$utx->begin();
$child = $this->node->addNode('insideTransaction');

$this->assertEquals($this->node->getPath() . '/insideTransaction', $child->getPath());

$session->save();
$this->session->save();

$sessionbeforesave = self::$loader->getSession();
$this->assertFalse($sessionbeforesave->nodeExists($child->getPath()));
Expand All @@ -55,19 +54,17 @@ public function testTransactionCommit()

public function testTransactionRollback()
{
$session = self::$staticSharedFixture['session'];

$copy = $this->node->addNode('copyTransaction');
$copiedNodePath = $this->node->getPath()."/copyTransactionCopy";
$session->save();
$this->session->save();

$utx = $session->getWorkspace()->getTransactionManager();
$utx = $this->session->getWorkspace()->getTransactionManager();

$child = $this->node->addNode('insideTransaction');
$utx->begin();
//workspace operation
$session->getWorkspace()->copy($copy->getPath(),$copiedNodePath);
$session->save();
$this->session->getWorkspace()->copy($copy->getPath(),$copiedNodePath);
$this->session->save();
$this->assertFalse($child->isNew());
$utx->rollback();

Expand All @@ -79,7 +76,7 @@ public function testTransactionRollback()

// semantics of rollback is that the local session state does not roll back
// this must work
$session->save();
$this->session->save();

$sessionaftersave = self::$loader->getSession();
$this->assertFalse($sessionaftersave->nodeExists($child->getPath()));
Expand All @@ -88,20 +85,19 @@ public function testTransactionRollback()

public function testInTransaction()
{
$session = self::$staticSharedFixture['session'];
$utx= $session->getWorkspace()->getTransactionManager();
$utx= $this->session->getWorkspace()->getTransactionManager();

$this->assertFalse($utx->inTransaction());
$utx->begin();
$this->node->addNode('insideTransaction0');
$session->save();
$this->session->save();
$this->assertTrue($utx->inTransaction());
$utx->commit();
$this->assertFalse($utx->inTransaction());

$utx->begin();
$this->node->addNode('insideTransaction1');
$session->save();
$this->session->save();
$this->assertTrue($utx->inTransaction());
$utx->rollback();
$this->assertFalse($utx->inTransaction());
Expand All @@ -114,19 +110,16 @@ public function testInTransaction()
*/
public function testIllegalCheckin()
{
if (!self::$staticSharedFixture['session']->getRepository()->getDescriptor('option.versioning.supported')) {
$this->markTestSkipped('PHPCR repository doesn\'t support versioning');
}
$this->skipIfNotSupported(RepositoryInterface::OPTION_VERSIONING_SUPPORTED);

$session = self::$staticSharedFixture['session'];
$vm = $session->getWorkspace()->getVersionManager();
$vm = $this->session->getWorkspace()->getVersionManager();

$utx= $session->getWorkspace()->getTransactionManager();
$utx= $this->session->getWorkspace()->getTransactionManager();
$vm->checkout($this->node->getPath());
$this->node->setProperty('foo', 'bar2');

$utx->begin();
$session->save();
$this->session->save();

$vm->checkin($this->node->getPath());
}
Expand Down