Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
fe46225f
Commit
fe46225f
authored
Jul 22, 2017
by
Julien Tant
Committed by
Nicolas Widart
Jul 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix broken workshop when module name contains dash (#351)
parent
536535e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
13 deletions
+19
-13
Generator.php
Modules/Workshop/Scaffold/Module/Generators/Generator.php
+2
-1
ModuleScaffoldTest.php
Modules/Workshop/Tests/ModuleScaffoldTest.php
+17
-12
No files found.
Modules/Workshop/Scaffold/Module/Generators/Generator.php
View file @
fe46225f
...
...
@@ -5,6 +5,7 @@ namespace Modules\Workshop\Scaffold\Module\Generators;
use
Illuminate\Contracts\Config\Repository
;
use
Illuminate\Contracts\Filesystem\FileNotFoundException
;
use
Illuminate\Filesystem\Filesystem
;
use
Illuminate\Support\Str
;
abstract
class
Generator
{
...
...
@@ -45,7 +46,7 @@ abstract class Generator
*/
public
function
forModule
(
$moduleName
)
{
$this
->
name
=
$moduleName
;
$this
->
name
=
Str
::
studly
(
$moduleName
)
;
return
$this
;
}
...
...
Modules/Workshop/Tests/ModuleScaffoldTest.php
View file @
fe46225f
...
...
@@ -23,11 +23,16 @@ class ModuleScaffoldTest extends BaseTestCase
* @var string The name of the module under test
*/
protected
$testModuleName
;
/**
* @var string The sanitized name of the module under test
*/
protected
$testModuleSanitizedName
;
public
function
setUp
()
{
$this
->
testModuleName
=
'TestingTestModule'
;
$this
->
testModulePath
=
__DIR__
.
"/../Modules/
{
$this
->
testModuleName
}
"
;
$this
->
testModuleName
=
'Testing_The-TestModule'
;
$this
->
testModuleSanitizedName
=
'TestingTheTestModule'
;
$this
->
testModulePath
=
__DIR__
.
"/../Modules/
{
$this
->
testModuleSanitizedName
}
"
;
$this
->
cleanUp
();
parent
::
setUp
();
...
...
@@ -256,7 +261,7 @@ class ModuleScaffoldTest extends BaseTestCase
$this
->
scaffoldModuleWithEloquent
();
$file1
=
$this
->
finder
->
isFile
(
$this
->
testModulePath
.
'/Providers/RouteServiceProvider.php'
);
$file2
=
$this
->
finder
->
isFile
(
$this
->
testModulePath
.
"/Providers/
{
$this
->
testModuleName
}
ServiceProvider.php"
);
$file2
=
$this
->
finder
->
isFile
(
$this
->
testModulePath
.
"/Providers/
{
$this
->
testModule
Sanitized
Name
}
ServiceProvider.php"
);
$this
->
assertTrue
(
$file1
);
$this
->
assertTrue
(
$file2
);
...
...
@@ -269,9 +274,9 @@ class ModuleScaffoldTest extends BaseTestCase
{
$this
->
scaffoldModuleWithEloquent
();
$file
=
$this
->
finder
->
get
(
$this
->
testModulePath
.
"/Providers/
{
$this
->
testModuleName
}
ServiceProvider.php"
);
$file
=
$this
->
finder
->
get
(
$this
->
testModulePath
.
"/Providers/
{
$this
->
testModule
Sanitized
Name
}
ServiceProvider.php"
);
$sidebarEventListenerName
=
"Register
{
$this
->
testModuleName
}
Sidebar"
;
$sidebarEventListenerName
=
"Register
{
$this
->
testModule
Sanitized
Name
}
Sidebar"
;
$this
->
assertTrue
(
str_contains
(
$file
,
'$this->loadMigrationsFrom(__DIR__ . \'/../Database/Migrations\');'
...
...
@@ -330,7 +335,7 @@ class ModuleScaffoldTest extends BaseTestCase
{
$this
->
scaffoldModuleWithEloquent
();
$file
=
$this
->
finder
->
isFile
(
$this
->
testModulePath
.
'/Events/Handlers/RegisterTestingTestModuleSidebar.php'
);
$file
=
$this
->
finder
->
isFile
(
$this
->
testModulePath
.
"/Events/Handlers/Register
{
$this
->
testModuleSanitizedName
}
Sidebar.php"
);
$this
->
assertTrue
(
$file
);
...
...
@@ -342,10 +347,10 @@ class ModuleScaffoldTest extends BaseTestCase
{
$this
->
scaffoldModuleWithEloquent
();
$file
=
$this
->
finder
->
get
(
$this
->
testModulePath
.
'/Events/Handlers/RegisterTestingTestModuleSidebar.php'
);
$file
=
$this
->
finder
->
get
(
$this
->
testModulePath
.
"/Events/Handlers/Register
{
$this
->
testModuleSanitizedName
}
Sidebar.php"
);
$this
->
assertTrue
(
str_contains
(
$file
,
'$menu->group'
));
$this
->
assertTrue
(
str_contains
(
$file
,
'class RegisterTestingTestModuleSidebar'
));
$this
->
assertTrue
(
str_contains
(
$file
,
"class Register
{
$this
->
testModuleSanitizedName
}
Sidebar"
));
$this
->
cleanUp
();
}
...
...
@@ -355,7 +360,7 @@ class ModuleScaffoldTest extends BaseTestCase
{
$this
->
scaffoldModule
(
'Eloquent'
,
[],
[]);
$file
=
$this
->
finder
->
get
(
$this
->
testModulePath
.
'/Events/Handlers/RegisterTestingTestModuleSidebar.php'
);
$file
=
$this
->
finder
->
get
(
$this
->
testModulePath
.
"/Events/Handlers/Register
{
$this
->
testModuleSanitizedName
}
Sidebar.php"
);
$this
->
assertFalse
(
str_contains
(
$file
,
'$menu->group'
));
$this
->
assertTrue
(
str_contains
(
$file
,
'return $menu'
));
...
...
@@ -427,7 +432,7 @@ class ModuleScaffoldTest extends BaseTestCase
$composerJson
=
$this
->
getComposerFile
();
$this
->
assertEquals
(
'asgardcms/testingtestmodule'
,
$composerJson
->
name
);
$this
->
assertEquals
(
'asgardcms/testingt
het
estmodule'
,
$composerJson
->
name
);
}
/** @test */
...
...
@@ -513,7 +518,7 @@ class ModuleScaffoldTest extends BaseTestCase
$this
->
scaffoldModuleWithEloquent
([
'Post'
]);
$controllerContents
=
$this
->
getAdminControllerFile
(
'Post'
);
$lowercaseModuleName
=
strtolower
(
$this
->
testModuleName
);
$lowercaseModuleName
=
strtolower
(
$this
->
testModule
Sanitized
Name
);
$matches
=
[
"withSuccess(trans('core::core.messages.resource created', ['name' => trans('
{
$lowercaseModuleName
}
::posts.title.posts')]));"
,
...
...
@@ -578,4 +583,4 @@ class ModuleScaffoldTest extends BaseTestCase
return
$controllerFile
;
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment