Skip to content

Commit 47c9eaf

Browse files
committed
Merge pull request #173 from phpcr/functional-nodehelper-test
adding a functional test for the node helper
2 parents 97eb1e7 + b0b3fc1 commit 47c9eaf

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

tests/PhpcrUtils/NodeHelperTest.php

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PHPCR API Tests package
5+
*
6+
* Copyright (c) 2015 Liip and others
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace PHPCR\Tests\PhpcrUtils;
13+
14+
use PHPCR\PropertyType;
15+
use PHPCR\Util\NodeHelper;
16+
use PHPCR\Test\BaseCase;
17+
18+
/**
19+
* Functional test for the node helper.
20+
*/
21+
class NodeHelperTest extends BaseCase
22+
{
23+
protected function setUp()
24+
{
25+
if (!class_exists('PHPCR\Util\NodeHelper')) {
26+
$this->markTestSkipped('This testbed does not have phpcr-utils available');
27+
}
28+
parent::setUp();
29+
}
30+
31+
public function testCreatePartialPath()
32+
{
33+
$node = NodeHelper::createPath($this->session, '/tests_general_base/index.txt/jcr:content/test/node');
34+
$this->assertInstanceOf('PHPCR\NodeInterface', $node);
35+
$this->session->save();
36+
}
37+
38+
public function testCreateNewPath()
39+
{
40+
$node = NodeHelper::createPath($this->session, '/tests_nodehelper/test/node');
41+
$this->assertInstanceOf('PHPCR\NodeInterface', $node);
42+
$this->session->save();
43+
}
44+
45+
public function testCreateExistingPath()
46+
{
47+
$node = NodeHelper::createPath($this->session, '/tests_general_base/index.txt');
48+
$this->assertInstanceOf('PHPCR\NodeInterface', $node);
49+
$this->assertFalse($this->session->hasPendingChanges());
50+
}
51+
}

0 commit comments

Comments
 (0)