Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
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
Tomáš Trávníček
doctrine-dbal
Commits
1b23da2b
Commit
1b23da2b
authored
Sep 02, 2007
by
meus
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented -group and -filter checks to the command line testrunner
parent
42e76aa7
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
12 deletions
+48
-12
Test.php
tests/Test.php
+18
-2
run.php
tests/run.php
+30
-10
No files found.
tests/Test.php
View file @
1b23da2b
...
...
@@ -19,11 +19,27 @@ class GroupTest extends UnitTestCase
}
}
public
function
run
(
HtmlReporter
$reporter
)
public
function
shouldBeRun
(
$testCase
,
$filter
){
if
(
!
is_array
(
$filter
)){
return
true
;
}
foreach
(
$filter
as
$subFilter
){
$name
=
strtolower
(
get_class
(
$testCase
));
$pos
=
strpos
(
$name
,
strtolower
(
$subFilter
));
//it can be 0 so we have to use === to see if false
if
(
$pos
===
false
){
return
false
;
}
}
return
true
;
}
public
function
run
(
HtmlReporter
$reporter
,
$filter
)
{
$reporter
->
paintHeader
();
foreach
(
$this
->
_testCases
as
$k
=>
$testCase
)
{
if
(
!
$this
->
shouldBeRun
(
$testCase
,
$filter
))
{
continue
;
}
$testCase
->
run
();
$this
->
_passed
+=
$testCase
->
getPassCount
();
$this
->
_failed
+=
$testCase
->
getFailCount
();
...
...
tests/run.php
View file @
1b23da2b
...
...
@@ -2,6 +2,25 @@
ini_set
(
'max_execution_time'
,
900
);
function
parseOptions
(
$array
)
{
$currentName
=
""
;
$options
=
array
();
foreach
(
$array
as
$name
){
if
(
strpos
(
$name
,
"-"
)
===
0
)
{
$name
=
str_replace
(
"-"
,
""
,
$name
);
$currentName
=
$name
;
if
(
!
isset
(
$options
[
$currentName
]))
{
$options
[
$currentName
]
=
array
();
}
}
else
{
$values
=
$options
[
$currentName
];
array_push
(
$values
,
$name
);
$options
[
$currentName
]
=
$values
;
}
}
return
$options
;
}
function
autoload
(
$class
)
{
if
(
strpos
(
$class
,
'TestCase'
)
===
false
)
{
return
false
;
...
...
@@ -424,15 +443,11 @@ if (PHP_SAPI === "cli") {
$argv
=
$_SERVER
[
"argv"
];
array_shift
(
$argv
);
$coverage
=
false
;
if
(
isset
(
$argv
[
0
])
&&
$argv
[
0
]
==
"coverage"
){
array_shift
(
$argv
);
$coverage
=
true
;
}
$options
=
parseOptions
(
$argv
);
if
(
!
empty
(
$argv
))
{
if
(
isset
(
$options
[
"group"
]
))
{
$testGroup
=
new
GroupTest
(
"Custom"
);
foreach
(
$
argv
as
$group
)
{
foreach
(
$
options
[
"group"
]
as
$group
)
{
if
(
!
isset
(
$$group
))
{
if
(
class_exists
(
$group
))
{
$testGroup
->
addTestCase
(
new
$group
);
...
...
@@ -444,13 +459,18 @@ if( ! empty($argv)) {
}
else
{
$testGroup
=
$test
;
}
if
(
$coverage
)
{
$filter
=
""
;
if
(
isset
(
$options
[
"filter"
])){
$filter
=
$options
[
"filter"
];
}
if
(
isset
(
$options
[
"coverage"
]))
{
xdebug_start_code_coverage
(
XDEBUG_CC_UNUSED
|
XDEBUG_CC_DEAD_CODE
);
$testGroup
->
run
(
$reporter
);
$testGroup
->
run
(
$reporter
,
$filter
);
$result
[
"path"
]
=
Doctrine
::
getPath
()
.
DIRECTORY_SEPARATOR
;
$result
[
"coverage"
]
=
xdebug_get_code_coverage
();
xdebug_stop_code_coverage
();
file_put_contents
(
"coverage.txt"
,
serialize
(
$result
));
}
else
{
$testGroup
->
run
(
$reporter
);
$testGroup
->
run
(
$reporter
,
$filter
);
}
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