Skip to content
Browse files

added a few tests for Augeas::insert()

  • Loading branch information...
1 parent b9666e3 commit 08fbdb299b7dafdbe4352702025c8644752eb8ca @ppadron committed Nov 18, 2009
Showing with 40 additions and 0 deletions.
  1. +40 −0 tests/AugeasInsertTest.php
View
40 tests/AugeasInsertTest.php
@@ -0,0 +1,40 @@
+<?php
+
+require_once "PHPUnit/Framework/TestCase.php";
+
+class AugeasInsertTest extends PHPUnit_Framework_TestCase
+{
+
+ public function testShouldBeAbleToInsertNodesBefore()
+ {
+ $beforeFirstComment = "comment inserted before the first comment";
+ $firstComment = "first comment";
+
+ $augeas = new Augeas("root");
+
+ // inserting before the first comment
+ $augeas->insert("/files/etc/hosts/comment[1]", "comment", Augeas::AUGEAS_INSERT_BEFORE);
+ $augeas->set("/files/etc/hosts/comment[1]", $beforeFirstComment);
+
+ $this->assertEquals($beforeFirstComment, $augeas->get("/files/etc/hosts/comment[1]"));
+ $this->assertEquals($firstComment, $augeas->get("/files/etc/hosts/comment[2]"));
+
+ }
+
+ public function testShouldBeAbleToInsertNodesAfter()
+ {
+ $afterFirstComment = "comment inserted after the first comment";
+ $firstComment = "first comment";
+
+ $augeas = new Augeas("root");
+
+ // inserting after the NEW first comment
+ $augeas->insert("/files/etc/hosts/comment[1]", "comment", Augeas::AUGEAS_INSERT_AFTER);
+ $augeas->set("/files/etc/hosts/comment[2]", $afterFirstComment);
+
+ $this->assertEquals($afterFirstComment, $augeas->get("/files/etc/hosts/comment[2]"));
+ }
+
+}
+
+?>

0 comments on commit 08fbdb2

Please sign in to comment.
Something went wrong with that request. Please try again.