Exemplo n.º 1
0
 public function testSkip()
 {
     $app = new \momentphp\App([\momentphp\test\bundles\first\Bundle::class => ['alias' => 'first', 'skipResource' => ['routes']], \momentphp\test\bundles\second\Bundle::class => ['alias' => 'second', 'skipResource' => ['routes']], \momentphp\test\bundles\third\Bundle::class => ['alias' => 'third', 'skipClass' => 'classes'], \momentphp\test\app\Bundle::class => ['alias' => 'app', 'skipResource' => ['routes']]]);
     $app->booted = true;
     $app->registerRoutes();
     $cl = $app->bundleClass('classes\\Animal');
     $animal = new $cl();
     $this->assertEquals('zebra from second bundle', $animal->makeNoise());
     $res = $app->visit('/animal');
     $this->assertEquals('monkey from third bundle', (string) $res->getBody());
 }
Exemplo n.º 2
0
<?php

/**
 * Discover & require Composer autoloader (upwards in folders tree)
 */
$pathBase = __DIR__;
do {
    $autoload = implode(DIRECTORY_SEPARATOR, [$pathBase, 'vendor', 'autoload.php']);
    if (file_exists($autoload)) {
        require $autoload;
        break;
    }
    $pathBase = dirname($pathBase);
} while (dirname($pathBase) !== $pathBase);
/**
 * Bundles to load
 */
$bundles = [momentphp\test\bundles\first\Bundle::class => ['alias' => 'first'], momentphp\test\bundles\second\Bundle::class => ['alias' => 'second'], momentphp\test\bundles\third\Bundle::class => ['alias' => 'third'], momentphp\test\app\Bundle::class => ['alias' => 'app']];
/**
 * Construct app
 */
$app = new momentphp\App($bundles);
/**
 * Send response to the client
 */
$app->run();