generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added Job Make Command - Attempt to generate tests: - Generation is working - TODO: Generated tests cannot be seen by pest. Come up with a concrete setup for tests in the modules
- Loading branch information
1 parent
d0baef6
commit 49f9ba5
Showing
8 changed files
with
183 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
'resources/css', | ||
'routes', | ||
'storage', | ||
'tests', | ||
'tests/Feature', | ||
'tests/Unit', | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Savannabits\Modular\Commands; | ||
|
||
use Savannabits\Modular\Support\Concerns\GeneratesModularFiles; | ||
|
||
class JobMakeCommand extends \Illuminate\Foundation\Console\JobMakeCommand | ||
{ | ||
use GeneratesModularFiles; | ||
|
||
protected $name = 'modular:make-job'; | ||
|
||
protected $description = 'Create a new job class in a modular package'; | ||
|
||
protected function getRelativeNamespace(): string | ||
{ | ||
return 'Jobs'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Savannabits\Modular\Commands; | ||
|
||
use Illuminate\Support\Str; | ||
use Savannabits\Modular\Support\Concerns\GeneratesModularFiles; | ||
|
||
class TestMakeCommand extends \Illuminate\Foundation\Console\TestMakeCommand | ||
{ | ||
use GeneratesModularFiles; | ||
|
||
protected $name = 'modular:make-test'; | ||
|
||
protected $description = 'Create a new test class in a modular package'; | ||
|
||
protected function getPath($name): string | ||
{ | ||
$name = Str::replaceFirst($this->rootNamespace(), '', $name); | ||
|
||
return $this->getModule()->testsPath(str_replace('\\', '/', $name).'.php'); | ||
} | ||
|
||
/** | ||
* Get the default namespace for the class. | ||
* | ||
* @param string $rootNamespace | ||
* @return string | ||
*/ | ||
protected function getDefaultNamespace($rootNamespace): string | ||
{ | ||
if ($this->option('unit')) { | ||
return $rootNamespace.'\Unit'; | ||
} else { | ||
return $rootNamespace.'\Feature'; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Test Case | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The closure you provide to your test functions is always bound to a specific PHPUnit test | ||
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may | ||
| need to change it using the "uses()" function to bind a different classes or traits. | ||
| | ||
*/ | ||
|
||
uses( | ||
{{ namespace }}\Tests\TestCase::class, | ||
// Illuminate\Foundation\Testing\RefreshDatabase::class, | ||
)->in(__DIR__); | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Expectations | ||
|-------------------------------------------------------------------------- | ||
| | ||
| When you're writing tests, you often need to check that values meet certain conditions. The | ||
| "expect()" function gives you access to a set of "expectations" methods that you can use | ||
| to assert different things. Of course, you may extend the Expectation API at any time. | ||
| | ||
*/ | ||
|
||
expect()->extend('toBeOne', function () { | ||
return $this->toBe(1); | ||
}); | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Functions | ||
|-------------------------------------------------------------------------- | ||
| | ||
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your | ||
| project that you don't want to repeat in every file. Here you can also expose helpers as | ||
| global functions to help you to reduce the number of lines of code in your test files. | ||
| | ||
*/ | ||
|
||
function something() | ||
{ | ||
// .. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="../../vendor/phpunit/phpunit/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
> | ||
<testsuites> | ||
<testsuite name="Unit"> | ||
<directory>tests/Unit</directory> | ||
</testsuite> | ||
<testsuite name="Feature"> | ||
<directory>tests/Feature</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory>app</directory> | ||
</include> | ||
</source> | ||
<php> | ||
<env name="APP_ENV" value="testing"/> | ||
<env name="APP_MAINTENANCE_DRIVER" value="file"/> | ||
<env name="BCRYPT_ROUNDS" value="4"/> | ||
<env name="CACHE_STORE" value="array"/> | ||
<!-- <env name="DB_CONNECTION" value="sqlite"/> --> | ||
<!-- <env name="DB_DATABASE" value=":memory:"/> --> | ||
<env name="MAIL_MAILER" value="array"/> | ||
<env name="PULSE_ENABLED" value="false"/> | ||
<env name="QUEUE_CONNECTION" value="sync"/> | ||
<env name="SESSION_DRIVER" value="array"/> | ||
<env name="TELESCOPE_ENABLED" value="false"/> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace {{ namespace }}; | ||
|
||
use Orchestra\Testbench\TestCase as Orchestra; | ||
|
||
abstract class TestCase extends Orchestra | ||
{ | ||
// | ||
} |