/** * undo all setup made for testing. */ public static function tearDown() { User::truncate(); Emoji::truncate(); EmojiKeyword::truncate(); Schema::dropAllSchema(); }
<?php require 'vendor/autoload.php'; use Slim\App; use Slim\Container; use BB8\Emoji\Database\Connection; use BB8\Emoji\Database\Schema; use BB8\Emoji\Middleware; use BB8\Emoji\Models\User; //Create connection to database $connection = new Connection(); //Creaet database tables if table does not exist Schema::createSchema(); //Initialize a new dependency container $container = new Container(); //Add container to handle all exceptions/errors, fail safe and return json $container['errorHandler'] = function ($container) { return function ($request, $response, $exception) use($container) { //Format of exception to return $data = ['message' => $exception->getMessage()]; return $container->get('response')->withStatus(500)->withHeader('Content-Type', 'application/json')->write(json_encode($data)); }; }; //Register authentication container Dependency $container['auth'] = function ($container) { return new BB8\Emoji\Auth($container); }; //Initialize the slim app $app = new App($container); //Add middleware at app level $app->add('BB8\\Emoji\\Middleware:init');