Skip to content

Commit

Permalink
Merge pull request #57 from RonasIT/add-nova-tests-generation
Browse files Browse the repository at this point in the history
Add nova tests generation
  • Loading branch information
DenTray committed Dec 19, 2023
2 parents 2111850 + 77bc95c commit 1615834
Show file tree
Hide file tree
Showing 28 changed files with 1,562 additions and 278 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/run-tests-with-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Run tests with coverage

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
test-with-coverage:
runs-on: ubuntu-latest
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- uses: actions/checkout@v3
- name: Validate composer.json and composer.lock
run: composer validate
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Execute unit tests via PHPUnit with coverage
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml
- name: Upload coverage results to Coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer global require php-coveralls/php-coveralls
php-coveralls --coverage_clover=build/logs/clover.xml -v
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
vendor/
composer.lock
composer.lock
.phpunit.result.cache
.phpunit.result.cache
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM webdevops/php-nginx-dev:7.4

RUN wget -O "/usr/local/bin/go-replace" "https://github.com/webdevops/goreplace/releases/download/1.1.2/gr-arm64-linux" \
&& chmod +x "/usr/local/bin/go-replace" \
&& "/usr/local/bin/go-replace" --version
34 changes: 34 additions & 0 deletions bootstrap/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Composer Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader
| for our application. We just need to utilize it! We'll require it
| into the script here so that we do not have to worry about the
| loading of any our classes "manually". Feels great to relax.
|
*/

require __DIR__.'/../vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Include The Compiled Class File
|--------------------------------------------------------------------------
|
| To dramatically increase your application's performance, you may use a
| compiled class file which contains all of the classes commonly used
| by a request. The Artisan "optimize" is used to create this file.
|
*/

$compiledPath = __DIR__.'/cache/compiled.php';

if (file_exists($compiledPath)) {
require $compiledPath;
}
2 changes: 2 additions & 0 deletions bootstrap/cache/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
18 changes: 14 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,34 @@
],
"require": {
"php": ">=7.1.3",
"laravel/framework": ">=5.4.0",
"ronasit/laravel-helpers": ">=2.0.0-beta",
"laravel/framework": ">=5.7.0",
"ronasit/laravel-helpers": ">=2.5",
"laravel/legacy-factories": ">=1.3.0",
"ext-json": "*"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.*",
"phpunit/phpunit": "~4.0"
"php-coveralls/php-coveralls": "^2.5",
"mockery/mockery": "^1.4",
"phpunit/phpunit": "^8.0",
"mikey179/vfsstream": "^1.6.11",
"php-mock/php-mock": "^2.4.1",
"orchestra/testbench": "^6.25"
},
"autoload": {
"psr-4": {
"RonasIT\\Support\\Tests\\": "tests/",
"RonasIT\\Support\\": "src/"
},
"files": [
"src/helpers.php"
]
},
"autoload-dev": {
"files": [
"tests/TestCase.php"
]
},
"minimum-stability": "beta",
"extra": {
"laravel": {
Expand Down
5 changes: 3 additions & 2 deletions config/entity-generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
'factory' => 'database/factories/ModelFactory.php',
'translations' => 'resources/lang/en/validation.php',
'resources' => 'app/Http/Resources',
'nova' => 'app/Nova'
'nova' => 'app/Nova',
],
'stubs' => [
'model' => 'entity-generator::model',
Expand All @@ -44,6 +44,7 @@
'validation' => 'entity-generator::validation',
'resource' => 'entity-generator::resource',
'collection_resource' => 'entity-generator::collection_resource',
'nova_resource' => 'entity-generator::nova_resource'
'nova_resource' => 'entity-generator::nova_resource',
'nova_test' => 'entity-generator::nova_test'
]
];
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'

services:
nginx:
build: .
working_dir: /app
ports:
- 80:80
- 443:443
volumes:
- ./:/app
29 changes: 29 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="bootstrap/autoload.php"
colors="true"
cacheResultFile=".phpunit.cache"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./src</directory>
<directory suffix=".php">./tests</directory>
<exclude>
<directory>./tests/fixtures</directory>
<file>./tests/TestCase.php</file>
</exclude>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>

</phpunit>
11 changes: 9 additions & 2 deletions src/Commands/MakeEntityCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use RonasIT\Support\Generators\MigrationGenerator;
use RonasIT\Support\Generators\ModelGenerator;
use RonasIT\Support\Generators\NovaResourceGenerator;
use RonasIT\Support\Generators\NovaTestGenerator;
use RonasIT\Support\Generators\RepositoryGenerator;
use RonasIT\Support\Generators\RequestsGenerator;
use RonasIT\Support\Generators\ResourceGenerator;
Expand All @@ -38,6 +39,7 @@
* @property SeederGenerator $seederGenerator
* @property ResourceGenerator $resourceGenerator
* @property NovaResourceGenerator $novaResourceGenerator
* @property NovaTestGenerator $novaTestGenerator
* @property EventDispatcher $eventDispatcher
*/
class MakeEntityCommand extends Command
Expand Down Expand Up @@ -66,6 +68,7 @@ class MakeEntityCommand extends Command
{--only-tests : Set this flag if you want to create only tests.}
{--only-seeder : Set this flag if you want to create only seeder.}
{--only-nova-resource : Set this flag if you want to create only nova resource.}
{--only-nova-tests : Set this flag if you want to create only nova resource tests.}
{--methods=CRUD : Set types of methods to create. Affect on routes, requests classes, controller\'s methods and tests methods.}
Expand Down Expand Up @@ -105,6 +108,7 @@ class MakeEntityCommand extends Command
protected $seederGenerator;
protected $resourceGenerator;
protected $novaResourceGenerator;
protected $novaTestGenerator;
protected $eventDispatcher;

protected $rules = [
Expand All @@ -121,14 +125,16 @@ class MakeEntityCommand extends Command
'only-factory' => [FactoryGenerator::class],
'only-tests' => [FactoryGenerator::class, TestsGenerator::class],
'only-seeder' => [SeederGenerator::class],
'only-nova-resource' => [NovaResourceGenerator::class]
'only-nova-resource' => [NovaResourceGenerator::class],
'only-nova-tests' => [NovaTestGenerator::class]
]
];

public $generators = [
ModelGenerator::class, RepositoryGenerator::class, ServiceGenerator::class, RequestsGenerator::class,
ResourceGenerator::class, ControllerGenerator::class, MigrationGenerator::class, FactoryGenerator::class,
TestsGenerator::class, TranslationsGenerator::class, SeederGenerator::class, NovaResourceGenerator::class
TestsGenerator::class, TranslationsGenerator::class, SeederGenerator::class, NovaResourceGenerator::class,
NovaTestGenerator::class
];

public function __construct()
Expand All @@ -147,6 +153,7 @@ public function __construct()
$this->seederGenerator = app(SeederGenerator::class);
$this->resourceGenerator = app(ResourceGenerator::class);
$this->novaResourceGenerator = app(NovaResourceGenerator::class);
$this->novaTestGenerator = app(NovaTestGenerator::class);
$this->eventDispatcher = app(EventDispatcher::class);
}

Expand Down
Loading

0 comments on commit 1615834

Please sign in to comment.