Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ Your module controllers (by default go into the `Http/Controllers` folder) shoul
## Creating Modules
To create a new module, you can use the artisan command
```
php artisan modules:make {id} {name} [--url={url}]
php artisan modules:make {id} [{name}] [--url={url}]
```
Values of `id`, `name`, and `url` are strings, and the URL part is optional and will be used to generate make the
URLs of the module more human friendly.
Values of `id`, `name`, and `url` are strings. The name and URL parts are optional. URL will be used to generate the
URLs of the module more human friendly. Name is used for human identification and readability only.
This command will create the basic folder structure inside the modules folder, along with the base module and a sample
routes (inside `Http/routes.php`), controller (inside `Http/Controllers/`), and view (inside `Views`).
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/MakeModule.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MakeModule extends \Illuminate\Console\Command implements SelfHandling {

protected $signature = 'make:module
{id : the ID of the module. Should be unique across modules}
{name : the display name of the module}
{name? : the display name of the module}
{--url= : the URL/route-names part for the module}
';
protected $description = 'Makes a new module';
Expand All @@ -36,7 +36,7 @@ public function __construct(Filesystem $fileSystem) {
public function handle() {
//input
$id = $this->argument('id');
$name = $this->argument('name');
$name = $this->argument('name') ? : $id;
$url = $this->option('url') ?: str_slug($id);

//subs
Expand Down
8 changes: 8 additions & 0 deletions tests/Cases/MakeModuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public function testSimpleCommand()
$this->assertEquals(\App\Modules\Test\Module::make()->routePrefix(), "test");
}

public function testDefaultValues()
{
$this->artisan('make:module', ["id" => "Test2"]);
$this->loadModuleFiles("Test2");
$this->assertEquals(\App\Modules\Test2\Module::make()->id(), "Test2");
$this->assertEquals(\App\Modules\Test2\Module::make()->name(), "Test2");
}

public function testCompoundName()
{
$this->artisan('make:module', ["id" => "TestModule", "name" => "Test Module"]);
Expand Down
6 changes: 3 additions & 3 deletions tests/codeCoverage/Commands/InitiateDatabaseTable.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@
<tr><td><div align="right"><a name="17"></a><a href="#17">17</a></div></td><td class="codeLine"><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span></td></tr>
<tr><td><div align="right"><a name="18"></a><a href="#18">18</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">public</span><span class="default">&nbsp;</span><span class="keyword">function</span><span class="default">&nbsp;</span><span class="default">__construct</span><span class="keyword">(</span><span class="keyword">)</span></td></tr>
<tr><td><div align="right"><a name="19"></a><a href="#19">19</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">{</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="10 tests cover line 20" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ControllerTest::testController&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ControllerTest::testInvalidControllers&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\GenericTest::testModulesServiceProvider&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\GenericTest::testDeletedModuleFiles&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testSimpleCommand&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testCompoundName&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testCustomUrl&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ModulePropertiesTest::testModuleProperties&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\StoreHandlersTest::testDummyStoreHandler&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\StoreHandlersTest::testSimpleDbStoreHandler&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="20"></a><a href="#20">20</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">parent</span><span class="default">::</span><span class="default">__construct</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="10 tests cover line 21" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ControllerTest::testController&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ControllerTest::testInvalidControllers&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\GenericTest::testModulesServiceProvider&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\GenericTest::testDeletedModuleFiles&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testSimpleCommand&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testCompoundName&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testCustomUrl&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ModulePropertiesTest::testModuleProperties&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\StoreHandlersTest::testDummyStoreHandler&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\StoreHandlersTest::testSimpleDbStoreHandler&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="21"></a><a href="#21">21</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="11 tests cover line 20" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ControllerTest::testController&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ControllerTest::testInvalidControllers&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\GenericTest::testModulesServiceProvider&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\GenericTest::testDeletedModuleFiles&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testSimpleCommand&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testDefaultValues&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testCompoundName&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testCustomUrl&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ModulePropertiesTest::testModuleProperties&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\StoreHandlersTest::testDummyStoreHandler&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\StoreHandlersTest::testSimpleDbStoreHandler&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="20"></a><a href="#20">20</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="default">parent</span><span class="default">::</span><span class="default">__construct</span><span class="keyword">(</span><span class="keyword">)</span><span class="keyword">;</span></td></tr>
<tr class="covered-by-large-tests popin" data-title="11 tests cover line 21" data-content="&lt;ul&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ControllerTest::testController&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ControllerTest::testInvalidControllers&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\GenericTest::testModulesServiceProvider&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\GenericTest::testDeletedModuleFiles&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testSimpleCommand&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testDefaultValues&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testCompoundName&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\MakeModuleTest::testCustomUrl&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\ModulePropertiesTest::testModuleProperties&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\StoreHandlersTest::testDummyStoreHandler&lt;/li&gt;&lt;li class=&quot;covered-by-large-tests&quot;&gt;ItvisionSy\Laravel\Modules\Tests\Cases\StoreHandlersTest::testSimpleDbStoreHandler&lt;/li&gt;&lt;/ul&gt;" data-placement="bottom" data-html="true"><td><div align="right"><a name="21"></a><a href="#21">21</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="keyword">}</span></td></tr>
<tr><td><div align="right"><a name="22"></a><a href="#22">22</a></div></td><td class="codeLine"></td></tr>
<tr><td><div align="right"><a name="23"></a><a href="#23">23</a></div></td><td class="codeLine"><span class="default">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="comment">/**</span></td></tr>
<tr><td><div align="right"><a name="24"></a><a href="#24">24</a></div></td><td class="codeLine"><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;Execute&nbsp;the&nbsp;command.</span></td></tr>
Expand Down Expand Up @@ -199,7 +199,7 @@ <h4>Legend</h4>
<span class="warning"><strong>Dead Code</strong></span>
</p>
<p>
<small>Generated by <a href="https://github.com/sebastianbergmann/php-code-coverage" target="_top">php-code-coverage 4.0.7</a> using <a href="https://secure.php.net/" target="_top">PHP 5.6.29</a> with <a href="https://xdebug.org/">Xdebug 2.2.5</a> and <a href="https://phpunit.de/">PHPUnit 5.7.16</a> at Sun Apr 2 11:20:54 UTC 2017.</small>
<small>Generated by <a href="https://github.com/sebastianbergmann/php-code-coverage" target="_top">php-code-coverage 4.0.7</a> using <a href="https://secure.php.net/" target="_top">PHP 5.6.29</a> with <a href="https://xdebug.org/">Xdebug 2.2.5</a> and <a href="https://phpunit.de/">PHPUnit 5.7.16</a> at Sun Apr 9 8:41:16 UTC 2017.</small>
</p>
<a title="Back to the top" id="toplink" href="#"><span class="glyphicon glyphicon-arrow-up"></span></a>
</footer>
Expand Down
Loading