Skip to content

Commit

Permalink
Refactored unit tests so that they follow the diretory structure of src/
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Nov 19, 2010
1 parent 52a600d commit be00b4d
Show file tree
Hide file tree
Showing 30 changed files with 393 additions and 388 deletions.
20 changes: 0 additions & 20 deletions tests/ImplementationHelpers.php

This file was deleted.

11 changes: 11 additions & 0 deletions tests/Jackalope/FactoryTest.php
@@ -0,0 +1,11 @@
<?php

namespace Jackalope;

class FactoryTest extends TestCase
{
public function testDummy()
{
$this->markTestSkipped('No tests for this class yet');
}
}
12 changes: 12 additions & 0 deletions tests/Jackalope/HelperTest.php
@@ -0,0 +1,12 @@
<?php

namespace Jackalope;

class HelperTest extends TestCase
{
public function testDummy()
{
$this->markTestSkipped('No tests for this class yet');
}

}
12 changes: 12 additions & 0 deletions tests/Jackalope/ItemTest.php
@@ -0,0 +1,12 @@
<?php

namespace Jackalope;

class ItemTest extends TestCase
{
public function testDummy()
{
$this->markTestSkipped('No tests for this class yet');
}

}
12 changes: 12 additions & 0 deletions tests/Jackalope/NamespaceRegistryTest.php
@@ -0,0 +1,12 @@
<?php

namespace Jackalope;

class NamespaceRegistryTest extends TestCase
{
public function testDummy()
{
$this->markTestSkipped('No tests for this class yet');
}

}
33 changes: 18 additions & 15 deletions tests/JackalopeObjects/Node.php → tests/Jackalope/NodeTest.php
@@ -1,10 +1,11 @@
<?php
namespace jackalope\tests\JackalopeObjects;

require_once(dirname(__FILE__) . '/../inc/baseCase.php');
namespace Jackalope;

class Node extends \jackalope\baseCase {
private $JSON = '{":jcr:primaryType":"Name","jcr:primaryType":"rep:root","jcr:system":{},"tests_level1_access_base":{}}';
class NodeTest extends TestCase
{
protected $JSON = '{":jcr:primaryType":"Name","jcr:primaryType":"rep:root","jcr:system":{},"tests_level1_access_base":{}}';

public function testConstructor() {
$session = $this->getMock('\jackalope\Session', array(), array(), '', false);
$objectManager = $this->getMock('\jackalope\ObjectManager', array(), array(), '', false);
Expand All @@ -17,71 +18,73 @@ public function testConstructor() {
$this->assertType('Iterator', $children);
$this->assertSame(2, count($children));
}

public function testFilterNames() {
$filter = 'test';
$names = array('test', 'toast');
$filtered = PublicFilter::filterNames($filter, $names);
$filtered = NodeMock::filterNames($filter, $names);
$this->assertType('array', $filtered);
$this->assertSame(1, count($filtered));
$this->assertSame('test', $filtered[0]);

$filter = 't*t';
$filtered = PublicFilter::filterNames($filter, $names);
$filtered = NodeMock::filterNames($filter, $names);
$this->assertType('array', $filtered);
$this->assertSame(2, count($filtered));
$this->assertSame('test', $filtered[0]);
$this->assertSame('toast', $filtered[1]);

$filter = 'te.t';
$filtered = PublicFilter::filterNames($filter, $names);
$filtered = NodeMock::filterNames($filter, $names);
$this->assertType('array', $filtered);
$this->assertSame(0, count($filtered));

$filter = 'test|toast';
$filtered = PublicFilter::filterNames($filter, $names);
$filtered = NodeMock::filterNames($filter, $names);
$this->assertType('array', $filtered);
$this->assertSame(2, count($filtered));
$this->assertSame('test', $filtered[0]);
$this->assertSame('toast', $filtered[1]);

$filter = 'test|toast ';
$filtered = PublicFilter::filterNames($filter, $names);
$filtered = NodeMock::filterNames($filter, $names);
$this->assertType('array', $filtered);
$this->assertSame(2, count($filtered));
$this->assertSame('test', $filtered[0]);
$this->assertSame('toast', $filtered[1]);

$filter = array('test ', 'toa*');
$filtered = PublicFilter::filterNames($filter, $names);
$filtered = NodeMock::filterNames($filter, $names);
$this->assertType('array', $filtered);
$this->assertSame(2, count($filtered));
$this->assertSame('test', $filtered[0]);
$this->assertSame('toast', $filtered[1]);

$filter = null;
$filtered = PublicFilter::filterNames($filter, $names);
$filtered = NodeMock::filterNames($filter, $names);
$this->assertType('array', $filtered);
$this->assertSame(2, count($filtered));
$this->assertSame('test', $filtered[0]);
$this->assertSame('toast', $filtered[1]);

$filter = '*';
$filtered = PublicFilter::filterNames($filter, $names);
$filtered = NodeMock::filterNames($filter, $names);
$this->assertType('array', $filtered);
$this->assertSame(2, count($filtered));
$this->assertSame('test', $filtered[0]);
$this->assertSame('toast', $filtered[1]);

$filter = array('*');
$filtered = PublicFilter::filterNames($filter, $names);
$filtered = NodeMock::filterNames($filter, $names);
$this->assertType('array', $filtered);
$this->assertSame(2, count($filtered));
$this->assertSame('test', $filtered[0]);
$this->assertSame('toast', $filtered[1]);
}
}
class PublicFilter extends \jackalope\Node {

class NodeMock extends \jackalope\Node {
public static function filterNames($filter,$names) {
return parent::filterNames($filter,$names);
}
}
}
14 changes: 14 additions & 0 deletions tests/Jackalope/NodeType/ItemDefinitionTest.php
@@ -0,0 +1,14 @@
<?php

namespace Jackalope\NodeType;

use Jackalope\TestCase;

class ItemDefinitionTest extends TestCase
{
public function testDummy()
{
$this->markTestSkipped('No tests for this class yet');
}

}
28 changes: 28 additions & 0 deletions tests/Jackalope/NodeType/NodeDefinitionTemplateTest.php
@@ -0,0 +1,28 @@
<?php

namespace Jackalope\NodeType;

use Jackalope\TestCase;

class NodeDefinitionTemplateTest extends TestCase
{
/**
* @covers jackalope\NodeType\NodeDefinitionTemplate::__construct
*/
public function testCreateNodeDefinitionTemplateEmpty() {
$ntm = $this->getNodeTypeManager();

$ndt = $ntm->createNodeDefinitionTemplate();

// is empty as defined by doc
$this->assertNull($ndt->getName());
$this->assertFalse($ndt->isAutoCreated());
$this->assertFalse($ndt->isMandatory());
$this->assertSame(\PHPCR\Version\OnParentVersionAction::COPY, $ndt->getOnParentVersion());
$this->assertFalse($ndt->isProtected());
$this->assertNull($ndt->getRequiredPrimaryTypeNames());
$this->assertNull($ndt->getDefaultPrimaryTypeName());
$this->assertFalse($ndt->allowsSameNameSiblings());
}

}
14 changes: 14 additions & 0 deletions tests/Jackalope/NodeType/NodeDefinitionTest.php
@@ -0,0 +1,14 @@
<?php

namespace Jackalope\NodeType;

use Jackalope\TestCase;

class NodeDefinitionTest extends TestCase
{
public function testDummy()
{
$this->markTestSkipped('No tests for this class yet');
}

}
14 changes: 14 additions & 0 deletions tests/Jackalope/NodeType/NodeTypeDefinitionTest.php
@@ -0,0 +1,14 @@
<?php

namespace Jackalope\NodeType;

use Jackalope\TestCase;

class NodeTypeDefinitionTest extends TestCase
{
public function testDummy()
{
$this->markTestSkipped('No tests for this class yet');
}

}
@@ -1,14 +1,11 @@
<?php
namespace jackalope\tests\JackalopeObjects;

use \PHPUnit_Framework_Constraint_IsType;
namespace Jackalope\NodeType;

require_once(dirname(__FILE__) . '/../inc/JackalopeObjectsCase.php');
use Jackalope\TestCase;

/**
* @covers: NodeTypeManager
*/
class NodeTypeManager extends \jackalope\JackalopeObjectsCase {
class NodeTypeManagerTest extends TestCase
{
protected $ntm;

public function setUp() {
Expand All @@ -28,6 +25,7 @@ public function testGetNodeType() {
$this->assertTrue($nt->isQueryable());
$this->assertSame('jcr:content', $nt->getPrimaryItemName());
}

/**
* @covers jackalope\NodeType\NodeTypeManager::getDeclaredSubtypes
* @covers jackalope\NodeType\NodeTypeManager::getSubtypes
Expand Down Expand Up @@ -82,4 +80,3 @@ public function testCreateNodeTypeTemplate() {
}

}

29 changes: 29 additions & 0 deletions tests/Jackalope/NodeType/NodeTypeTemplateTest.php
@@ -0,0 +1,29 @@
<?php

namespace Jackalope\NodeType;

use Jackalope\TestCase;

class NodeTypeTemplateTest extends TestCase
{
/**
* @covers jackalope\NodeType\NodeTypeTemplate
*/
public function testCreateNodeTypeTemplateEmpty() {
$ntm = $this->getNodeTypeManager();

$ntt = $ntm->createNodeTypeTemplate();

// is empty as defined by doc
$this->assertNull($ntt->getName());
$this->assertSame(array('nt:base'), $ntt->getDeclaredSupertypeNames());
$this->assertFalse($ntt->isAbstract());
$this->assertFalse($ntt->isMixin());
$this->assertFalse($ntt->hasOrderableChildNodes());
$this->assertFalse($ntt->isQueryable());
$this->assertNull($ntt->getPrimaryItemName());
$this->assertNull($ntt->getDeclaredPropertyDefinitions());
$this->assertNull($ntt->getDeclaredChildNodeDefinitions());
}

}

0 comments on commit be00b4d

Please sign in to comment.