Lia.php
<?php
namespace Lia\Test\NewTest;
class Lia extends \Tlf\Tester {
public function testGlobalConfig(){
$_SERVER['REQUEST_URI'] = '/';
try {
$this->test("Proper exception for configurable addon not available\n");
$lia = new \Lia();
$configs = [];
$lia->configure(
[
'lia:server' =>[
'asdf'=>[
'nohtin'
],
],
]
);
$server = \Lia\Package\Server::main($lia);
} catch (\Lia\Exception $e){
$addon_list = (\Lia\Package\Server::main(new \Lia()))->addons;
$exception_message =
sprintf(
\Lia\Exception::CONFIGURABLE_ADDON_NOT_FOUND
,'asdf', 'lia:server', implode(', ', array_keys($addon_list))
);
$this->catch('Lia\\Exception')
->containing($exception_message);
$this->throw($e);
}
$lia = new \Lia();
//@export_start(Lia.configure)
$lia->configure(
[
'lia:server' =>[
'cache'=>[
'enabled' => false,
],
],
]
);
//@export_end(Lia.configure)
$server = \Lia\Package\Server::main($lia);
$this->test("Cache successfully disabled");
$this->compare(false, \Lia\Addon\Cache::from($lia)->enabled);
try {
$this->test("Proper exception for unsettable config\n");
$lia = new \Lia();
$lia->configure(
[
'lia:server' =>[
'resourcesorter'=>[
'prepend' => [],
],
],
]
);
$server = \Lia\Package\Server::main($lia);
} catch (\Exception $e){
$this->catch('\Lia\Exception')
->containing(
sprintf(\Lia\Exception::CANNOT_SET_CONFIG,
'prepend',
'resourcesorter',
'Lia\\Addon\\ResourceSorter',
''
)
)->containing(
"Cannot access protected property"
);
$this->throw($e);
}
}
public function testAddonFromLia(){
$_SERVER['REQUEST_URI'] = '/';
$lia = new \Lia();
// Add the built-in App, which provides all the web-server features.
$server_package = new \Lia\Package\Server($lia, $fqn='lia:server'); // dir & base_url not required
$res_addon = \Lia\Addon\Resources::from($lia);
$this->compare(\Lia\Addon\Resources::class, get_class($res_addon));
}
}