Skip to content

Commit d7eacdc

Browse files
committed
Minor improvements
- Skip autocreate writing tests if repository does not support autocreate - Throw better exception
1 parent 9cdc05c commit d7eacdc

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

inc/AbstractLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ private function getSessionForWorkspace($credentials, $workspaceName)
253253
$session = $adminRepository->login($this->getCredentials(), 'default');
254254
$workspace = $session->getWorkspace();
255255
if (in_array($workspaceName, $workspace->getAccessibleWorkspaceNames())) {
256-
throw new \Exception("Failed to log into $workspaceName");
256+
throw new \Exception(sprintf('Workspace "%s" already exists but could not login to it', $workspaceName), null, $e);
257257
}
258258
$workspace->createWorkspace($workspaceName);
259259

inc/BaseCase.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,21 @@ protected function assertSimilarDateTime($expected, $data)
269269
$data->format('c') . ' is not close to the expected ' . $expected->format('c')
270270
);
271271
}
272+
273+
/**
274+
* Check to see if the given descriptor evaluates to false, if it does
275+
* mark the test as skipped and return False, else return True.
276+
*
277+
* @param sting $descriptor
278+
* @return boolean
279+
*/
280+
protected function skipIfNotSupported($descriptor)
281+
{
282+
if (false === $this->session->getRepository()->getDescriptor($descriptor)) {
283+
$this->markTestSkipped('Descriptor "' . $descriptor . '" not supported');
284+
return false;
285+
}
286+
287+
return true;
288+
}
272289
}

tests/10_Writing/AddMethodsTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
require_once(__DIR__ . '/../../inc/BaseCase.php');
55

66
use PHPCR\PropertyType as Type;
7+
use PHPCR\RepositoryInterface;
78

89
/**
910
* Covering jcr-283 spec $10.4
@@ -386,6 +387,10 @@ public function testAddPropertyWithUnregisteredNamespace()
386387

387388
public function testAddNodeWithAutoCreatedNode()
388389
{
390+
if ($this->skipIfNotSupported(RepositoryInterface::NODE_TYPE_MANAGEMENT_AUTOCREATED_DEFINITIONS_SUPPORTED)) {
391+
return;
392+
}
393+
389394
$workspace = $this->session->getWorkspace();
390395
$cnd = file_get_contents(__DIR__.'/../../fixtures/10_Writing/add_auto_create.cnd');
391396
$workspace->getNodeTypeManager()->registerNodeTypesCnd($cnd, true);

0 commit comments

Comments
 (0)