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
9ff9cab6
Commit
9ff9cab6
authored
Jan 10, 2015
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ensure gii tests fail on error and not just print_r
parent
6f889e12
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
30 deletions
+26
-30
GeneratorsTest.php
tests/unit/extensions/gii/GeneratorsTest.php
+25
-30
GiiTestCase.php
tests/unit/extensions/gii/GiiTestCase.php
+1
-0
No files found.
tests/unit/extensions/gii/GeneratorsTest.php
View file @
9ff9cab6
...
@@ -11,6 +11,7 @@ use yii\gii\generators\module\Generator as ModuleGenerator;
...
@@ -11,6 +11,7 @@ use yii\gii\generators\module\Generator as ModuleGenerator;
/**
/**
* GeneratorsTest checks that Gii generators aren't throwing any errors during generation
* GeneratorsTest checks that Gii generators aren't throwing any errors during generation
* @group gii
*/
*/
class
GeneratorsTest
extends
GiiTestCase
class
GeneratorsTest
extends
GiiTestCase
{
{
...
@@ -18,13 +19,12 @@ class GeneratorsTest extends GiiTestCase
...
@@ -18,13 +19,12 @@ class GeneratorsTest extends GiiTestCase
{
{
$generator
=
new
ControllerGenerator
();
$generator
=
new
ControllerGenerator
();
$generator
->
template
=
'default'
;
$generator
->
template
=
'default'
;
$generator
->
controllerClass
=
'
test
'
;
$generator
->
controllerClass
=
'
app\runtime\TestController
'
;
if
(
$generator
->
validate
())
{
$valid
=
$generator
->
validate
();
$generator
->
generate
();
$this
->
assertTrue
(
$valid
,
'Validation failed: '
.
print_r
(
$generator
->
getErrors
(),
true
));
}
else
{
print_r
(
$generator
->
getErrors
());
$this
->
assertNotEmpty
(
$generator
->
generate
());
}
}
}
public
function
testExtensionGenerator
()
public
function
testExtensionGenerator
()
...
@@ -39,11 +39,10 @@ class GeneratorsTest extends GiiTestCase
...
@@ -39,11 +39,10 @@ class GeneratorsTest extends GiiTestCase
$generator
->
authorName
=
'Alexander Makarov'
;
$generator
->
authorName
=
'Alexander Makarov'
;
$generator
->
authorEmail
=
'sam@rmcreative.ru'
;
$generator
->
authorEmail
=
'sam@rmcreative.ru'
;
if
(
$generator
->
validate
())
{
$valid
=
$generator
->
validate
();
$generator
->
generate
();
$this
->
assertTrue
(
$valid
,
'Validation failed: '
.
print_r
(
$generator
->
getErrors
(),
true
));
}
else
{
print_r
(
$generator
->
getErrors
());
$this
->
assertNotEmpty
(
$generator
->
generate
());
}
}
}
public
function
testModelGenerator
()
public
function
testModelGenerator
()
...
@@ -53,15 +52,14 @@ class GeneratorsTest extends GiiTestCase
...
@@ -53,15 +52,14 @@ class GeneratorsTest extends GiiTestCase
$generator
->
tableName
=
'profile'
;
$generator
->
tableName
=
'profile'
;
$generator
->
modelClass
=
'Profile'
;
$generator
->
modelClass
=
'Profile'
;
if
(
$generator
->
validate
())
{
$valid
=
$generator
->
validate
();
$this
->
assertTrue
(
$valid
,
'Validation failed: '
.
print_r
(
$generator
->
getErrors
(),
true
));
$files
=
$generator
->
generate
();
$files
=
$generator
->
generate
();
$modelCode
=
$files
[
0
]
->
content
;
$modelCode
=
$files
[
0
]
->
content
;
$this
->
assertTrue
(
strpos
(
$modelCode
,
"'id' => 'ID'"
)
!==
false
,
"ID label should be there:
\n
"
.
$modelCode
);
$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
);
$this
->
assertTrue
(
strpos
(
$modelCode
,
"'description' => 'Description',"
)
!==
false
,
"Description label should be there:
\n
"
.
$modelCode
);
}
else
{
print_r
(
$generator
->
getErrors
());
}
}
}
public
function
testModuleGenerator
()
public
function
testModuleGenerator
()
...
@@ -71,11 +69,10 @@ class GeneratorsTest extends GiiTestCase
...
@@ -71,11 +69,10 @@ class GeneratorsTest extends GiiTestCase
$generator
->
moduleID
=
'test'
;
$generator
->
moduleID
=
'test'
;
$generator
->
moduleClass
=
'app\modules\test\Module'
;
$generator
->
moduleClass
=
'app\modules\test\Module'
;
if
(
$generator
->
validate
())
{
$valid
=
$generator
->
validate
();
$generator
->
generate
();
$this
->
assertTrue
(
$valid
,
'Validation failed: '
.
print_r
(
$generator
->
getErrors
(),
true
));
}
else
{
print_r
(
$generator
->
getErrors
());
$this
->
assertNotEmpty
(
$generator
->
generate
());
}
}
}
...
@@ -87,11 +84,10 @@ class GeneratorsTest extends GiiTestCase
...
@@ -87,11 +84,10 @@ class GeneratorsTest extends GiiTestCase
$generator
->
viewName
=
'profile'
;
$generator
->
viewName
=
'profile'
;
$generator
->
viewPath
=
'@yiiunit/runtime'
;
$generator
->
viewPath
=
'@yiiunit/runtime'
;
if
(
$generator
->
validate
())
{
$valid
=
$generator
->
validate
();
$generator
->
generate
();
$this
->
assertTrue
(
$valid
,
'Validation failed: '
.
print_r
(
$generator
->
getErrors
(),
true
));
}
else
{
print_r
(
$generator
->
getErrors
());
$this
->
assertNotEmpty
(
$generator
->
generate
());
}
}
}
public
function
testCRUDGenerator
()
public
function
testCRUDGenerator
()
...
@@ -101,10 +97,9 @@ class GeneratorsTest extends GiiTestCase
...
@@ -101,10 +97,9 @@ class GeneratorsTest extends GiiTestCase
$generator
->
modelClass
=
'yiiunit\extensions\gii\Profile'
;
$generator
->
modelClass
=
'yiiunit\extensions\gii\Profile'
;
$generator
->
controllerClass
=
'app\TestController'
;
$generator
->
controllerClass
=
'app\TestController'
;
if
(
$generator
->
validate
())
{
$valid
=
$generator
->
validate
();
$generator
->
generate
();
$this
->
assertTrue
(
$valid
,
'Validation failed: '
.
print_r
(
$generator
->
getErrors
(),
true
));
}
else
{
print_r
(
$generator
->
getErrors
());
$this
->
assertNotEmpty
(
$generator
->
generate
());
}
}
}
}
}
tests/unit/extensions/gii/GiiTestCase.php
View file @
9ff9cab6
...
@@ -9,6 +9,7 @@ Yii::setAlias('@yii/gii', __DIR__ . '/../../../../extensions/gii');
...
@@ -9,6 +9,7 @@ Yii::setAlias('@yii/gii', __DIR__ . '/../../../../extensions/gii');
/**
/**
* GiiTestCase is the base class for all gii related test cases
* GiiTestCase is the base class for all gii related test cases
* @group gii
*/
*/
class
GiiTestCase
extends
TestCase
class
GiiTestCase
extends
TestCase
{
{
...
...
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