Skip to content

Commit

Permalink
show, api route fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sarthaksavvy committed Jul 18, 2019
1 parent 51d0a08 commit acd0c43
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Commands/Crud/AddRouteCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function getRouteFilePath($path)
{
$content = $this->getComposer();
if ($content->type == 'project') {
$path = $path . 'routes/web.php';
$path = $this->option('api') == 'api' ? $path . 'routes/api.php' : $path . 'routes/web.php';
} elseif ($content->type == 'library' || $content->type == 'package') {
$path = $this->packageRoutePath($path);
}
Expand Down
3 changes: 3 additions & 0 deletions app/Commands/Crud/stubs/tests/unit-test.stub
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ namespace DummyNamespace;
use DummyRootNamespaceTestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\DatabaseMigrations;

class DummyClass extends TestCase
{
use DatabaseMigrations;

//Relationships
}
2 changes: 1 addition & 1 deletion app/Commands/Crud/stubs/views/show.stub
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</div>

<div class="card-body">
// to be done
{{ $//FIELD }}
</div>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions app/Commands/Crud/views/ShowMakeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@ protected function replaceNamespace(&$stub, $name)
{
$stub = str_replace(
[
'//FIELD',
'DummyModelName',
'DummyModelLower',
'DummyModelPlural',
'InputFieldsReplacer',
'DummyPackageName::',
],
[
$this->createFirstField(),
$this->argument('name'),
strtolower($this->argument('name')),
Str::plural($this->argument('name')),
Expand All @@ -100,6 +102,13 @@ public function createFields()
return $inputFields;
}

public function createFirstField()
{
$fields = cache()->get('structure')->fields;
$model = strtolower($this->argument('name'));
return "{$model}->{$fields[0]->name}";
}

public function generateFieldStub($field)
{
$stub = file_get_contents(__DIR__ . '/../stubs/views/inputFields/editText.stub');
Expand Down
Binary file modified builds/packer
Binary file not shown.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@
"@php application app:rename"
]
},
"bin": ["builds/packer"]
"bin": ["packer"]
}
35 changes: 35 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>

<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_DRIVER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
</php>
</phpunit>
22 changes: 22 additions & 0 deletions tests/CreatesApplication.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Tests;

use Illuminate\Contracts\Console\Kernel;

trait CreatesApplication
{
/**
* Creates the application.
*
* @return \Illuminate\Foundation\Application
*/
public function createApplication()
{
$app = require __DIR__ . '/../bootstrap/app.php';

$app->make(Kernel::class)->bootstrap();

return $app;
}
}
19 changes: 19 additions & 0 deletions tests/Feature/InspiringCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace Tests\Feature;

use Tests\TestCase;

class InspiringCommandTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testInspiringCommand()
{
$this->artisan('crud:json admin')
->assertExitCode(0);
}
}
10 changes: 10 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Tests;

use LaravelZero\Framework\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
}

0 comments on commit acd0c43

Please sign in to comment.