This repository has been archived by the owner on Aug 20, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
20e57ec
commit e65c488
Showing
32 changed files
with
1,951 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<?php | ||
/** | ||
* Tests for Eliasis PHP Framework. | ||
* | ||
* @author Josantonius <hello@josantonius.com> | ||
* @copyright 2017 - 2018 (c) Josantonius - Eliasis Framework | ||
* @license https://opensource.org/licenses/MIT - The MIT License (MIT) | ||
* @link https://github.com/eliasis-framework/eliasis | ||
* @since 1.1.2 | ||
*/ | ||
namespace Eliasis\Framework\App; | ||
|
||
use Eliasis\Framework\App; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Tests class for predefined constants. | ||
*/ | ||
final class ConstantsTest extends TestCase | ||
{ | ||
/** | ||
* App instance. | ||
* | ||
* @var object | ||
*/ | ||
protected $app; | ||
|
||
/** | ||
* Root path. | ||
* | ||
* @var string | ||
*/ | ||
protected $root; | ||
|
||
/** | ||
* Root url. | ||
* | ||
* @var string | ||
*/ | ||
protected $root_url; | ||
|
||
/** | ||
* Core path. | ||
* | ||
* @var object | ||
*/ | ||
protected $core; | ||
|
||
/** | ||
* Set up. | ||
*/ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->app = new App; | ||
|
||
$this->root = $_SERVER['DOCUMENT_ROOT']; | ||
|
||
$this->root_url = 'https://' . $_SERVER['SERVER_NAME'] . '/'; | ||
|
||
$this->core = dirname(dirname(dirname(dirname(__DIR__)))) . '/'; | ||
|
||
$app = $this->app; | ||
|
||
$app::run($this->root); | ||
} | ||
|
||
/** | ||
* Check if it is an instance of App. | ||
*/ | ||
public function testIsInstanceOf() | ||
{ | ||
$this->assertInstanceOf('Eliasis\Framework\App', $this->app); | ||
} | ||
|
||
/** | ||
* Validate that application base paths have been generated. | ||
*/ | ||
public function testCheckApplicationBasepathConstants() | ||
{ | ||
$app = $this->app; | ||
|
||
$this->assertSame( | ||
$this->root, | ||
$app::ROOT() | ||
); | ||
|
||
$this->assertSame( | ||
$this->core, | ||
$app::CORE() | ||
); | ||
|
||
$this->assertSame( | ||
$this->root . 'templates/', | ||
$app::TEMPLATES() | ||
); | ||
|
||
$this->assertSame( | ||
$this->root . 'modules/', | ||
$app::MODULES() | ||
); | ||
|
||
$this->assertSame( | ||
$this->root . 'plugins/', | ||
$app::PLUGINS() | ||
); | ||
|
||
$this->assertSame( | ||
$this->root . 'components/', | ||
$app::COMPONENTS() | ||
); | ||
} | ||
|
||
/** | ||
* Validate that application base urls have been generated. | ||
*/ | ||
public function testCheckApplicationBaseUrlsConstants() | ||
{ | ||
$app = $this->app; | ||
|
||
$this->assertSame( | ||
$this->root_url . 'public/', | ||
$app::PUBLIC_URL() | ||
); | ||
|
||
$this->assertSame( | ||
$this->root_url . 'templates/', | ||
$app::TEMPLATES_URL() | ||
); | ||
|
||
$this->assertSame( | ||
$this->root_url . 'modules/', | ||
$app::MODULES_URL() | ||
); | ||
|
||
$this->assertSame( | ||
$this->root_url . 'plugins/', | ||
$app::PLUGINS_URL() | ||
); | ||
|
||
$this->assertSame( | ||
$this->root_url . 'components/', | ||
$app::COMPONENTS_URL() | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
<?php | ||
/** | ||
* Tests for Eliasis PHP Framework. | ||
* | ||
* @author Josantonius <hello@josantonius.com> | ||
* @copyright 2017 - 2018 (c) Josantonius - Eliasis Framework | ||
* @license https://opensource.org/licenses/MIT - The MIT License (MIT) | ||
* @link https://github.com/eliasis-framework/eliasis | ||
* @since 1.1.2 | ||
*/ | ||
namespace Eliasis\Framework\App; | ||
|
||
use Eliasis\Framework\App; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Tests class for App::getCurrentID() and App::setCurrentID() method. | ||
*/ | ||
final class CurrentIdTest extends TestCase | ||
{ | ||
/** | ||
* App instance. | ||
* | ||
* @var object | ||
*/ | ||
protected $app; | ||
|
||
/** | ||
* Root path. | ||
* | ||
* @var string | ||
*/ | ||
protected $root; | ||
|
||
/** | ||
* Set up. | ||
*/ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->app = new App; | ||
|
||
$this->root = $_SERVER['DOCUMENT_ROOT']; | ||
} | ||
|
||
/** | ||
* Check if it is an instance of App. | ||
*/ | ||
public function testIsInstanceOf() | ||
{ | ||
$this->assertInstanceOf('Eliasis\Framework\App', $this->app); | ||
} | ||
|
||
/** | ||
* Run multiple applications. | ||
*/ | ||
public function testRunMultipleApplications() | ||
{ | ||
$app = $this->app; | ||
|
||
$this->assertTrue( | ||
$app::run($this->root, 'app', 'MyApplicationOne') | ||
); | ||
|
||
$this->assertTrue( | ||
$app::run($this->root, 'app', 'MyApplicationTwo') | ||
); | ||
|
||
$this->assertTrue( | ||
$app::run($this->root, 'app', 'MyApplicationThree') | ||
); | ||
} | ||
|
||
/** | ||
* Define the current application ID. | ||
* | ||
* @depends testRunMultipleApplications | ||
*/ | ||
public function testSetCurrentID() | ||
{ | ||
$app = $this->app; | ||
|
||
$this->assertTrue( | ||
$app::setCurrentID('MyApplicationOne') | ||
); | ||
|
||
$this->assertTrue( | ||
$app::setCurrentID('MyApplicationThree') | ||
); | ||
|
||
$this->assertTrue( | ||
$app::setCurrentID('MyApplicationTwo') | ||
); | ||
} | ||
|
||
/** | ||
* Define the current application ID when the application doesn't exist. | ||
* | ||
* @depends testRunMultipleApplications | ||
*/ | ||
public function testSetNonexistentCurrentID() | ||
{ | ||
$app = $this->app; | ||
|
||
$this->assertFalse( | ||
$app::setCurrentID('Unknown') | ||
); | ||
} | ||
|
||
/** | ||
* Get the current application ID. | ||
* | ||
* @depends testRunMultipleApplications | ||
*/ | ||
public function testGetCurrentID() | ||
{ | ||
$app = $this->app; | ||
|
||
$this->assertSame( | ||
'MyApplicationTwo', | ||
$app::getCurrentID() | ||
); | ||
} | ||
} |
Oops, something went wrong.