Skip to content
This repository has been archived by the owner on Aug 20, 2022. It is now read-only.

Commit

Permalink
Last update before archiving
Browse files Browse the repository at this point in the history
  • Loading branch information
josantonius committed Aug 19, 2022
1 parent 20e57ec commit e65c488
Show file tree
Hide file tree
Showing 32 changed files with 1,951 additions and 0 deletions.
147 changes: 147 additions & 0 deletions tests/App/ConstantsTest.php
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()
);
}
}
125 changes: 125 additions & 0 deletions tests/App/CurrentIdTest.php
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()
);
}
}
Loading

0 comments on commit e65c488

Please sign in to comment.