/** * Renders the report * * @return Illuminate\Http\Response|null */ protected function renderReport() { if (Features::isEnabled('ActionsReport')) { $report = App::make('report'); $statusCode = $report->containsError() ? 503 : 200; return Response::json($report)->setStatusCode($statusCode); } }
public function testExecuteWhenSomeFeatureIsDisabled() { Features::disable('ActionsReport'); $this->servicesMock->shouldReceive('get')->once()->andReturn([]); $this->tester->execute(['command' => $this->command->getName()]); $this->assertRegexp('/Gate *\\| *✓ *\\|/', $this->tester->getDisplay()); $this->assertRegexp('/ActionsReport *\\| *\\|/', $this->tester->getDisplay()); }
/** * Gets features as table rows * * @return array */ protected function getFeaturesTableRows() { $rows = []; foreach (Features::getAll() as $key => $value) { if ($value) { $checkMark = '✓'; } else { $checkMark = ''; } $rows[] = [$key, $checkMark]; } return $rows; }
public function testEnable() { // Find it (en vain …) $this->assertNotContains('Quux', Features::getEnabled()); $this->assertFalse(Features::isEnabled('Quux')); // Enable it Features::enable('Quux'); $this->assertTrue(Features::isEnabled('Quux')); $this->assertContains('Quux', Features::getEnabled()); // Disable it Features::disable('Quux'); $this->assertFalse(Features::isEnabled('Quux')); // Count it $this->assertContains('Quux', Features::getAll()); $this->assertContains('Quux', Features::getAvailable()); $this->assertNotContains('Quux', Features::getEnabled()); }
<?php use Nasqueron\Notifications\Features; /* |-------------------------------------------------------------------------- | Application Routes |-------------------------------------------------------------------------- | | Here is where you can register all of the routes for an application. | It's a breeze. Simply tell Laravel the URIs it should respond to | and give it the controller to call when that URI is requested. | */ Route::get('/', function () { return view('welcome'); }); // Allows to external tool to ping your instalation and know if the site is up. Route::get('/status', function () { return "ALIVE"; }); // Gate controllers if (Features::isEnabled('Gate')) { foreach (Config::get('gate.controllers') as $controller) { $controllerRoute = '/gate/' . $controller . '/'; Route::get($controllerRoute . '{door?}', "Gate\\{$controller}GateController@onGet"); Route::post($controllerRoute . '{door}', "Gate\\{$controller}GateController@onPost"); } }
/** * Same than testPost, but without actions report. */ public function testPostWithoutActionsReport() { Features::disable("ActionsReport"); $this->sendValidTestPayload(); $this->assertEmpty($this->response->getContent()); $this->assertResponseOk(); // Let's throw an Exception at broker level. // Without ActionsReport, the client must always receive a 200 OK. $this->app->instance('broker', function ($app) { // A non omnipotent instance, so it doesn't mock connect(). return new BlackholeBroker(); }); $this->sendValidTestPayload(); $this->assertEmpty($this->response->getContent()); $this->assertResponseOk(); }