Beispiel #1
0
 /**
  * Tests attributes diff tracking
  *
  * @return void
  */
 public function testDiffTracking()
 {
     $test = new NodeAttribute('test');
     $test->add(array('value4', 'value5'));
     $test->snapshot();
     $test->add(array('value1', 'value2', 'value3'));
     $test->remove(array('value4', 'value1', 'value5'));
     $test[] = 'value6';
     $test[] = 'value4';
     $test[] = 'value7';
     unset($test[5]);
     //value6
     $this->assertEquals(array('value2', 'value3', 'value7'), $test->getDiffAdditions(), 'Additions have been tracked');
     $this->assertEquals(array('value5'), $test->getDiffDeletions(), 'Deletions have been tracked');
     $this->assertEquals(array('value4'), $test->getDiffReplacements(), 'Replacements have been tracked');
     $test->snapshot();
     $this->assertEquals(array(), $test->getDiffAdditions(), 'Diff tracking has been reset');
     $this->assertEquals(array(), $test->getDiffDeletions(), 'Diff tracking has been reset');
     $this->assertEquals(array(), $test->getDiffReplacements(), 'Diff tracking has been reset');
 }