Skip to content

Commit

Permalink
Merge pull request #84 from Icinga/chore/tests
Browse files Browse the repository at this point in the history
Extend tests
  • Loading branch information
martialblog committed Aug 16, 2024
2 parents 00e1500 + d2c15e3 commit 8d5d8eb
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/php/library/Toplevelview/ViewConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ public function testViewConfigWithNoError()
$this->assertStringContainsString('linux-servers', $view->getText());
$this->assertSame('5fc0ad55066b871d376eee60c84300d32ac7cb1d', $view->getTextChecksum());
$this->assertSame('yml', $view->getFormat());

$this->assertSame('example', $view->getName());
$this->assertSame(['name' => 'My View'], $view->getMetaData());

$clone = clone $view;
$this->assertSame(null, $clone->getName());
$this->assertFalse($clone->hasBeenLoaded());
}

public function testViewConfigWithTree()
public function testViewConfigWithTreeWithError()
{
$this->expectException(NotFoundError::class);

Expand All @@ -72,4 +74,22 @@ public function testViewConfigWithTree()
$t = $view->getTree();
$t->getById('0-1-2');
}

public function testViewConfigWithSession()
{
$c = new ViewConfig('test/testdata');
$view = $c->loadByName('example');

$view->setMeta('foo', 'bar');
$this->assertSame('bar', $view->getMeta('foo'));
$this->assertSame(null, $view->getMeta('bar'));
$this->assertSame(['foo' => 'bar'], $view->getMetaData());

$c->storeToSession($view);
$view2 = $c->loadByName('example');

$this->assertSame($view->getTextChecksum(), $view2->getTextChecksum());
$this->assertFalse($view->hasBeenLoadedFromSession());
$this->assertTrue($view2->hasBeenLoadedFromSession());
}
}

0 comments on commit 8d5d8eb

Please sign in to comment.