Skip to content

Commit

Permalink
Restructured tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Dec 8, 2014
1 parent 8511670 commit 76dc743
Show file tree
Hide file tree
Showing 13 changed files with 322 additions and 239 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ before_script:
- sed '/jackalope\/jackalope-transport/d' composer.json >> tmp; mv tmp composer.json
- composer update --prefer-source

script: phpunit -c tests/phpunit.xml.dist
script: phpunit

notifications:
irc: "irc.freenode.org#jackalope"
Expand Down
6 changes: 3 additions & 3 deletions tests/phpunit.xml.dist → phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="true"
strict="false"
bootstrap="bootstrap.php">
bootstrap="tests/bootstrap.php">

<testsuites>
<testsuite name="Jackalope Tests">
<directory>./Jackalope</directory>
<directory>./tests/Jackalope</directory>
</testsuite>
</testsuites>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Validation;
namespace Jackalope\Validation\Exception;

use PHPCR\ValueFormatException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php

namespace Jackalope\Validation;
namespace Jackalope\Validation\Path;

use DOMElement;
use Jackalope\Validation\Exception\InvalidPathException;
use Jackalope\Validation\PathValidatorInterface;

/**
* Abstract class for regex based validators
Expand All @@ -14,8 +16,18 @@
*/
abstract class AbstractRegexValidator implements PathValidatorInterface
{
/**
* Return a regular expression for a valid path
*
* @return string
*/
abstract protected function getPathPattern();

/**
* Return a regular expression for a valid name
*
* @return string
*/
abstract protected function getNamePattern();

/**
Expand All @@ -40,6 +52,18 @@ public function validateAbsPath($path)
return $this->validatePath($path);
}

/**
* {@inheritDoc}
*/
public function validateDestPath($path)
{
if (']' === substr($path, -1)) {
throw new InvalidPathException(sprintf('Destination path "%s" must not end with an index', $path));
}

return $this->validatePath($path);
}

/**
* {@inheritDoc}
*/
Expand All @@ -50,6 +74,9 @@ public function validateName($path)
}
}

/**
* {@inheritDoc}
*/
private function validate($path, $pattern)
{
$pattern = '{' . $pattern . '}u';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Jackalope\Validation;
namespace Jackalope\Validation\Path;

use DOMElement;

/**
* Applies the same path validation rules as the Apache Jackrabbit PHPCR implementation.
* Applies the same path validation rules as the Apache Jackrabbit JCR implementation.
*
* Namespaces need to be valid XML elements according to the XML specification:
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Jackalope\Validation;
namespace Jackalope\Validation\Path;

use DOMElement;

Expand Down
10 changes: 10 additions & 0 deletions src/Jackalope/Validation/PathValidatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ public function validatePath($path);
*/
public function validateAbsPath($absPath);

/**
* Assert that the given path is a valid destination path
*
* @param string $path
*
* @return void
* @throws InvalidPathException
*/
public function validateDestPath($destPath);

/**
* Assert that the given path is a valid absolute path
*
Expand Down
111 changes: 0 additions & 111 deletions tests/Jackalope/Validation/JackrabbitPathValidatorTest.php

This file was deleted.

66 changes: 66 additions & 0 deletions tests/Jackalope/Validation/Path/JackrabbitPathValidatorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Jackalope\NodeType\Path;

use Jackalope\NodeType\NodeProcessor;
use Jackalope\TestCase;
use PHPCR\PropertyType;
use Jackalope\Validation\PathValidatorTestCase;
use Jackalope\Validation\Path\JackrabbitPathValidator;

class JackrabbitPathValidatorTest extends PathValidatorTestCase
{
public function getValidator()
{
return new JackrabbitPathValidator();
}

public function getPathAnswers()
{
return array(
'absolute_1' => true,
'absolute_2' => false,
'absolute_3' => false,
'normal_1' => true,
'normal_2' => true,
'normal_3' => true,
'normal_4' => true,
'normal_5' => true,
'normal_6' => true,
'normal_7' => true,
'normal_8' => true,
'normal_9' => true,
'normal_10' => false,
'normal_11' => false,
'normal_12' => false,
'normal_13' => false,
'normal_14' => false,
);
}

public function getNameAnswers()
{
return array(
'normal_1' => false,
'normal_2' => false,
'normal_3' => true,
'normal_4' => true,
'normal_5' => false,
'normal_6' => true,
'namespace_1' => true,
'namespace_2' => true,
'namespace_3' => true,
'namespace_4' => true,
'namespace_5' => false,
'namespace_6' => false,
'namespace_7' => false,
'namespace_8' => false,
'namespace_9' => false,
'localname_1' => true,
'localname_2' => true,
'localname_3' => true,
'localname_4' => true,
'localname_5' => true,
);
}
}
66 changes: 66 additions & 0 deletions tests/Jackalope/Validation/Path/SimplePathValidatorTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace Jackalope\NodeType;

use Jackalope\NodeType\NodeProcessor;
use Jackalope\TestCase;
use PHPCR\PropertyType;
use Jackalope\Validation\PathValidatorTestCase;
use Jackalope\Validation\Path\SimplePathValidator;

class SimplePathValidatorTest extends PathValidatorTestCase
{
public function getValidator()
{
return new SimplePathValidator();
}

public function getPathAnswers()
{
return array(
'absolute_1' => true,
'absolute_2' => false,
'absolute_3' => false,
'normal_1' => true,
'normal_2' => false,
'normal_3' => false,
'normal_4' => false,
'normal_5' => false,
'normal_6' => false,
'normal_7' => true,
'normal_8' => true,
'normal_9' => false,
'normal_10' => false,
'normal_11' => false,
'normal_12' => false,
'normal_13' => false,
'normal_14' => false,
);
}

public function getNameAnswers()
{
return array(
'normal_1' => false,
'normal_2' => false,
'normal_3' => true,
'normal_4' => false,
'normal_5' => false,
'normal_6' => true,
'namespace_1' => false,
'namespace_2' => false,
'namespace_3' => false,
'namespace_4' => false,
'namespace_5' => false,
'namespace_6' => false,
'namespace_7' => false,
'namespace_8' => false,
'namespace_9' => false,
'localname_1' => false,
'localname_2' => false,
'localname_3' => false,
'localname_4' => false,
'localname_5' => false,
);
}
}
Loading

0 comments on commit 76dc743

Please sign in to comment.