コード例 #1
0
ファイル: SqonTest.php プロジェクト: sqon/sqon
 /**
  * Verify that a path can be manages in the Sqon.
  */
 public function testManagePathsInTheSqon()
 {
     $path = new Memory('test');
     self::assertFalse($this->sqon->hasPath('test.php'), 'The path should not exist.');
     $this->eventDispatcher->addListener(BeforeSetPathEvent::NAME, function () {
         $this->events[BeforeSetPathEvent::NAME] = true;
     });
     $this->eventDispatcher->addListener(AfterSetPathEvent::NAME, function () {
         $this->events[AfterSetPathEvent::NAME] = true;
     });
     self::assertSame($this->sqon, $this->sqon->setPath('test.php', $path), 'The path setter did not return a fluent interface.');
     self::assertTrue($this->events[BeforeSetPathEvent::NAME], sprintf('The "%s" event was not dispatched.', BeforeSetPathEvent::NAME));
     self::assertTrue($this->events[AfterSetPathEvent::NAME], sprintf('The "%s" event was not dispatched.', AfterSetPathEvent::NAME));
     self::assertTrue($this->sqon->hasPath('test.php'), 'The path should exist.');
     self::assertEquals($path, $this->sqon->getPath('test.php'), 'The same path information was not returned.');
     self::assertEquals(['test.php' => $path], iterator_to_array($this->sqon->getPaths()), 'The paths were not returned.');
     self::assertSame($this->sqon, $this->sqon->removePath('test.php'), 'The path remover did not return a fluent interface.');
     self::assertFalse($this->sqon->hasPath('test.php'), 'The path was not removed.');
 }