128 lines
3.4 KiB
PHP
128 lines
3.4 KiB
PHP
<?php
|
|
namespace nur\sery\wip\app {
|
|
use nulib\tests\TestCase;
|
|
use nur\sery\wip\app\impl\config;
|
|
use nur\sery\wip\app\impl\myapp2;
|
|
use nur\sery\wip\app\impl\MyApplication1;
|
|
use nur\sery\wip\app\impl\MyApplication2;
|
|
|
|
class app2Test extends TestCase {
|
|
function testWith() {
|
|
$projdir = config::get_projdir();
|
|
$cwd = getcwd();
|
|
|
|
myapp2::reset();
|
|
$app1 = myapp2::with(MyApplication1::class);
|
|
self::assertSame([
|
|
"projdir" => $projdir,
|
|
"vendor" => [
|
|
"bindir" => "$projdir/vendor/bin",
|
|
"autoload" => "$projdir/vendor/autoload.php",
|
|
],
|
|
"appcode" => "nur-sery",
|
|
"cwd" => $cwd,
|
|
"datadir" => "$projdir/devel",
|
|
"etcdir" => "$projdir/devel/etc",
|
|
"vardir" => "$projdir/devel/var",
|
|
"logdir" => "$projdir/devel/log",
|
|
"profile" => "devel",
|
|
"name" => "my-application1",
|
|
"title" => null,
|
|
], $app1->getParams());
|
|
|
|
$app2 = myapp2::with(MyApplication2::class, $app1);
|
|
self::assertSame([
|
|
"projdir" => $projdir,
|
|
"vendor" => [
|
|
"bindir" => "$projdir/vendor/bin",
|
|
"autoload" => "$projdir/vendor/autoload.php",
|
|
],
|
|
"appcode" => "nur-sery",
|
|
"cwd" => $cwd,
|
|
"datadir" => "$projdir/devel",
|
|
"etcdir" => "$projdir/devel/etc",
|
|
"vardir" => "$projdir/devel/var",
|
|
"logdir" => "$projdir/devel/log",
|
|
"profile" => "devel",
|
|
"name" => "my-application2",
|
|
"title" => null,
|
|
], $app2->getParams());
|
|
}
|
|
|
|
function testInit() {
|
|
$projdir = config::get_projdir();
|
|
$cwd = getcwd();
|
|
|
|
myapp2::reset();
|
|
myapp2::init(MyApplication1::class);
|
|
self::assertSame([
|
|
"projdir" => $projdir,
|
|
"vendor" => [
|
|
"bindir" => "$projdir/vendor/bin",
|
|
"autoload" => "$projdir/vendor/autoload.php",
|
|
],
|
|
"appcode" => "nur-sery",
|
|
"cwd" => $cwd,
|
|
"datadir" => "$projdir/devel",
|
|
"etcdir" => "$projdir/devel/etc",
|
|
"vardir" => "$projdir/devel/var",
|
|
"logdir" => "$projdir/devel/log",
|
|
"profile" => "devel",
|
|
"name" => "my-application1",
|
|
"title" => null,
|
|
], myapp2::get()->getParams());
|
|
|
|
myapp2::init(MyApplication2::class);
|
|
self::assertSame([
|
|
"projdir" => $projdir,
|
|
"vendor" => [
|
|
"bindir" => "$projdir/vendor/bin",
|
|
"autoload" => "$projdir/vendor/autoload.php",
|
|
],
|
|
"appcode" => "nur-sery",
|
|
"cwd" => $cwd,
|
|
"datadir" => "$projdir/devel",
|
|
"etcdir" => "$projdir/devel/etc",
|
|
"vardir" => "$projdir/devel/var",
|
|
"logdir" => "$projdir/devel/log",
|
|
"profile" => "devel",
|
|
"name" => "my-application2",
|
|
"title" => null,
|
|
], myapp2::get()->getParams());
|
|
}
|
|
}
|
|
}
|
|
|
|
namespace nur\sery\wip\app\impl {
|
|
use nur\cli\Application2;
|
|
use nur\sery\os\path;
|
|
use nur\sery\wip\app\app2;
|
|
|
|
class config {
|
|
const PROJDIR = __DIR__.'/../../..';
|
|
|
|
static function get_projdir(): string {
|
|
return path::abspath(self::PROJDIR);
|
|
}
|
|
}
|
|
|
|
class myapp2 extends app2 {
|
|
static function reset(): void {
|
|
self::$app = null;
|
|
}
|
|
}
|
|
|
|
class MyApplication1 extends Application2 {
|
|
const PROJDIR = config::PROJDIR;
|
|
|
|
function main() {
|
|
}
|
|
}
|
|
class MyApplication2 extends Application2 {
|
|
const PROJDIR = null;
|
|
|
|
function main() {
|
|
}
|
|
}
|
|
}
|