-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b5c556
commit 4e90f68
Showing
15 changed files
with
255 additions
and
60 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
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 |
---|---|---|
@@ -1,9 +1,28 @@ | ||
<?php | ||
|
||
use Faker\Generator as Faker; | ||
namespace {{ factoryNamespace }}; | ||
|
||
$factory->define(DummyModel::class, function (Faker $faker) { | ||
return [ | ||
// | ||
]; | ||
}); | ||
use Illuminate\Database\Eloquent\Factories\Factory; | ||
use {{ namespacedModel }}; | ||
|
||
class {{ model }}Factory extends Factory | ||
{ | ||
/** | ||
* The name of the factory's corresponding model. | ||
* | ||
* @var string | ||
*/ | ||
protected $model = {{ model }}::class; | ||
|
||
/** | ||
* Define the model's default state. | ||
* | ||
* @return array | ||
*/ | ||
public function definition() | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
} |
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
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
Binary file not shown.
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,51 @@ | ||
<?php | ||
|
||
namespace Tests\Feature; | ||
|
||
use Tests\TestCase; | ||
use Tests\RefreshPacker; | ||
use Illuminate\Support\Facades\Artisan; | ||
|
||
class CrudMakeTest extends TestCase | ||
{ | ||
use RefreshPacker; | ||
|
||
public function test_it_can_create_a_json_file_to_write_crud_structure() | ||
{ | ||
Artisan::call('crud:json Test'); | ||
$this->isFileExists('crud/Test.json'); | ||
} | ||
|
||
public function test_it_can_create_a_crud_for_a_json_file() | ||
{ | ||
Artisan::call('crud:json Test'); | ||
Artisan::call('crud:make Test'); | ||
$this->isFileExists('src/Test.php'); | ||
$this->isFileExists('src/database/factories/TestFactory.php'); | ||
$this->assertEquals(1, count(glob($this->_testPath() . 'src/database/migrations/*_create_tests_table.php'))); | ||
$this->isFileExists('src/Http/controllers/TestController.php'); | ||
$this->isFileExists('tests/Feature/TestTest.php'); | ||
$this->isFileExists('tests/Unit/TestTest.php'); | ||
} | ||
|
||
public function test_it_create_class_based_factory() | ||
{ | ||
Artisan::call('crud:json Test'); | ||
Artisan::call('crud:make Test'); | ||
$this->isFileExists('src/database/factories/TestFactory.php'); | ||
$content = file_get_contents($this->_testPath() . 'src/database/factories/TestFactory.php'); | ||
$this->assertStringContainsString('protected $model = Test::class;', $content); | ||
$this->assertStringContainsString('use Bitfumes\TestApp\Test;', $content); | ||
$this->assertStringContainsString('namespace Bitfumes\TestApp\Database\Factories;', $content); | ||
} | ||
|
||
public function test_it_create_tests_properly() | ||
{ | ||
Artisan::call('crud:json User'); | ||
Artisan::call('crud:make User'); | ||
$this->isFileExists('/tests/Feature/UserTest.php'); | ||
$content = file_get_contents($this->_testPath() . '/tests/Feature/UserTest.php'); | ||
$this->assertStringContainsString('class UserTest', $content); | ||
$this->assertStringContainsString('User::factory()->count($num)->create($args);', $content);; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,21 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Make; | ||
|
||
use Tests\TestCase; | ||
use Tests\RefreshPacker; | ||
use Illuminate\Support\Facades\Artisan; | ||
|
||
class ChannelTest extends TestCase | ||
{ | ||
use RefreshPacker; | ||
|
||
public function test_it_create_class_based_factory() | ||
{ | ||
Artisan::call('make:channel TestChannel'); | ||
$this->isFileExists('src/Broadcasting/TestChannel.php'); | ||
$content = file_get_contents($this->_testPath() . 'src/Broadcasting/TestChannel.php'); | ||
$this->assertStringContainsString('use Bitfumes\TestApp\Models\User;', $content); | ||
$this->assertStringContainsString('TestChannel', $content); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Make; | ||
|
||
use Tests\TestCase; | ||
use Tests\RefreshPacker; | ||
use Illuminate\Support\Facades\Artisan; | ||
|
||
class CommandTest extends TestCase | ||
{ | ||
use RefreshPacker; | ||
|
||
public function test_it_create_class_based_factory() | ||
{ | ||
$this->assertTrue(true); | ||
// Artisan::call('make:command TestCommand'); | ||
// $this->isFileExists('src/Console/TestCommand.php'); | ||
// $content = file_get_contents($this->_testPath() . 'src/Console/TestCommand.php'); | ||
// // $this->assertStringContainsString('use Bitfumes\TestApp\Models\User;', $content); | ||
// $this->assertStringContainsString('TestCommand', $content); | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Make; | ||
|
||
use Tests\TestCase; | ||
use Tests\RefreshPacker; | ||
use Illuminate\Support\Facades\Artisan; | ||
|
||
class ControllerTest extends TestCase | ||
{ | ||
use RefreshPacker; | ||
|
||
public function test_it_create_controller_file() | ||
{ | ||
Artisan::call('make:controller TestController'); | ||
$this->isFileExists('src/Http/Controllers/TestController.php'); | ||
$content = file_get_contents($this->_testPath() . 'src/Http/Controllers/TestController.php'); | ||
$this->assertStringContainsString('TestController', $content); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
|
||
namespace Tests\Feature\Make; | ||
|
||
use Tests\TestCase; | ||
use Tests\RefreshPacker; | ||
use Illuminate\Support\Facades\Artisan; | ||
|
||
class FactoryTest extends TestCase | ||
{ | ||
use RefreshPacker; | ||
|
||
public function test_it_create_class_based_factory() | ||
{ | ||
Artisan::call('make:factory TestFactory --model Test'); | ||
$this->isFileExists('src/database/factories/TestFactory.php'); | ||
$content = file_get_contents($this->_testPath() . 'src/database/factories/TestFactory.php'); | ||
$this->assertStringContainsString('protected $model = Test::class;', $content); | ||
$this->assertStringContainsString('use Bitfumes\TestApp\Test;', $content); | ||
$this->assertStringContainsString('namespace Bitfumes\TestApp\Database\Factories;', $content); | ||
} | ||
} |
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