Browse Source

Update codebase and tests

pull/11/head
Nafies Luthfi 5 years ago
parent
commit
49b7e91054
  1. 10
      app/Exceptions/Handler.php
  2. 15
      tests/Feature/Api/OutletListingTest.php
  3. 8
      tests/Unit/Models/OutletTest.php

10
app/Exceptions/Handler.php

@ -2,8 +2,8 @@
namespace App\Exceptions; namespace App\Exceptions;
use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Throwable;
class Handler extends ExceptionHandler class Handler extends ExceptionHandler
{ {
@ -29,10 +29,10 @@ class Handler extends ExceptionHandler
/** /**
* Report or log an exception. * Report or log an exception.
* *
* @param \Exception $exception
* @param \Throwable $exception
* @return void * @return void
*/ */
public function report(Exception $exception)
public function report(Throwable $exception)
{ {
parent::report($exception); parent::report($exception);
} }
@ -41,10 +41,10 @@ class Handler extends ExceptionHandler
* Render an exception into an HTTP response. * Render an exception into an HTTP response.
* *
* @param \Illuminate\Http\Request $request * @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @param \Throwable $exception
* @return \Illuminate\Http\Response * @return \Illuminate\Http\Response
*/ */
public function render($request, Exception $exception)
public function render($request, Throwable $exception)
{ {
return parent::render($request, $exception); return parent::render($request, $exception);
} }

15
tests/Feature/Api/OutletListingTest.php

@ -3,8 +3,8 @@
namespace Tests\Feature\Api; namespace Tests\Feature\Api;
use App\Outlet; use App\Outlet;
use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase; use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\BrowserKitTest as TestCase;
class OutletListingTest extends TestCase class OutletListingTest extends TestCase
{ {
@ -17,7 +17,7 @@ class OutletListingTest extends TestCase
$this->getJson(route('api.outlets.index')); $this->getJson(route('api.outlets.index'));
$this->seeJsonSubset([
$this->seeJsonContains([
'type' => 'FeatureCollection', 'type' => 'FeatureCollection',
'features' => [ 'features' => [
[ [
@ -26,12 +26,19 @@ class OutletListingTest extends TestCase
'name' => $outlet->name, 'name' => $outlet->name,
'address' => $outlet->address, 'address' => $outlet->address,
'coordinate' => $outlet->coordinate, 'coordinate' => $outlet->coordinate,
'latitude' => (string) $outlet->latitude,
'longitude' => (string) $outlet->longitude,
'map_popup_content' => $outlet->map_popup_content,
'creator_id' => (string) $outlet->creator_id,
'id' => $outlet->id,
'created_at' => $outlet->created_at,
'updated_at' => $outlet->updated_at,
], ],
'geometry' => [ 'geometry' => [
'type' => 'Point', 'type' => 'Point',
'coordinates' => [ 'coordinates' => [
$outlet->longitude,
$outlet->latitude,
(string) $outlet->longitude,
(string) $outlet->latitude,
], ],
], ],
], ],

8
tests/Unit/Models/OutletTest.php

@ -2,14 +2,14 @@
namespace Tests\Unit\Models; namespace Tests\Unit\Models;
use App\User;
use App\Outlet; use App\Outlet;
use App\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\BrowserKitTest as TestCase; use Tests\BrowserKitTest as TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class OutletTest extends TestCase class OutletTest extends TestCase
{ {
use DatabaseMigrations;
use RefreshDatabase;
/** @test */ /** @test */
public function an_outlet_has_name_link_attribute() public function an_outlet_has_name_link_attribute()
@ -52,7 +52,7 @@ class OutletTest extends TestCase
/** @test */ /** @test */
public function an_outlet_has_map_popup_content_attribute() public function an_outlet_has_map_popup_content_attribute()
{ {
$outlet = factory(Outlet::class)->make(['lat' => '-3.333333', 'long' => '114.583333']);
$outlet = factory(Outlet::class)->create(['latitude' => '-3.333333', 'longitude' => '114.583333']);
$mapPopupContent = ''; $mapPopupContent = '';
$mapPopupContent .= '<div class="my-2"><strong>'.__('outlet.name').':</strong><br>'.$outlet->name_link.'</div>'; $mapPopupContent .= '<div class="my-2"><strong>'.__('outlet.name').':</strong><br>'.$outlet->name_link.'</div>';

Loading…
Cancel
Save