Skip to content

Commit 5ab1bc1

Browse files
committed
Created test file, added new files and fixed bugs in src/Commands/ApiGenerator.php
1 parent 8ec404f commit 5ab1bc1

9 files changed

+432
-26
lines changed

config/apigenerator.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
// Or create a 'snippetify-ams.json' file in the root of your project
2626
'modules' => [
2727
// [
28-
// 'name' => 'Article', // The name of your module in StudlyCase(PascalCase), for namespacing
28+
// 'name' => 'Blog', // The name of your module in StudlyCase(PascalCase), for namespacing
2929
// 'model' => [
3030
// 'name' => 'Article', // The name of your model in StudlyCase(PascalCase)
3131
// 'hasUser' => true, // Is owned by a user,
@@ -44,5 +44,17 @@
4444
// ]
4545
// ]
4646
// ]
47+
],
48+
49+
// App dependencies
50+
"dependencies" => [
51+
'algolia/algoliasearch-client-php' => '^2.8',
52+
'fruitcake/laravel-cors' => '^2.0',
53+
'guzzlehttp/guzzle' => '^7.0.1',
54+
'laravel/sanctum' => '^2.8',
55+
'laravel/scout' => '^8.6',
56+
'spatie/laravel-activitylog' => '^3.16',
57+
'spatie/laravel-medialibrary' => '^9.4',
58+
'spatie/laravel-query-builder' => '^3.3'
4759
]
4860
];

config/apigenerator_test.php

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the snippetify package.
5+
*
6+
* (c) Evens Pierre <evenspierre@snippetify.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
return [
13+
14+
/*
15+
|-----------------------------------------------------------------------
16+
| Snippetify ApiGenerator Configuration
17+
|-----------------------------------------------------------------------
18+
|
19+
| A collection of default options to apply to snippet ApiGenerator objects
20+
|
21+
| @see {@link https =>//github.com/snippetify/laravel-api-generator}
22+
*/
23+
24+
// Define the skeleton of your project here in the module array
25+
// Or create a 'snippetify-ams.json' file in the root of your project
26+
'modules' => [
27+
[
28+
'name' => 'Blog', // The name of your module in StudlyCase(PascalCase), for namespacing
29+
'model' => [
30+
'name' => 'Article', // The name of your model in StudlyCase(PascalCase)
31+
'hasUser' => true, // Is owned by a user,
32+
'hasLog' => true, // Allow model to be loggable,
33+
'softDelete' => true, // Add laravel soft delete feature to model
34+
'isSearchable' => true, // Allow this model to be fulltext searchable using laravel scout library
35+
'hasMedia' => true, // Attach a media to this library using the Spatie Media library
36+
'hasSlug' => true, // Add a slug to this model
37+
'issers' => [ 'published', 'activated' ], // Issers like isPublished, isActivated, etc...
38+
'attributes' => [
39+
'name' => [ 'type' => 'string', 'rules' => '', 'fillable' => true, 'hidden' => false ],
40+
],
41+
'relations' => [ // Relation types: oneToOne, oneToMany, manyToOne, manyToMany
42+
'comments' => [ 'type' => 'oneToOne', 'class' => 'App\Models\Blog\Comment', 'morph' => false, 'with' => true, 'inverse' => true ],
43+
'categories' => [ 'type' => 'oneToMany', 'class' => 'App\Models\Blog\Category', 'morph' => false, 'with' => true ],
44+
]
45+
]
46+
]
47+
],
48+
49+
// App dependencies
50+
"dependencies" => [
51+
'algolia/algoliasearch-client-php' => '^2.8',
52+
'fruitcake/laravel-cors' => '^2.0',
53+
'guzzlehttp/guzzle' => '^7.0.1',
54+
'laravel/sanctum' => '^2.8',
55+
'laravel/scout' => '^8.6',
56+
'spatie/laravel-activitylog' => '^3.16',
57+
'spatie/laravel-medialibrary' => '^9.4',
58+
'spatie/laravel-query-builder' => '^3.3'
59+
]
60+
];

config/filesystems.php

+82
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
return [
4+
5+
/*
6+
|--------------------------------------------------------------------------
7+
| Default Filesystem Disk
8+
|--------------------------------------------------------------------------
9+
|
10+
| Here you may specify the default filesystem disk that should be used
11+
| by the framework. The "local" disk, as well as a variety of cloud
12+
| based disks are available to your application. Just store away!
13+
|
14+
*/
15+
16+
'default' => env('FILESYSTEM_DRIVER', 'local'),
17+
18+
/*
19+
|--------------------------------------------------------------------------
20+
| Filesystem Disks
21+
|--------------------------------------------------------------------------
22+
|
23+
| Here you may configure as many filesystem "disks" as you wish, and you
24+
| may even configure multiple disks of the same driver. Defaults have
25+
| been setup for each driver as an example of the required options.
26+
|
27+
| Supported Drivers: "local", "ftp", "sftp", "s3"
28+
|
29+
*/
30+
31+
'disks' => [
32+
33+
'local' => [
34+
'driver' => 'local',
35+
'root' => storage_path('app'),
36+
],
37+
38+
'base' => [
39+
'driver' => 'local',
40+
'root' => base_path(),
41+
],
42+
43+
'app' => [
44+
'driver' => 'local',
45+
'root' => app_path(),
46+
],
47+
48+
'public' => [
49+
'driver' => 'local',
50+
'root' => storage_path('app/public'),
51+
'url' => env('APP_URL').'/storage',
52+
'visibility' => 'public',
53+
],
54+
55+
's3' => [
56+
'driver' => 's3',
57+
'key' => env('AWS_ACCESS_KEY_ID'),
58+
'secret' => env('AWS_SECRET_ACCESS_KEY'),
59+
'region' => env('AWS_DEFAULT_REGION'),
60+
'bucket' => env('AWS_BUCKET'),
61+
'url' => env('AWS_URL'),
62+
'endpoint' => env('AWS_ENDPOINT'),
63+
],
64+
65+
],
66+
67+
/*
68+
|--------------------------------------------------------------------------
69+
| Symbolic Links
70+
|--------------------------------------------------------------------------
71+
|
72+
| Here you may configure the symbolic links that will be created when the
73+
| `storage:link` Artisan command is executed. The array keys should be
74+
| the locations of the links and the values should be their targets.
75+
|
76+
*/
77+
78+
'links' => [
79+
public_path('storage') => storage_path('app/public'),
80+
],
81+
82+
];

phpunit.xml.dist

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
bootstrap="vendor/autoload.php"
5+
backupGlobals="false"
6+
backupStaticAttributes="false"
7+
colors="true"
8+
verbose="true"
9+
failOnRisky="true"
10+
convertErrorsToExceptions="true"
11+
convertNoticesToExceptions="true"
12+
convertWarningsToExceptions="true"
13+
processIsolation="false"
14+
stopOnFailure="false"
15+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
16+
>
17+
<coverage>
18+
<include>
19+
<directory suffix=".php">src/</directory>
20+
</include>
21+
</coverage>
22+
<testsuites>
23+
<testsuite name="Unit">
24+
<directory suffix="Test.php">./tests/Unit</directory>
25+
</testsuite>
26+
<testsuite name="Feature">
27+
<directory suffix="Test.php">./tests/Feature</directory>
28+
</testsuite>
29+
</testsuites>
30+
<php>
31+
<env name="APP_ENV" value="testing"/>
32+
<env name="DB_CONNECTION" value="testing"/>
33+
<env name="APP_KEY" value=""/>
34+
</php>
35+
</phpunit>

src/ApiGeneratorServiceProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Snippetify\ApiGenerator\Commands\ApiGenerator;
1515
use Illuminate\Contracts\Support\DeferrableProvider;
1616

17-
class ApiGeneratorServiceProvider extends ServiceProvider implements DeferrableProvider
17+
class ApiGeneratorServiceProvider extends ServiceProvider
1818
{
1919
/**
2020
* Get the path of the configuration file shipping with the package.

0 commit comments

Comments
 (0)