|
@@ -3,27 +3,15 @@
|
|
|
namespace Knuckles\Scribe\Tests\Strategies\Responses;
|
|
|
|
|
|
use Knuckles\Scribe\Extracting\Strategies\Responses\UseResponseFileTag;
|
|
|
-use Knuckles\Scribe\ScribeServiceProvider;
|
|
|
use Knuckles\Scribe\Tools\DocumentationConfig;
|
|
|
use Mpociot\Reflection\DocBlock\Tag;
|
|
|
use DMS\PHPUnitExtensions\ArraySubset\ArraySubsetAsserts;
|
|
|
-use Orchestra\Testbench\TestCase;
|
|
|
+use PHPUnit\Framework\TestCase;
|
|
|
|
|
|
class UseResponseFileTagTest extends TestCase
|
|
|
{
|
|
|
use ArraySubsetAsserts;
|
|
|
|
|
|
- protected function getPackageProviders($app)
|
|
|
- {
|
|
|
- $providers = [
|
|
|
- ScribeServiceProvider::class,
|
|
|
- ];
|
|
|
- if (class_exists(\Dingo\Api\Provider\LaravelServiceProvider::class)) {
|
|
|
- $providers[] = \Dingo\Api\Provider\LaravelServiceProvider::class;
|
|
|
- }
|
|
|
- return $providers;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @test
|
|
|
* @dataProvider responseFileTags
|
|
@@ -33,9 +21,6 @@ class UseResponseFileTagTest extends TestCase
|
|
|
$filePath = __DIR__ . '/../../Fixtures/response_test.json';
|
|
|
$filePath2 = __DIR__ . '/../../Fixtures/response_error_test.json';
|
|
|
|
|
|
- copy($filePath, storage_path('response_test.json'));
|
|
|
- copy($filePath2, storage_path('response_error_test.json'));
|
|
|
-
|
|
|
$strategy = new UseResponseFileTag(new DocumentationConfig([]));
|
|
|
$results = $strategy->getFileResponses($tags);
|
|
|
|
|
@@ -52,20 +37,14 @@ class UseResponseFileTagTest extends TestCase
|
|
|
],
|
|
|
], $results);
|
|
|
|
|
|
- unlink(storage_path('response_test.json'));
|
|
|
- unlink(storage_path('response_error_test.json'));
|
|
|
}
|
|
|
|
|
|
/** @test */
|
|
|
public function can_add_or_replace_key_value_pair_in_response_file()
|
|
|
{
|
|
|
-
|
|
|
- $filePath = __DIR__ . '/../../Fixtures/response_test.json';
|
|
|
- copy($filePath, storage_path('response_test.json'));
|
|
|
-
|
|
|
$strategy = new UseResponseFileTag(new DocumentationConfig([]));
|
|
|
$tags = [
|
|
|
- new Tag('responseFile', 'response_test.json {"message" : "Serendipity", "gender": "male"}'),
|
|
|
+ new Tag('responseFile', 'tests/Fixtures/response_test.json {"message" : "Serendipity", "gender": "male"}'),
|
|
|
];
|
|
|
$results = $strategy->getFileResponses($tags);
|
|
|
|
|
@@ -82,8 +61,8 @@ class UseResponseFileTagTest extends TestCase
|
|
|
return [
|
|
|
"with status as initial position" => [
|
|
|
[
|
|
|
- new Tag('responseFile', 'response_test.json'),
|
|
|
- new Tag('responseFile', '401 response_error_test.json'),
|
|
|
+ new Tag('responseFile', 'tests/Fixtures/response_test.json'),
|
|
|
+ new Tag('responseFile', '401 tests/Fixtures/response_error_test.json'),
|
|
|
],
|
|
|
[
|
|
|
[
|
|
@@ -99,8 +78,8 @@ class UseResponseFileTagTest extends TestCase
|
|
|
|
|
|
"with attributes" => [
|
|
|
[
|
|
|
- new Tag('responseFile', 'scenario="success" response_test.json'),
|
|
|
- new Tag('responseFile', 'status=401 scenario=\'auth problem\' response_error_test.json'),
|
|
|
+ new Tag('responseFile', 'scenario="success" tests/Fixtures/response_test.json'),
|
|
|
+ new Tag('responseFile', 'status=401 scenario=\'auth problem\' tests/Fixtures/response_error_test.json'),
|
|
|
],
|
|
|
[
|
|
|
[
|