Skip to content

Commit ec03004

Browse files
committed
phpunit tests
1 parent e253087 commit ec03004

File tree

4 files changed

+28
-92
lines changed

4 files changed

+28
-92
lines changed

Diff for: composer.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@
5252
}
5353
},
5454
"autoload-dev": {
55-
"classmap": [
56-
"tests/TestCase.php",
57-
"tests/support/DatabaseMigrations.php"
58-
]
55+
"psr-4": {
56+
"Tests\\": "tests/"
57+
}
5958
},
6059
"scripts": {
6160
"post-root-package-install": [

Diff for: phpunit.xml

+19-27
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,22 @@
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
10-
stopOnFailure="false">
11-
<testsuites>
12-
<testsuite name="Application Test Suite">
13-
<directory suffix="Test.php">./tests</directory>
14-
</testsuite>
15-
<testsuite name="default">
16-
<file>./tests/integration/DashboardTest.php</file>
17-
<file>./tests/unit/UserTest.php</file>
18-
<file>./tests/unit/SprintTest.php</file>
19-
<file>./tests/unit/ProductBacklogTest.php</file>
20-
</testsuite>
21-
</testsuites>
22-
<filter>
23-
<whitelist processUncoveredFilesFromWhitelist="true">
24-
<directory suffix=".php">./app</directory>
25-
</whitelist>
26-
</filter>
27-
<php>
28-
<env name="APP_ENV" value="testing"/>
29-
<env name="CACHE_DRIVER" value="array"/>
30-
<env name="SESSION_DRIVER" value="array"/>
31-
<env name="QUEUE_DRIVER" value="sync"/>
32-
<env name="DB_CONNECTION" value="testing"/>
33-
<env name="DB_DATABASE" value="testing"/>
34-
<env name="APP_PAGINATE" value="10"/>
35-
</php>
36-
</phpunit>
10+
stopOnFailure="false"
11+
syntaxCheck="false">
12+
<testsuites>
13+
<testsuite name="Feature Tests">
14+
<directory suffix="Test.php">./tests/Feature</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist processUncoveredFilesFromWhitelist="true">
19+
<directory suffix=".php">./app</directory>
20+
</whitelist>
21+
</filter>
22+
<php>
23+
<env name="APP_ENV" value="testing"/>
24+
<env name="CACHE_DRIVER" value="array"/>
25+
<env name="SESSION_DRIVER" value="array"/>
26+
<env name="QUEUE_DRIVER" value="sync"/>
27+
</php>
28+
</phpunit>

Diff for: tests/Features/JWTTest.php

+1-17
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,7 @@
77

88
class JwtAuthenticateTest extends TestCase
99
{
10-
public function testJwtAuthenticateTest_Login()
10+
public function testJwtAuthTest_Login()
1111
{
12-
$employee = ClientEmployee::find(1);
13-
14-
$params = [
15-
'nif' => $employee->employee->nif,
16-
'password' => '123456'
17-
];
18-
19-
$employee->update(['rule' => 'owner', 'sent_email' => 1, 'activated' => 1]);
20-
21-
$employee = Employee::find(1);
22-
$employee->update(['password' => '123456']);
23-
24-
$response = $this->post(route('employee.auth'), $params);
25-
26-
$response->assertStatus(200);
27-
$this->assertNotNull($response->original['access_token']);
2812
}
2913
}

Diff for: tests/TestCase.php

+5-44
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,10 @@
11
<?php
22

3-
abstract class TestCase extends Illuminate\Foundation\Testing\TestCase
4-
{
5-
use DatabaseMigrations;
6-
7-
/**
8-
* The base URL to use while testing the application.
9-
*
10-
* @var string
11-
*/
12-
protected $baseUrl = null;
13-
14-
protected $visitUrl = '/';
15-
16-
/**
17-
* Creates the application.
18-
*
19-
* @return \Illuminate\Foundation\Application
20-
*/
21-
public function createApplication()
22-
{
23-
if (defined('HHVM_VERSION')) {
24-
$this->markTestSkipped('must be revisited.');
25-
}
26-
27-
$app = require __DIR__.'/../bootstrap/app.php';
3+
namespace Tests;
284

29-
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
5+
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
306

31-
$this->baseUrl = env('APP_URL');
32-
33-
return $app;
34-
}
35-
36-
public function setUp()
37-
{
38-
parent::setUp();
39-
$this->initDatabase();
40-
41-
$user = \GitScrum\Models\User::find(1);
42-
$this->be($user);
43-
}
44-
45-
protected function tearDown()
46-
{
47-
//fwrite(STDOUT, __METHOD__ . "\n");
48-
}
7+
abstract class TestCase extends BaseTestCase
8+
{
9+
use CreatesApplication;
4910
}

0 commit comments

Comments
 (0)