Skip to content

Commit 2e054b4

Browse files
authored
Merge pull request #24 from spotlibs/feature/exploration
fix command create test
2 parents 693dd7b + bd0b2fd commit 2e054b4

File tree

6 files changed

+27
-24
lines changed

6 files changed

+27
-24
lines changed

src/Commands/stubs/controller.swagger.plain.stub

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ declare(strict_types=1);
55
namespace DummyNamespace;
66

77
use App\Http\Controllers\Controller;
8-
use App\Http\Usecases\DummyUsecase;
98

109
class DummyClassController extends Controller
1110
{
12-
public function __construct(DummyUsecase $dummyUsecase)
11+
public function __construct()
1312
{
1413
header("Strict-Transport-Security: max-age=31536000; includeSubDomains; preload");
1514
}

src/Commands/stubs/test.plain.stub

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ use Tests\TestCase;
1717

1818
class DummyClassTest extends TestCase
1919
{
20-
/**
21-
* A basic test example.
22-
*
23-
* @return void
24-
*/
25-
public function createApplication()
26-
{
27-
return require realpath(env('LARAVEL_BASE_PATH'));
28-
}
29-
3020
/** @test */
3121
/** @runInSeparateProcess */
3222
public function testDummyClassMethod()

tests/Libraries/RestClientTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function testCall():void
1919
{
2020
$startTime = time();
2121
$client = new RestClient();
22-
$client->call(null, "https://reqres.in", "/api/users?delay=2", "GET");
22+
$client->call(null, "https://dummyjson.com", "/test?delay=2000", "GET");
2323
$duration = time() - $startTime;
2424
$this->assertTrue($duration > 1); // more than 1 second
2525
}
@@ -28,8 +28,8 @@ function testCallAsync():void
2828
{
2929
$startTime = time();
3030
$client = new RestClient();
31-
$client->callAsync(null, "https://reqres.in", "/api/users?delay=3", "GET");
32-
$client->callAsync(null, "https://reqres.in", "/api/users?delay=5", "GET");
31+
$client->callAsync(null, "https://dummyjson.com", "/test?delay=3000", "GET");
32+
$client->callAsync(null, "https://dummyjson.com", "/test?delay=5000", "GET");
3333
$duration = time() - $startTime;
3434
$this->assertTrue($duration < 1); // less than 1 second
3535
}
@@ -38,8 +38,8 @@ function testCallAsync2():void
3838
{
3939
$startTime = microtime(true);
4040
$client = new RestClient();
41-
$promise = $client->callAsync(null, "https://reqres.in", "/api/users?delay=2", "GET");
42-
$promise2 = $client->callAsync(null, "https://reqres.in", "/api/users?delay=2", "GET");
41+
$promise = $client->callAsync(null, "https://dummyjson.com", "/test?delay=2000", "GET");
42+
$promise2 = $client->callAsync(null, "https://dummyjson.com", "/test?delay=2000", "GET");
4343
$response = new Response();
4444
$promise->then(
4545
function(ResponseInterface $res) use (&$response) {
@@ -61,6 +61,5 @@ function() {
6161
$promise2->wait();
6262
$duration = microtime(true) - $startTime;
6363
$this->assertTrue($duration > 2);
64-
$this->assertEquals("https://reqres.in/#support-heading", $response->support->url);
6564
}
6665
}

tests/Logs/LogTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,13 @@
44

55
namespace Tests\Logs;
66

7-
use Laravel\Lumen\Testing\TestCase;
7+
use Tests\TestCase;
88
use Spotlibs\PhpLib\Logs\Log;
99
use Spotlibs\PhpLib\Services\Context;
1010
use Spotlibs\PhpLib\Services\Metadata;
1111

1212
class LogTest extends TestCase
1313
{
14-
public function createApplication()
15-
{
16-
return require __DIR__.'/../../bootstrap/app.php';
17-
}
18-
1914
private function setContext(): void
2015
{
2116
$meta = new Metadata();

tests/TestCase.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests;
6+
7+
use Laravel\Lumen\Testing\TestCase as BaseTestCase;
8+
9+
abstract class TestCase extends BaseTestCase
10+
{
11+
/**
12+
* Creates the application.
13+
*
14+
* @return \Laravel\Lumen\Application
15+
*/
16+
public function createApplication()
17+
{
18+
return require __DIR__.'/../bootstrap/app.php';
19+
}
20+
}

0 commit comments

Comments
 (0)