Skip to content

Commit

Permalink
Added integration tests for laravel
Browse files Browse the repository at this point in the history
- [x] Checks uri and response code without needing server (smoke tests)
  • Loading branch information
Geshan Manandhar committed Oct 4, 2015
1 parent 198016c commit 04baf61
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
3 changes: 2 additions & 1 deletion phpunit.xml
Expand Up @@ -7,7 +7,7 @@
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
stopOnFailure="true"
syntaxCheck="false">
<testsuites>
<testsuite name="Application Test Suite">
Expand All @@ -24,5 +24,6 @@
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
</php>
</phpunit>
45 changes: 45 additions & 0 deletions tests/Integrated/ExampleTest.php
@@ -0,0 +1,45 @@
<?php

namespace Test\Integrated;

use Illuminate\Foundation\Testing\WithoutMiddleware;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Test\TestCase;

class ExampleTest extends TestCase
{
/**
* A basic functional test example.
*
* @return void
*/
public function testBasicExample()
{
$this->visit('/')
->see('Laravel 5');
}

public function providerAllUrisWithResponseCode()
{
return [
['/', 200],
['/place/cc', 200],
['/place/cod', 200],
['/non-existing', 404],
];
}

/**
* This is kind of a smoke test
*
* @dataProvider providerAllUrisWithResponseCode
**/
public function testApplicationUriResponses($uri, $responseCode)
{
print sprintf('checking URI : %s - to be %d - %s', $uri, $responseCode, PHP_EOL);
$response = $this->call('GET', $uri);

$this->assertEquals($responseCode, $response->status());
}
}
2 changes: 1 addition & 1 deletion tests/TestCase.php
Expand Up @@ -22,7 +22,7 @@ public function createApplication()
{
$app = require __DIR__.'/../bootstrap/app.php';

$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();

return $app;
}
Expand Down

0 comments on commit 04baf61

Please sign in to comment.