public function testRun() { $stub = \Mockery::mock('Load'); $stub->shouldReceive('loadExceptionHandler')->once(); $stub->shouldReceive('loadRegistry')->once(); $stub->shouldReceive('loadSession')->once(); $stub->shouldReceive('loadHttp')->once(); $stub->shouldReceive('loadView')->once(); $stub->shouldReceive('loadUser')->once(); $stub->shouldReceive('loadAdmin')->once(); $stub->shouldReceive('loadFrontController')->once(); $stub->shouldReceive('loadTheme')->once(); MockTest::inject($this->app, 'load', $stub); $this->app->run(); }
<?php session_start(); require '../vendor/autoload.php'; use app\App; $app = new App(); echo $app->run();
error_reporting(E_ALL); if (PHP_SAPI == 'cli-server') { // To help the built-in PHP dev server, check if the request was actually for // something which should probably be served as a static file $file = __DIR__ . $_SERVER['REQUEST_URI']; if (is_file($file)) { return false; } } require __DIR__ . '/../vendor/autoload.php'; session_start(); // Instantiate the app $settings = __DIR__ . '/../config/settings.php'; if (!is_file($settings)) { $defaults = (require __DIR__ . '/../config/settings.php.dist'); $defaults['settings']['jwt']['key'] = base64_encode(Random::secure_random_bytes(64)); file_put_contents($settings, '<?php' . "\n" . 'return ' . var_export($defaults, true) . ';'); } $app = new \Slim\App(require $settings); SlimStatic::boot($app); // Allow static proxies to be called from anywhere in App Statical::addNamespace('*', __NAMESPACE__ . '\\*'); // Set up dependencies require __DIR__ . '/../src/dependencies.php'; // Register middleware require __DIR__ . '/../src/middleware.php'; // Register routes require __DIR__ . '/../src/routes.php'; // Run app App::run();
<?php use App\App; require dirname(__FILE__) . "/vendor/autoload.php"; $app = new App(array('DB_DRIVER' => 'pdo_mysql', 'DB_HOST' => 'localhost', 'DB_USER' => 'root', 'DB_PASS' => 'root', 'DB_NAME' => 'slim_doctrine')); $app->run();
<?php /** * Индексный файл, точка входа в приложение веб-сайта */ require_once __DIR__ . '/../init.php'; \app\App::run();
/** * @test */ public function can_return_secret_of_the_universe() { $app = new App(); $this->assertEquals(42, $app->run()); }