Skip to content

Commit

Permalink
Merge pull request #31 from yepwoo/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mahmoodahmad100 authored Mar 18, 2023
2 parents 97de1aa + 70bb404 commit 13bc0a9
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 16 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
![Codacy grade](https://img.shields.io/codacy/grade/c8ff813591bf46ee9711e57188149288)
[![Total Downloads](https://img.shields.io/packagist/dt/yepwoo/laragine.svg)](https://packagist.org/packages/yepwoo/laragine)

| **Supported Laravel Versions** |
|-------------|
| 8.x |
| 9.x |
| 10.x |

We developed Laragine to make the software development using Laravel faster and cleaner, so you can get things done faster, not only that, Laragine is not about quantity only, it's all about quantity and quality.

#### Quick short video:
Expand Down
2 changes: 1 addition & 1 deletion docs/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Handler extends ExceptionHandler
}
```

Now, we need to use this helper function `client_validation_response` (it accepts 2 arguments, the first is the rules array and the second (optional) is the start error code) in the validation file (`lang\en\validation.php` in Laravel `9.x` or `resources\lang\en\validation.php` Laravel `8.x`) by assigning the array to a variable and then return the helper function, here is the full code snippet:
Now, we need to use this helper function `client_validation_response` (it accepts 2 arguments, the first is the rules array and the second (optional) is the start error code) in the validation file (`lang\en\validation.php` in Laravel `9.x` and `10.x` (in `10.x` you need to run this command first: `php artisan lang:publish`) or `resources\lang\en\validation.php` Laravel `8.x`) by assigning the array to a variable and then return the helper function, here is the full code snippet:

```php
$array = [
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ It's also very important to understand the following terms:

### Notes

* Laragine currently is working on **Laravel 8.x and 9.x**
* Laragine currently is working on **Laravel 8.x, 9.x and 10.x**

* Laragine directory will be in the root directory under `Core` directory

Expand Down
4 changes: 2 additions & 2 deletions docs/middlewares.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Useful middlewares to help you protect the system and for better security:

to check if the client side includes a valid `api-key` header in any API request.

to use it, first add `API_KEY=your_api_key_here` in `.env` file, second in the **Kernel** (`app\Http\Kernel.php`) add it in `$routeMiddleware` as below:
to use it, first add `API_KEY=your_api_key_here` in `.env` file, second in the **Kernel** (`app\Http\Kernel.php`) add it in `$routeMiddleware` or `middlewareAliases` if it's Laravel `10.x` as below:

```php
protected $routeMiddleware = [
protected $middlewareAliases = [

...

Expand Down
15 changes: 11 additions & 4 deletions src/Core/Base/TestCase.stub → src/Core/Base/ApiTestCase.stub
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

namespace Core\Base\Tests;

use Tests\TestCase as BaseTestCase;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use App\Models\User;
// use Tymon\JWTAuth\Facades\JWTAuth;

class TestCase extends BaseTestCase
class ApiTestCase extends TestCase
{
use RefreshDatabase;

Expand All @@ -18,6 +18,13 @@ class TestCase extends BaseTestCase
*/
protected $base_url;

/**
* the current model
*
* @var array
*/
protected $model;

/**
* the data that will be sent in the request (create/update)
*
Expand Down Expand Up @@ -125,11 +132,11 @@ class TestCase extends BaseTestCase
/**
* create new entry
*
* @return Model
* @return \Illuminate\Database\Eloquent\Model
*/
protected function getNewEntry()
{
return Model::factory()->create();
return $this->model::factory()->create();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Base/SendResponse.stub
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ trait SendResponse
}

if (env('APP_DEBUG') == true) {
$errors = $e->errors();
$errors = $e->getTrace();
$message = $e->getMessage();
}

Expand Down
6 changes: 3 additions & 3 deletions src/Core/Base/WebControllerTest.stub
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Core\Base\Tests\Unit;

use Core\Base\Tests\TestCase;
use Core\Base\Tests\WebTestCase;
use Core\Base\Controllers\Web\Controller;

class WebControllerTest extends TestCase
class WebControllerTest extends WebTestCase
{
/**
* the web controller
Expand All @@ -26,7 +26,7 @@ class WebControllerTest extends TestCase

$this->controller = $this->getMockBuilder(Controller::class)
->disableOriginalConstructor()
->setMethods(['getExplodedNamespace'])
->onlyMethods(['getExplodedNamespace'])
->getMock();

$this->controller->expects($this->any())
Expand Down
10 changes: 10 additions & 0 deletions src/Core/Base/WebTestCase.stub
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Core\Base\Tests;

use Tests\TestCase;

class WebTestCase extends TestCase
{

}
7 changes: 4 additions & 3 deletions src/Core/Module/UnitTest.stub
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Core\#MODULE_NAME#\Tests\Feature;

use Core\Base\Tests\TestCase;
use Core\Base\Tests\ApiTestCase;
use Core\#MODULE_NAME#\Models\#UNIT_NAME# as Model;

class #UNIT_NAME#Test extends TestCase
class #UNIT_NAME#Test extends ApiTestCase
{
/**
* setting up
Expand All @@ -18,7 +18,8 @@ class #UNIT_NAME#Test extends TestCase
parent::setUp();

$this->base_url = $this->getApiBaseUrl() . '#UNIT_NAME_PLURAL_LOWER_CASE#/';
$this->data = Model::factory()->make()->toArray();
$this->model = new Model();
$this->data = $this->model::factory()->make()->toArray();
$this->json = $this->getJsonStructure();
$this->json['data'] = ['id'];

Expand Down
3 changes: 2 additions & 1 deletion src/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
'api.php' => 'routes/api.php',
'web.php' => 'routes/web.php',
'WebControllerTest.stub' => 'Tests/Unit/WebControllerTest.php',
'TestCase.stub' => 'Tests/TestCase.php',
'ApiTestCase.stub' => 'Tests/ApiTestCase.php',
'WebTestCase.stub' => 'Tests/WebTestCase.php',
'Uuid.stub' => 'Traits/Model/Uuid.php',
'SendResponse.stub' => 'Traits/Response/SendResponse.php',
'File.stub' => 'Traits/ServiceProvider/File.php',
Expand Down

0 comments on commit 13bc0a9

Please sign in to comment.