parent
79242846b3
commit
f3d5343de6
@ -0,0 +1,29 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
declare(strict_types=1); |
||||||
|
|
||||||
|
namespace UnitTestFiles\Test; |
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase; |
||||||
|
|
||||||
|
class SecondTest extends TestCase { |
||||||
|
private $setup; |
||||||
|
|
||||||
|
protected function setUp(): void { |
||||||
|
require_once "tts_setup.php"; |
||||||
|
$this->setup = \testing\tts_setup::get_instance(); |
||||||
|
} |
||||||
|
|
||||||
|
public function testIdAssetsToId() { |
||||||
|
$this->setup::test_route("mockup/example/10"); |
||||||
|
$condition = $this->setup::do_routes(); |
||||||
|
$this->assertEquals($condition, 10); |
||||||
|
} |
||||||
|
|
||||||
|
public function testAnotherRouteAssetsToTrue() { |
||||||
|
$this->setup::test_route("/mockup/app/first/not_same.html"); |
||||||
|
$condition = $this->setup::do_routes(); |
||||||
|
$this->assertFalse($condition); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -1,13 +0,0 @@ |
|||||||
<?php |
|
||||||
function setup(string $route) { |
|
||||||
$p_dir = dirname(__DIR__, 2) . "/src/"; |
|
||||||
require_once $p_dir . 'before_main.php'; |
|
||||||
|
|
||||||
\tts\site_helper::set_all_projects(['mockup', 'ex', 'live']); |
|
||||||
\tts\site_helper::set_default_project("mockup"); |
|
||||||
|
|
||||||
$PHPUNIT_Testing = true; |
|
||||||
\tts\site_helper::init(PROJECT_BASE_DIR, $route, "get", $PHPUNIT_Testing); |
|
||||||
|
|
||||||
require_once PROJECT_BASE_DIR . 'main.php'; |
|
||||||
} |
|
||||||
@ -0,0 +1,55 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace testing; |
||||||
|
|
||||||
|
class tts_setup { |
||||||
|
|
||||||
|
// Hold the class instance. |
||||||
|
private static $instance = null; |
||||||
|
|
||||||
|
// The constructor is private |
||||||
|
// to prevent initiation with outer code. |
||||||
|
private function __construct() { |
||||||
|
$this->setup(); |
||||||
|
} |
||||||
|
|
||||||
|
// The object is created from within the class itself |
||||||
|
// only if the class has no instance. |
||||||
|
public static function get_instance() { |
||||||
|
if (self::$instance == null) { |
||||||
|
self::$instance = new tts_setup(); |
||||||
|
} |
||||||
|
|
||||||
|
return self::$instance; |
||||||
|
} |
||||||
|
|
||||||
|
private static function setup(): void { |
||||||
|
$p_dir = dirname(__DIR__, 2) . "/src/"; |
||||||
|
require_once $p_dir . 'before_main.php'; |
||||||
|
|
||||||
|
\tts\site_helper::set_all_projects(['mockup', 'ex', 'live']); |
||||||
|
\tts\site_helper::set_default_project("mockup"); |
||||||
|
|
||||||
|
\tts\site_helper::init(PROJECT_BASE_DIR, "", "get", true); |
||||||
|
|
||||||
|
require_once PROJECT_BASE_DIR . 'main.php'; |
||||||
|
} |
||||||
|
|
||||||
|
public static function test_route(string $route): void { |
||||||
|
$PHPUNIT_Testing = true; |
||||||
|
\tts\site_helper::init(PROJECT_BASE_DIR, $route, "get", $PHPUNIT_Testing); |
||||||
|
} |
||||||
|
|
||||||
|
public static function do_routes() { |
||||||
|
$returned_route = \tts\router::execute(); |
||||||
|
|
||||||
|
if ($returned_route["found"] === true) { |
||||||
|
$condition = $returned_route["returned"]; |
||||||
|
} else { |
||||||
|
$app = new \tts\app(); |
||||||
|
$condition = $app->load_controller(); |
||||||
|
} |
||||||
|
return $condition; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
@ -1,29 +0,0 @@ |
|||||||
#!/usr/bin/env php |
|
||||||
<?php |
|
||||||
|
|
||||||
declare(strict_types=1); |
|
||||||
|
|
||||||
require 'src/before_main.php'; |
|
||||||
\tts\site_helper::set_all_projects(['mockup','ex','live']); |
|
||||||
\tts\site_helper::set_default_project("mockup"); |
|
||||||
|
|
||||||
$PHPUNIT_Testing = true; |
|
||||||
|
|
||||||
$cli_args = \tts\site_helper::get_cli_args(); |
|
||||||
\tts\site_helper::init(PROJECT_BASE_DIR, $cli_args, "get", $PHPUNIT_Testing); |
|
||||||
|
|
||||||
require 'src/main.php'; |
|
||||||
|
|
||||||
if (\tts\console_app::is_cli() === false) { |
|
||||||
echo 'Unable to Start'; |
|
||||||
exit; |
|
||||||
} |
|
||||||
|
|
||||||
echo 'Starting...' . PHP_EOL; |
|
||||||
|
|
||||||
$found_route = \tts\router::execute(); |
|
||||||
|
|
||||||
if (!$found_route) { |
|
||||||
$app = new \tts\app(); |
|
||||||
$app->load_controller(); |
|
||||||
} |
|
||||||
Loading…
Reference in new issue