mirror of
https://github.com/ZorgCC/lumen-generators.git
synced 2025-01-13 05:47:56 +03:00
Fixing the failing build
This commit is contained in:
parent
942b8fefb4
commit
17bc595db9
@ -8,7 +8,7 @@ php:
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- php: 7.0
|
||||
- php: hhvm
|
||||
|
||||
sudo: false
|
||||
|
||||
|
3
lumen-test/.gitignore
vendored
3
lumen-test/.gitignore
vendored
@ -3,4 +3,5 @@
|
||||
|
||||
tests/_output/*
|
||||
|
||||
composer.lock
|
||||
composer.lock
|
||||
tests/_output/*
|
@ -1,10 +0,0 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
|
||||
class ProjectsController extends Controller {
|
||||
|
||||
const MODEL = "App\Project";
|
||||
|
||||
use RESTActions;
|
||||
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
|
||||
class TagsController extends Controller {
|
||||
|
||||
const MODEL = "App\Tag";
|
||||
|
||||
use RESTActions;
|
||||
|
||||
}
|
@ -7,7 +7,7 @@ paths:
|
||||
envs: tests/_envs
|
||||
settings:
|
||||
bootstrap: _bootstrap.php
|
||||
colors: true
|
||||
colors: false
|
||||
memory_limit: 1024M
|
||||
extensions:
|
||||
enabled:
|
||||
|
@ -19,3 +19,24 @@ $factory->define(App\User::class, function ($faker) {
|
||||
'remember_token' => str_random(10),
|
||||
];
|
||||
});
|
||||
/**
|
||||
* Factory definition for model App\Task.
|
||||
*/
|
||||
$factory->define(App\Task::class, function ($faker) {
|
||||
return [
|
||||
// Fields here
|
||||
];
|
||||
});
|
||||
|
||||
/**
|
||||
* Factory definition for model App\TaskCategory.
|
||||
*/
|
||||
$factory->define(App\TaskCategory::class, function ($faker) {
|
||||
return [
|
||||
'name' => $faker->word,
|
||||
'descr' => $faker->paragraph,
|
||||
'due' => $faker->date,
|
||||
'project_id' => $faker->key,
|
||||
'user_id' => $faker->key,
|
||||
];
|
||||
});
|
||||
|
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
class ExampleTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* A basic test example.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testBasicExample()
|
||||
{
|
||||
$this->visit('/')
|
||||
->see('Lumen.');
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
class TestCase extends Laravel\Lumen\Testing\TestCase
|
||||
{
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Laravel\Lumen\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
return require __DIR__.'/../bootstrap/app.php';
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
|
@ -12,7 +12,7 @@
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace Helper;
|
||||
|
||||
// here you can define custom actions
|
||||
// all public methods declared in helper class will be available in $I
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
* @method void am($role)
|
||||
* @method void lookForwardTo($achieveValue)
|
||||
* @method void comment($description)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null)
|
||||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
|
||||
*
|
||||
* @SuppressWarnings(PHPMD)
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php //[STAMP] 90ca27738c5db3919bd1f5813987c735
|
||||
<?php //[STAMP] 6172d62f52ee53bf8d6f975a52df4f0d
|
||||
namespace _generated;
|
||||
|
||||
// This class was automatically generated by build task
|
||||
@ -250,6 +250,74 @@ trait AcceptanceTesterActions
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks If opened file has the `number` of new lines.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->openFile('composer.json');
|
||||
* $I->seeNumberNewLines(5);
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param int $number New lines
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see \Codeception\Module\Filesystem::seeNumberNewLines()
|
||||
*/
|
||||
public function canSeeNumberNewLines($number) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeNumberNewLines', func_get_args()));
|
||||
}
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks If opened file has the `number` of new lines.
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* ``` php
|
||||
* <?php
|
||||
* $I->openFile('composer.json');
|
||||
* $I->seeNumberNewLines(5);
|
||||
* ?>
|
||||
* ```
|
||||
*
|
||||
* @param int $number New lines
|
||||
* @see \Codeception\Module\Filesystem::seeNumberNewLines()
|
||||
*/
|
||||
public function seeNumberNewLines($number) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeNumberNewLines', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that contents of currently opened file matches $regex
|
||||
*
|
||||
* @param $regex
|
||||
* Conditional Assertion: Test won't be stopped on fail
|
||||
* @see \Codeception\Module\Filesystem::seeThisFileMatches()
|
||||
*/
|
||||
public function canSeeThisFileMatches($regex) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\ConditionalAssertion('seeThisFileMatches', func_get_args()));
|
||||
}
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks that contents of currently opened file matches $regex
|
||||
*
|
||||
* @param $regex
|
||||
* @see \Codeception\Module\Filesystem::seeThisFileMatches()
|
||||
*/
|
||||
public function seeThisFileMatches($regex) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Assertion('seeThisFileMatches', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php //[STAMP] ffada6587f597b23930f2f63d3309fd0
|
||||
<?php //[STAMP] 113b78942a9c8ce85a7c18397003b17c
|
||||
namespace _generated;
|
||||
|
||||
// This class was automatically generated by build task
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php //[STAMP] c871459f363e639d6d4c21f535bb78f4
|
||||
<?php //[STAMP] afa4f0350422fae145b4236dce66191a
|
||||
namespace _generated;
|
||||
|
||||
// This class was automatically generated by build task
|
||||
@ -24,8 +24,6 @@ trait UnitTesterActions
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
*
|
||||
* @return mixed
|
||||
* @see \Codeception\Module\Asserts::assertEquals()
|
||||
*/
|
||||
public function assertEquals($expected, $actual, $message = null) {
|
||||
@ -56,8 +54,7 @@ trait UnitTesterActions
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param string $message
|
||||
*
|
||||
* @return mixed
|
||||
* @return mixed|void
|
||||
* @see \Codeception\Module\Asserts::assertSame()
|
||||
*/
|
||||
public function assertSame($expected, $actual, $message = null) {
|
||||
@ -95,17 +92,6 @@ trait UnitTesterActions
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @deprecated
|
||||
* @see \Codeception\Module\Asserts::assertGreaterThen()
|
||||
*/
|
||||
public function assertGreaterThen($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThen', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
@ -121,17 +107,6 @@ trait UnitTesterActions
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @deprecated
|
||||
* @see \Codeception\Module\Asserts::assertGreaterThenOrEqual()
|
||||
*/
|
||||
public function assertGreaterThenOrEqual($expected, $actual, $message = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterThenOrEqual', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
@ -310,7 +285,7 @@ trait UnitTesterActions
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks if file exists
|
||||
*
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertFileExists()
|
||||
@ -324,7 +299,7 @@ trait UnitTesterActions
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Checks if file doesn't exist
|
||||
*
|
||||
*
|
||||
* @param string $filename
|
||||
* @param string $message
|
||||
* @see \Codeception\Module\Asserts::assertFileNotExists()
|
||||
@ -334,6 +309,122 @@ trait UnitTesterActions
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param $description
|
||||
* @see \Codeception\Module\Asserts::assertGreaterOrEquals()
|
||||
*/
|
||||
public function assertGreaterOrEquals($expected, $actual, $description = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertGreaterOrEquals', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @param $expected
|
||||
* @param $actual
|
||||
* @param $description
|
||||
* @see \Codeception\Module\Asserts::assertLessOrEquals()
|
||||
*/
|
||||
public function assertLessOrEquals($expected, $actual, $description = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertLessOrEquals', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @param $actual
|
||||
* @param $description
|
||||
* @see \Codeception\Module\Asserts::assertIsEmpty()
|
||||
*/
|
||||
public function assertIsEmpty($actual, $description = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertIsEmpty', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @param $key
|
||||
* @param $actual
|
||||
* @param $description
|
||||
* @see \Codeception\Module\Asserts::assertArrayHasKey()
|
||||
*/
|
||||
public function assertArrayHasKey($key, $actual, $description = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayHasKey', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @param $key
|
||||
* @param $actual
|
||||
* @param $description
|
||||
* @see \Codeception\Module\Asserts::assertArrayNotHasKey()
|
||||
*/
|
||||
public function assertArrayNotHasKey($key, $actual, $description = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArrayNotHasKey', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @param $expectedCount
|
||||
* @param $actual
|
||||
* @param $description
|
||||
* @see \Codeception\Module\Asserts::assertCount()
|
||||
*/
|
||||
public function assertCount($expectedCount, $actual, $description = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertCount', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @param $class
|
||||
* @param $actual
|
||||
* @param $description
|
||||
* @see \Codeception\Module\Asserts::assertInstanceOf()
|
||||
*/
|
||||
public function assertInstanceOf($class, $actual, $description = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInstanceOf', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @param $class
|
||||
* @param $actual
|
||||
* @param $description
|
||||
* @see \Codeception\Module\Asserts::assertNotInstanceOf()
|
||||
*/
|
||||
public function assertNotInstanceOf($class, $actual, $description = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotInstanceOf', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* @param $type
|
||||
* @param $actual
|
||||
* @param $description
|
||||
* @see \Codeception\Module\Asserts::assertInternalType()
|
||||
*/
|
||||
public function assertInternalType($type, $actual, $description = null) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertInternalType', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
@ -345,4 +436,38 @@ trait UnitTesterActions
|
||||
public function fail($message) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [!] Method is generated. Documentation taken from corresponding module.
|
||||
*
|
||||
* Handles and checks exception called inside callback function.
|
||||
* Either exception class name or exception instance should be provided.
|
||||
*
|
||||
* ```php
|
||||
* <?php
|
||||
* $I->expectException(MyException::class, function() {
|
||||
* $this->doSomethingBad();
|
||||
* });
|
||||
*
|
||||
* $I->expectException(new MyException(), function() {
|
||||
* $this->doSomethingBad();
|
||||
* });
|
||||
* ```
|
||||
* If you want to check message or exception code, you can pass them with exception instance:
|
||||
* ```php
|
||||
* <?php
|
||||
* // will check that exception MyException is thrown with "Don't do bad things" message
|
||||
* $I->expectException(new MyException("Don't do bad things"), function() {
|
||||
* $this->doSomethingBad();
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param $exception string or \Exception
|
||||
* @param $callback
|
||||
* @see \Codeception\Module\Asserts::expectException()
|
||||
*/
|
||||
public function expectException($exception, $callback) {
|
||||
return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args()));
|
||||
}
|
||||
}
|
||||
|
@ -7,8 +7,6 @@
|
||||
class_name: AcceptanceTester
|
||||
modules:
|
||||
enabled:
|
||||
# - PhpBrowser:
|
||||
# url: http://localhost/myapp
|
||||
- \Helper\Acceptance
|
||||
- Cli
|
||||
- Filesystem
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
$I = new AcceptanceTester($scenario);
|
||||
|
||||
$I->wantTo('generate a RESTful controller with short model name');
|
||||
@ -8,12 +8,11 @@ $I->seeFileFound('./app/Http/Controllers/TestsController.php');
|
||||
$I->openFile('./app/Http/Controllers/TestsController.php');
|
||||
$I->seeFileContentsEqual('<?php namespace App\Http\Controllers;
|
||||
|
||||
|
||||
class TestsController extends Controller {
|
||||
|
||||
const MODEL = "App\\Test";
|
||||
const MODEL = "App\\Test";
|
||||
|
||||
use RESTActions;
|
||||
use RESTActions;
|
||||
|
||||
}
|
||||
');
|
||||
@ -26,12 +25,11 @@ $I->seeFileFound('./app/Http/Controllers/CategoriesController.php');
|
||||
$I->openFile('./app/Http/Controllers/CategoriesController.php');
|
||||
$I->seeFileContentsEqual('<?php namespace App\Http\Controllers;
|
||||
|
||||
|
||||
class CategoriesController extends Controller {
|
||||
|
||||
const MODEL = "App\\Models\\Category";
|
||||
const MODEL = "App\\Models\\Category";
|
||||
|
||||
use RESTActions;
|
||||
use RESTActions;
|
||||
|
||||
}
|
||||
');
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
$I = new AcceptanceTester($scenario);
|
||||
|
||||
$I->wantTo('generate model factories without fields');
|
||||
@ -8,7 +8,7 @@ $I->openFile('./database/factories/ModelFactory.php');
|
||||
$I->seeInThisFile('
|
||||
$factory->define(App\Task::class, function ($faker) {
|
||||
return [
|
||||
// Fields here
|
||||
// Fields here
|
||||
];
|
||||
});');
|
||||
$I->writeToFile('./database/factories/ModelFactory.php', "<?php
|
||||
@ -39,10 +39,10 @@ $I->runShellCommand('php artisan wn:factory "App\Task" --fields="title:sentence(
|
||||
$I->seeInShellOutput('App\Task factory generated');
|
||||
$I->openFile('./database/factories/ModelFactory.php');
|
||||
$I->seeInThisFile("
|
||||
'title' => \$faker->sentence(3),
|
||||
'description' => \$faker->paragraph(3),
|
||||
'due' => \$faker->date,
|
||||
'hidden' => \$faker->boolean,
|
||||
'title' => \$faker->sentence(3),
|
||||
'description' => \$faker->paragraph(3),
|
||||
'due' => \$faker->date,
|
||||
'hidden' => \$faker->boolean,
|
||||
");
|
||||
$I->writeToFile('./database/factories/ModelFactory.php', "<?php
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
$I = new AcceptanceTester($scenario);
|
||||
|
||||
$I->wantTo('generate a migration without schema');
|
||||
@ -13,7 +13,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateTasksTable extends Migration
|
||||
{
|
||||
|
||||
|
||||
public function up()
|
||||
{
|
||||
Schema::create(\'tasks\', function(Blueprint $table) {
|
||||
@ -44,7 +44,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateTasksTable extends Migration
|
||||
{
|
||||
|
||||
|
||||
public function up()
|
||||
{
|
||||
Schema::create(\'tasks\', function(Blueprint $table) {
|
||||
@ -72,8 +72,8 @@ $I->openFile('./database/migrations/create_tasks.php');
|
||||
$I->seeInThisFile('$table->foreign(\'category_type_id\')
|
||||
->references(\'id\')
|
||||
->on(\'category_types\');');
|
||||
$I->seeInThisFile('$table->foreign(\'user_id\')
|
||||
->references(\'identifier\')
|
||||
->on(\'members\')
|
||||
->onDelete(\'cascade\');');
|
||||
$I->seeInThisFile("\$table->foreign('user_id')
|
||||
->references('identifier')
|
||||
->on('members')
|
||||
->onDelete('cascade');");
|
||||
$I->deleteFile('./database/migrations/create_tasks.php');
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
$I = new AcceptanceTester($scenario);
|
||||
|
||||
$I->wantTo('generate a model without fillable fields or dates');
|
||||
@ -13,15 +13,15 @@ use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TestingModel extends Model {
|
||||
|
||||
protected $fillable = [];
|
||||
protected $fillable = [];
|
||||
|
||||
protected $dates = [];
|
||||
protected $dates = [];
|
||||
|
||||
public static $rules = [
|
||||
// Validation rules
|
||||
];
|
||||
public static $rules = [
|
||||
// Validation rules
|
||||
];
|
||||
|
||||
// Relationships
|
||||
// Relationships
|
||||
|
||||
}
|
||||
');
|
||||
@ -43,22 +43,22 @@ $I->runShellCommand('php artisan wn:model TestingModel --has-many=accounts --bel
|
||||
$I->seeFileFound('./tests/tmp/TestingModel.php');
|
||||
$I->openFile('./tests/tmp/TestingModel.php');
|
||||
$I->seeInThisFile('
|
||||
public function accounts()
|
||||
{
|
||||
return $this->hasMany("Tests\\Tmp\\Account");
|
||||
}
|
||||
public function accounts()
|
||||
{
|
||||
return $this->hasMany("Tests\\Tmp\\Account");
|
||||
}
|
||||
');
|
||||
$I->seeInThisFile('
|
||||
public function owner()
|
||||
{
|
||||
return $this->belongsTo("App\\User");
|
||||
}
|
||||
public function owner()
|
||||
{
|
||||
return $this->belongsTo("App\\User");
|
||||
}
|
||||
');
|
||||
$I->seeInThisFile('
|
||||
public function number()
|
||||
{
|
||||
return $this->hasOne("Tests\\Tmp\\Phone");
|
||||
}
|
||||
public function number()
|
||||
{
|
||||
return $this->hasOne("Tests\\Tmp\\Phone");
|
||||
}
|
||||
');
|
||||
|
||||
$I->wantTo('generate a model with validation rules');
|
||||
@ -66,11 +66,11 @@ $I->runShellCommand('php artisan wn:model TestingModel --rules="name=required ag
|
||||
$I->seeFileFound('./tests/tmp/TestingModel.php');
|
||||
$I->openFile('./tests/tmp/TestingModel.php');
|
||||
$I->seeInThisFile('
|
||||
public static $rules = [
|
||||
"name" => "required",
|
||||
"age" => "integer|min:13",
|
||||
"email" => "email|unique:users,email_address",
|
||||
];
|
||||
public static $rules = [
|
||||
"name" => "required",
|
||||
"age" => "integer|min:13",
|
||||
"email" => "email|unique:users,email_address",
|
||||
];
|
||||
');
|
||||
|
||||
$I->deleteFile('./tests/tmp/TestingModel.php');
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
$I = new AcceptanceTester($scenario);
|
||||
|
||||
$I->wantTo('generate a pivot table seeder');
|
||||
@ -13,16 +13,16 @@ class ShortTagTaskTableSeeder extends Seeder
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
\$faker = Faker::create();
|
||||
\$faker = Faker::create();
|
||||
|
||||
\$firstIds = DB::table('short_tags')->lists('id');
|
||||
\$secondIds = DB::table('tasks')->lists('id');
|
||||
\$firstIds = DB::table('short_tags')->lists('id');
|
||||
\$secondIds = DB::table('tasks')->lists('id');
|
||||
|
||||
for(\$i = 0; \$i < 10; \$i++) {
|
||||
DB::table('short_tag_task')->insert([
|
||||
'short_tag_id' => \$faker->randomElement(\$firstIds),
|
||||
'task_id' => \$faker->randomElement(\$secondIds)
|
||||
]);
|
||||
DB::table('short_tag_task')->insert([
|
||||
'short_tag_id' => \$faker->randomElement(\$firstIds),
|
||||
'task_id' => \$faker->randomElement(\$secondIds)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}");
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
$I = new AcceptanceTester($scenario);
|
||||
|
||||
$I->wantTo('generate a pivot table');
|
||||
@ -13,7 +13,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateProjectTagTable extends Migration
|
||||
{
|
||||
|
||||
|
||||
public function up()
|
||||
{
|
||||
Schema::create(\'project_tag\', function(Blueprint $table) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
$I = new AcceptanceTester($scenario);
|
||||
|
||||
$I->wantTo('generate a RESTful resource');
|
||||
@ -14,30 +14,30 @@ $I->seeInThisFile('class TaskCategory extends Model');
|
||||
$I->seeInThisFile('protected $fillable = ["name", "descr", "due", "project_id", "user_id"];');
|
||||
$I->seeInThisFile('protected $dates = ["due"];');
|
||||
$I->seeInThisFile('public static $rules = [
|
||||
"name" => "requied",
|
||||
"project_id" => "required|numeric",
|
||||
"user_id" => "required|numeric",
|
||||
];');
|
||||
"name" => "requied",
|
||||
"project_id" => "required|numeric",
|
||||
"user_id" => "required|numeric",
|
||||
];');
|
||||
$I->seeInThisFile('
|
||||
public function tags()
|
||||
{
|
||||
return $this->hasMany("App\Tag");
|
||||
}
|
||||
public function tags()
|
||||
{
|
||||
return $this->hasMany("App\Tag");
|
||||
}
|
||||
|
||||
public function tasks()
|
||||
{
|
||||
return $this->hasMany("App\Task");
|
||||
}
|
||||
public function tasks()
|
||||
{
|
||||
return $this->hasMany("App\Task");
|
||||
}
|
||||
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo("App\Project");
|
||||
}
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo("App\Project");
|
||||
}
|
||||
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo("App\User");
|
||||
}');
|
||||
public function creator()
|
||||
{
|
||||
return $this->belongsTo("App\User");
|
||||
}');
|
||||
$I->deleteFile('./app/TaskCategory.php');
|
||||
|
||||
// Checking the migration
|
||||
@ -75,9 +75,9 @@ $I->openFile('./app/Http/Controllers/TaskCategoriesController.php');
|
||||
|
||||
$I->seeInThisFile('class TaskCategoriesController extends Controller {
|
||||
|
||||
const MODEL = "App\TaskCategory";
|
||||
const MODEL = "App\TaskCategory";
|
||||
|
||||
use RESTActions;
|
||||
use RESTActions;
|
||||
|
||||
}');
|
||||
|
||||
@ -117,9 +117,9 @@ $I->openFile('./database/factories/ModelFactory.php');
|
||||
// */
|
||||
// \$factory->define(App\TaskCategory::class, function (\$faker) {
|
||||
// return [
|
||||
// 'name' => \$faker->word,
|
||||
// 'descr' => \$faker->paragraph,
|
||||
// 'due' => \$faker->date,
|
||||
// 'name' => \$faker->word,
|
||||
// 'descr' => \$faker->paragraph,
|
||||
// 'due' => \$faker->date,
|
||||
// ];
|
||||
// });");
|
||||
$I->writeToFile('./database/factories/ModelFactory.php', "<?php
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
$I = new AcceptanceTester($scenario);
|
||||
|
||||
$I->wantTo('generate RESTful routes for a resource with default controller');
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
$I = new AcceptanceTester($scenario);
|
||||
|
||||
$I->wantTo('generate a seeder with default options');
|
||||
|
17
lumen-test/tests/tmp/TestingModel.php
Normal file
17
lumen-test/tests/tmp/TestingModel.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php namespace Tests\Tmp;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class TestingModel extends Model
|
||||
{
|
||||
protected $fillable = [];
|
||||
|
||||
protected $dates = [];
|
||||
|
||||
public static $rules = [
|
||||
// Validation rules
|
||||
];
|
||||
|
||||
// Relationships
|
||||
|
||||
}
|
@ -56,10 +56,10 @@ class FactoryCommand extends BaseCommand {
|
||||
}
|
||||
$content = implode(PHP_EOL, $content);
|
||||
} else {
|
||||
$content = "\t\t// Fields here";
|
||||
$content = " // Fields here";
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -55,10 +55,10 @@ class ModelCommand extends BaseCommand {
|
||||
{
|
||||
return str_replace(' ', '\\', ucwords(str_replace('/', ' ', $this->option('path'))));
|
||||
}
|
||||
|
||||
|
||||
protected function getRelations()
|
||||
{
|
||||
$relations = array_merge([],
|
||||
$relations = array_merge([],
|
||||
$this->getRelationsByType('hasOne', 'has-one'),
|
||||
$this->getRelationsByType('hasMany', 'has-many'),
|
||||
$this->getRelationsByType('belongsTo', 'belongs-to'),
|
||||
@ -66,7 +66,7 @@ class ModelCommand extends BaseCommand {
|
||||
);
|
||||
|
||||
if(empty($relations)){
|
||||
return "\t// Relationships";
|
||||
return " // Relationships";
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $relations);
|
||||
@ -79,7 +79,7 @@ class ModelCommand extends BaseCommand {
|
||||
if($option){
|
||||
|
||||
$items = $this->getArgumentParser('relations')->parse($option);
|
||||
|
||||
|
||||
$template = ($withTimestamps) ? 'model/relation-with-timestamps' : 'model/relation';
|
||||
$template = $this->getTemplate($template);
|
||||
foreach ($items as $item) {
|
||||
@ -99,7 +99,7 @@ class ModelCommand extends BaseCommand {
|
||||
{
|
||||
$rules = $this->option('rules');
|
||||
if(! $rules){
|
||||
return "\t\t// Validation rules";
|
||||
return " // Validation rules";
|
||||
}
|
||||
$items = $rules;
|
||||
if(! $this->option('parsed')){
|
||||
@ -113,5 +113,5 @@ class ModelCommand extends BaseCommand {
|
||||
|
||||
return implode(PHP_EOL, $rules);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
|
||||
class {{name}} extends Controller
|
||||
{
|
||||
class {{name}} extends Controller {
|
||||
|
||||
const MODEL = "{{model}}";
|
||||
|
||||
use RESTActions;
|
||||
|
@ -5,7 +5,7 @@ use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class {{name}}Table extends Migration
|
||||
{
|
||||
|
||||
|
||||
public function up()
|
||||
{
|
||||
Schema::create('{{table}}', function(Blueprint $table) {
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class {{name}} extends Model
|
||||
{
|
||||
class {{name}} extends Model {
|
||||
|
||||
protected $fillable = [{{fillable}}];
|
||||
|
||||
protected $dates = [{{dates}}];
|
||||
|
Loading…
x
Reference in New Issue
Block a user