Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
PSDI Army
yii2
Commits
59a52d88
Commit
59a52d88
authored
Aug 01, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #4556: Gii was incorrectly generating labels
parent
c1cf48cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
Generator.php
extensions/gii/generators/model/Generator.php
+1
-1
GeneratorsTest.php
tests/unit/extensions/gii/GeneratorsTest.php
+6
-1
No files found.
extensions/gii/generators/model/Generator.php
View file @
59a52d88
...
...
@@ -197,7 +197,7 @@ class Generator extends \yii\gii\Generator
$labels
[
$column
->
name
]
=
'ID'
;
}
else
{
$label
=
Inflector
::
camel2words
(
$column
->
name
);
if
(
!
empty
(
$label
)
&&
substr_compare
(
$label
,
' id'
,
-
3
,
3
,
true
))
{
if
(
!
empty
(
$label
)
&&
substr_compare
(
$label
,
' id'
,
-
3
,
3
,
true
)
===
0
)
{
$label
=
substr
(
$label
,
0
,
-
3
)
.
' ID'
;
}
$labels
[
$column
->
name
]
=
$label
;
...
...
tests/unit/extensions/gii/GeneratorsTest.php
View file @
59a52d88
<?php
namespace
yiiunit\extensions\gii
;
use
yii\gii\CodeFile
;
use
yii\gii\generators\controller\Generator
as
ControllerGenerator
;
use
yii\gii\generators\crud\Generator
as
CRUDGenerator
;
use
yii\gii\generators\extension\Generator
as
ExtensionGenerator
;
...
...
@@ -53,7 +54,11 @@ class GeneratorsTest extends GiiTestCase
$generator
->
modelClass
=
'Profile'
;
if
(
$generator
->
validate
())
{
$generator
->
generate
();
$files
=
$generator
->
generate
();
$modelCode
=
$files
[
0
]
->
content
;
$this
->
assertTrue
(
strpos
(
$modelCode
,
"'id' => 'ID'"
)
!==
false
,
"ID label should be there:
\n
"
.
$modelCode
);
$this
->
assertTrue
(
strpos
(
$modelCode
,
"'description' => 'Description',"
)
!==
false
,
"Description label should be there:
\n
"
.
$modelCode
);
}
else
{
print_r
(
$generator
->
getErrors
());
}
...
...
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