|
|
|
|
@ -96,8 +96,7 @@ class EngineTest extends TestCase
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
$this->expectException(Exception::class);
|
|
|
|
|
$this->expectExceptionMessage('Cannot override an existing framework method.');
|
|
|
|
|
$engine->map('_start', function () {
|
|
|
|
|
});
|
|
|
|
|
$engine->map('_start', function () {});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testRegisterExistingMethod(): void
|
|
|
|
|
@ -666,8 +665,7 @@ class EngineTest extends TestCase
|
|
|
|
|
|
|
|
|
|
public function testMiddlewareCallableFunctionReturnFalse(): void
|
|
|
|
|
{
|
|
|
|
|
$engine = new class extends Engine {
|
|
|
|
|
};
|
|
|
|
|
$engine = new class extends Engine {};
|
|
|
|
|
$engine->route('/path1/@id', function ($id) {
|
|
|
|
|
echo 'OK' . $id;
|
|
|
|
|
})
|
|
|
|
|
@ -794,8 +792,7 @@ class EngineTest extends TestCase
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
$engine = new class extends Engine {
|
|
|
|
|
};
|
|
|
|
|
$engine = new class extends Engine {};
|
|
|
|
|
|
|
|
|
|
$engine->route('/path1/@id', function ($id) {
|
|
|
|
|
echo 'OK' . $id;
|
|
|
|
|
@ -894,7 +891,8 @@ class EngineTest extends TestCase
|
|
|
|
|
$this->expectOutputString('before456before123OKafter123456after123');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testContainerBadClass() {
|
|
|
|
|
public function testContainerBadClass()
|
|
|
|
|
{
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
|
|
|
|
|
$this->expectException(InvalidArgumentException::class);
|
|
|
|
|
@ -902,7 +900,8 @@ class EngineTest extends TestCase
|
|
|
|
|
$engine->registerContainerHandler('BadClass');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testContainerDice() {
|
|
|
|
|
public function testContainerDice()
|
|
|
|
|
{
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
$dice = new \Dice\Dice();
|
|
|
|
|
$dice = $dice->addRules([
|
|
|
|
|
@ -922,7 +921,8 @@ class EngineTest extends TestCase
|
|
|
|
|
$this->expectOutputString('yay! I injected a collection, and it has 1 items');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testContainerDicePdoWrapperTest() {
|
|
|
|
|
public function testContainerDicePdoWrapperTest()
|
|
|
|
|
{
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
$dice = new \Dice\Dice();
|
|
|
|
|
$dice = $dice->addRules([
|
|
|
|
|
@ -942,7 +942,8 @@ class EngineTest extends TestCase
|
|
|
|
|
$this->expectOutputString('Yay! I injected a PdoWrapper, and it returned the number 5 from the database!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testContainerDiceFlightEngine() {
|
|
|
|
|
public function testContainerDiceFlightEngine()
|
|
|
|
|
{
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
$engine->set('test_me_out', 'You got it boss!');
|
|
|
|
|
$dice = new \Dice\Dice();
|
|
|
|
|
@ -962,7 +963,8 @@ class EngineTest extends TestCase
|
|
|
|
|
$this->expectOutputString('You got it boss!');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testContainerDiceBadClass() {
|
|
|
|
|
public function testContainerDiceBadClass()
|
|
|
|
|
{
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
$dice = new \Dice\Dice();
|
|
|
|
|
$engine->registerContainerHandler(function ($class, $params) use ($dice) {
|
|
|
|
|
@ -978,7 +980,8 @@ class EngineTest extends TestCase
|
|
|
|
|
$engine->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testContainerDiceBadMethod() {
|
|
|
|
|
public function testContainerDiceBadMethod()
|
|
|
|
|
{
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
$dice = new \Dice\Dice();
|
|
|
|
|
$dice = $dice->addRules([
|
|
|
|
|
@ -1000,7 +1003,8 @@ class EngineTest extends TestCase
|
|
|
|
|
$engine->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testContainerPsr11(): void {
|
|
|
|
|
public function testContainerPsr11(): void
|
|
|
|
|
{
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
$container = new \League\Container\Container();
|
|
|
|
|
$container->add(Container::class)->addArgument(Collection::class)->addArgument(PdoWrapper::class);
|
|
|
|
|
@ -1015,7 +1019,8 @@ class EngineTest extends TestCase
|
|
|
|
|
$this->expectOutputString('yay! I injected a collection, and it has 1 items');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testContainerPsr11ClassNotFound() {
|
|
|
|
|
public function testContainerPsr11ClassNotFound()
|
|
|
|
|
{
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
$container = new \League\Container\Container();
|
|
|
|
|
$container->add(Container::class)->addArgument(Collection::class);
|
|
|
|
|
@ -1031,7 +1036,8 @@ class EngineTest extends TestCase
|
|
|
|
|
$engine->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testContainerPsr11MethodNotFound(): void {
|
|
|
|
|
public function testContainerPsr11MethodNotFound(): void
|
|
|
|
|
{
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
$container = new \League\Container\Container();
|
|
|
|
|
$container->add(Container::class)->addArgument(Collection::class)->addArgument(PdoWrapper::class);
|
|
|
|
|
@ -1048,7 +1054,8 @@ class EngineTest extends TestCase
|
|
|
|
|
$engine->start();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testRouteFoundButBadMethod(): void {
|
|
|
|
|
public function testRouteFoundButBadMethod(): void
|
|
|
|
|
{
|
|
|
|
|
$engine = new class extends Engine {
|
|
|
|
|
public function getLoader()
|
|
|
|
|
{
|
|
|
|
|
@ -1151,11 +1158,11 @@ class EngineTest extends TestCase
|
|
|
|
|
$this->assertContains('Content-Disposition: attachment; filename="something.txt"', $engine->response()->headersSent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testDownloadBadPath() {
|
|
|
|
|
public function testDownloadBadPath()
|
|
|
|
|
{
|
|
|
|
|
$engine = new Engine();
|
|
|
|
|
$this->expectException(Exception::class);
|
|
|
|
|
$this->expectExceptionMessage("/path/to/nowhere cannot be found.");
|
|
|
|
|
$engine->download('/path/to/nowhere');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|