Skip to content

Commit

Permalink
Merge pull request #66 from jackalope/adjust-prefetch-test
Browse files Browse the repository at this point in the history
adjust prefetch test to jackalope/jackalope#202
  • Loading branch information
dbu committed Jan 8, 2014
2 parents 0308e04 + 7d3d0f8 commit 7300797
Showing 1 changed file with 60 additions and 2 deletions.
62 changes: 60 additions & 2 deletions tests/Jackalope/Transport/Jackrabbit/PrefetchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,25 @@

namespace Jackalope\Transport\Jackrabbit;

use Jackalope\Functional\Transport\PrefetchTestCase;
use Jackalope\TestCase;

class PrefetchTest extends PrefetchTestCase
/**
* Extend this test case in your jackalope transport and provide the transport
* instance to be tested.
*
* The fixtures must contain the following tree:
*
* * node-a
* * * child-a
* * * child-b
* * node-b
* * * child-a
* * * child-b
*
* each child has a property "prop" with the corresponding a and b value in it:
* /node-a/child-a get "prop" => "aa".
*/
class PrefetchTest extends TestCase
{
/**
* @var \ImplementationLoader
Expand Down Expand Up @@ -42,4 +58,46 @@ protected function getTransport()

return $transport;
}

public function testGetNode()
{
$transport = $this->getTransport();
$transport->setFetchDepth(1);

$raw = $transport->getNode('/node-a');

$this->assertNode($raw, 'a');
}

public function testGetNodes()
{
$transport = $this->getTransport();
$transport->setFetchDepth(1);

$list = $transport->getNodes(array('/node-a', '/node-b'));

list($key, $raw) = each($list);
$this->assertEquals('/node-a', $key);
$this->assertNode($raw, 'a');

list($key, $raw) = each($list);
$this->assertEquals('/node-b', $key);
$this->assertNode($raw, 'b');
}

protected function assertNode($raw, $parent)
{
$this->assertInstanceOf('\stdClass', $raw);
$name = "child-a";
$this->assertTrue(isset($raw->$name), "The raw data is missing child $name");
$this->assertInstanceOf('\stdClass', $raw->$name);
$this->assertTrue(isset($raw->$name->prop), "The child $name is missing property 'prop'");
$this->assertEquals($parent . 'a', $raw->$name->prop);

$name = 'child-b';
$this->assertTrue(isset($raw->$name));
$this->assertInstanceOf('\stdClass', $raw->$name);
$this->assertTrue(isset($raw->$name->prop), "The child $name is missing property 'prop'");
$this->assertEquals($parent . 'b', $raw->$name->prop);
}
}

0 comments on commit 7300797

Please sign in to comment.