diff --git a/app/langs/LangEN.php b/app/langs/LangEN.php index 5be3882b..468ce712 100644 --- a/app/langs/LangEN.php +++ b/app/langs/LangEN.php @@ -12,5 +12,11 @@ class LangEN extends Lang { public function __construct() { parent::__construct('ltr', 'EN', true); //TODO: Add the language "EN" labels. + $this->createAndSet('hello', [ + 'one' => [ + 'cool' => 'Cool' + ], + 'two' => '2' + ]); } } diff --git a/tests/webfiori/framework/test/PageTest.php b/tests/webfiori/framework/test/PageTest.php index 4d5c9d1f..d313a828 100644 --- a/tests/webfiori/framework/test/PageTest.php +++ b/tests/webfiori/framework/test/PageTest.php @@ -4,10 +4,13 @@ use Exception; use PHPUnit\Framework\TestCase; use themes\fioriTheme\NewFTestTheme; +use webfiori\framework\Access; use webfiori\framework\App; use webfiori\framework\Lang; +use webfiori\framework\session\SessionsManager; use webfiori\framework\Theme; use webfiori\framework\ui\WebPage; +use webfiori\framework\User; use webfiori\ui\HTMLNode; /** * Description of PageTest @@ -209,6 +212,98 @@ public function testCreateHtmlNode02() { $el = $page->getChildByID('my-div'); $this->assertEquals('My Name Is Super Hero', $el->getChild(0)->getText()); } + /** + * @test + */ + public function testCreateHtmlNode03() { + $page = new WebPage(); + $node = $page->createHTMLNode(); + $node->setID('new-node'); + $this->assertEquals('div', $node->getNodeName()); + $this->assertEquals(0,$page->getChildByID('main-content-area')->childrenCount()); + $el = $page->getChildByID('new-node'); + $this->assertNull($el); + } + /** + * @test + */ + public function testHasPrivilege00() { + $page = new WebPage(); + $this->assertFalse($page->hasPrivilege('A_TEST')); + } + /** + * @test + */ + public function testHasPrivilege01() { + $page = new WebPage(); + SessionsManager::start('new'); + $this->assertFalse($page->hasPrivilege('A_TEST')); + } + /** + * @test + */ + public function testHasPrivilege02() { + $page = new WebPage(); + SessionsManager::start('new'); + $user = new User(); + $user->addPrivilege('A_TEST'); + SessionsManager::getActiveSession()->setUser($user); + $this->assertFalse($page->hasPrivilege('A_TEST')); + Access::newGroup('Test'); + Access::newPrivilege('Test', 'A_TEST'); + $user->addPrivilege('A_TEST'); + $this->assertTrue($page->hasPrivilege('A_TEST')); + } + /** + * @test + */ + public function testGetSession00() { + SessionsManager::destroy(); + $page = new WebPage(); + $this->assertNull($page->getActiveSession()); + } + /** + * @test + */ + public function testGetSession01() { + SessionsManager::start('test-session-1'); + $page = new WebPage(); + $session = $page->getActiveSession(); + $this->assertNotNull($session); + $this->assertEquals('test-session-1', $session->getName()); + SessionsManager::destroy(); + $this->assertNull($page->getActiveSession()); + } + /** + * @test + */ + public function testGetSession02() { + SessionsManager::start('test-session-1'); + SessionsManager::start('test-session-2'); + $page = new WebPage(); + $session = $page->getActiveSession(); + $this->assertNotNull($session); + $this->assertEquals('test-session-2', $session->getName()); + SessionsManager::destroy(); + $this->assertNull($page->getActiveSession()); + } + /** + * @test + */ + public function testGetLabel00() { + $page = new WebPage(); + $this->assertEquals('a/b/c', $page->get('a/b/c')); + } + /** + * @test + */ + public function testGetLabel01() { + $page = new WebPage(); + $this->assertEquals('2', $page->get('hello/two')); + $this->assertEquals([ + 'cool' => 'Cool' + ], $page->get('hello/one')); + } /** * @test */ @@ -225,6 +320,7 @@ public function testDefaults00() { $this->assertEquals('ltr',$page->getWritingDir()); $this->assertNotNull($page->getTranslation()); $this->assertEquals('https://127.0.0.1/',$page->getCanonical()); + $this->assertEquals('http://127.0.0.1',$page->getBase()); } /** * @test