Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
d4c5fe45
Unverified
Commit
d4c5fe45
authored
3 years ago
by
colemanw
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #20448 from eileenmcnaughton/report
Mark test class as having invalid financials
parents
4c2c4780
d5d08fab
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/phpunit/CRM/Report/Form/TestCaseTest.php
+25
-28
25 additions, 28 deletions
tests/phpunit/CRM/Report/Form/TestCaseTest.php
tests/phpunit/CiviTest/CiviReportTestCase.php
+6
-8
6 additions, 8 deletions
tests/phpunit/CiviTest/CiviReportTestCase.php
with
31 additions
and
36 deletions
tests/phpunit/CRM/Report/Form/TestCaseTest.php
+
25
−
28
View file @
d4c5fe45
...
...
@@ -9,8 +9,6 @@
+--------------------------------------------------------------------+
*/
require_once
'CiviTest/CiviReportTestCase.php'
;
use
Civi\Test\Invasive
;
/**
...
...
@@ -32,10 +30,19 @@ class CRM_Report_Form_TestCaseTest extends CiviReportTestCase {
'civicrm_contribution'
,
];
/**
* Financial data used in these tests is invalid - do not validate.
*
* Note ideally it would be fixed and we would always use valid data.
*
* @var bool
*/
protected
$isValidateFinancialsOnPostAssert
=
FALSE
;
/**
* @return array
*/
public
function
dataProvider
()
{
public
function
dataProvider
()
:
array
{
$testCaseA
=
[
'CRM_Report_Form_Contribute_Detail'
,
[
...
...
@@ -69,7 +76,7 @@ class CRM_Report_Form_TestCaseTest extends CiviReportTestCase {
/**
* @return array
*/
public
function
badDataProvider
()
{
public
function
badDataProvider
()
:
array
{
return
[
// This test-case is bad because the dataset-ascii.sql does not match the
// report.csv (due to differences in international chars)
...
...
@@ -115,6 +122,9 @@ class CRM_Report_Form_TestCaseTest extends CiviReportTestCase {
];
}
/**
* @throws \CRM_Core_Exception
*/
public
function
setUp
():
void
{
parent
::
setUp
();
$this
->
quickCleanup
(
$this
->
_tablesToTruncate
);
...
...
@@ -128,54 +138,41 @@ class CRM_Report_Form_TestCaseTest extends CiviReportTestCase {
* @param $expectedOutputCsvFile
* @throws \Exception
*/
public
function
testReportOutput
(
$reportClass
,
$inputParams
,
$dataSet
,
$expectedOutputCsvFile
)
{
public
function
testReportOutput
(
$reportClass
,
$inputParams
,
$dataSet
,
$expectedOutputCsvFile
)
:
void
{
$config
=
CRM_Core_Config
::
singleton
();
CRM_Utils_File
::
sourceSQLFile
(
$config
->
dsn
,
dirname
(
__FILE
__
)
.
"/
{
$dataSet
}
"
);
CRM_Utils_File
::
sourceSQLFile
(
$config
->
dsn
,
__DIR
__
.
"/
$dataSet
"
);
$reportCsvFile
=
$this
->
getReportOutputAsCsv
(
$reportClass
,
$inputParams
);
$reportCsvArray
=
$this
->
getArrayFromCsv
(
$reportCsvFile
);
$expectedOutputCsvArray
=
$this
->
getArrayFromCsv
(
dirname
(
__FILE
__
)
.
"/
{
$expectedOutputCsvFile
}
"
);
$expectedOutputCsvArray
=
$this
->
getArrayFromCsv
(
__DIR
__
.
"/
$expectedOutputCsvFile
"
);
$this
->
assertCsvArraysEqual
(
$expectedOutputCsvArray
,
$reportCsvArray
);
}
/**
* @dataProvider badDataProvider
*
* @param $reportClass
* @param $inputParams
* @param $dataSet
* @param $expectedOutputCsvFile
* @throws \Exception
*
* @throws \CRM_Core_Exception
*/
public
function
testBadReportOutput
(
$reportClass
,
$inputParams
,
$dataSet
,
$expectedOutputCsvFile
)
{
$config
=
CRM_Core_Config
::
singleton
();
CRM_Utils_File
::
sourceSQLFile
(
$config
->
dsn
,
dirname
(
__FILE__
)
.
"/
{
$dataSet
}
"
);
public
function
testBadReportOutput
(
$reportClass
,
$inputParams
,
$dataSet
,
$expectedOutputCsvFile
):
void
{
CRM_Utils_File
::
sourceSQLFile
(
CIVICRM_DSN
,
__DIR__
.
"/
$dataSet
"
);
$reportCsvFile
=
$this
->
getReportOutputAsCsv
(
$reportClass
,
$inputParams
);
$reportCsvArray
=
$this
->
getArrayFromCsv
(
$reportCsvFile
);
$expectedOutputCsvArray
=
$this
->
getArrayFromCsv
(
dirname
(
__FILE__
)
.
"/
{
$expectedOutputCsvFile
}
"
);
try
{
$this
->
assertCsvArraysEqual
(
$expectedOutputCsvArray
,
$reportCsvArray
);
// @todo But...doesn't this mean this test can't ever notify you of a
// fail? I think what you could do instead is right here in the try
// section throw something that doesn't get caught, since then that means
// the previous line passed and so the arrays ARE equal, which means
// something is wrong. Or just don't use assertCsvArraysEqual and
// explicity compare that they are NOT equal.
}
catch
(
PHPUnit\Framework\AssertionFailedError
$e
)
{
/* OK */
}
catch
(
PHPUnit_Framework_AssertionFailedError
$e
)
{
/* OK */
}
$expectedOutputCsvArray
=
$this
->
getArrayFromCsv
(
__DIR__
.
"/
$expectedOutputCsvFile
"
);
$this
->
assertNotEquals
(
$expectedOutputCsvArray
[
1
],
$reportCsvArray
[
1
]);
}
/**
* Test processReportMode() Function in Reports
*/
public
function
testOutputMode
()
{
public
function
testOutputMode
()
:
void
{
$reportForm
=
new
CRM_Report_Form
();
Invasive
::
set
([
$reportForm
,
'_params'
],
[
'groups'
=>
4
]);
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CiviTest/CiviReportTestCase.php
+
6
−
8
View file @
d4c5fe45
...
...
@@ -29,7 +29,7 @@ class CiviReportTestCase extends CiviUnitTestCase {
* @param array $inputParams
*
* @return string
* @throws Exception
* @throws
\CRM_Core_
Exception
*/
public
function
getReportOutputAsCsv
(
$reportClass
,
$inputParams
)
{
...
...
@@ -46,9 +46,9 @@ class CiviReportTestCase extends CiviUnitTestCase {
* @param array $inputParams
*
* @return CRM_Report_Form
* @throws Exception
* @throws
\CRM_Core_
Exception
*/
public
function
getReportObject
(
$reportClass
,
$inputParams
)
{
public
function
getReportObject
(
string
$reportClass
,
array
$inputParams
)
:
CRM_Report_Form
{
$config
=
CRM_Core_Config
::
singleton
();
$config
->
keyDisable
=
TRUE
;
$controller
=
new
CRM_Core_Controller_Simple
(
$reportClass
,
ts
(
'some title'
));
...
...
@@ -81,7 +81,7 @@ class CiviReportTestCase extends CiviUnitTestCase {
$reportObj
->
storeResultSet
();
$reportObj
->
buildForm
();
}
catch
(
Exception
$e
)
{
catch
(
CRM_Core_
Exception
$e
)
{
// print_r($e->getCause()->getUserInfo());
CRM_Utils_GlobalStack
::
singleton
()
->
pop
();
throw
$e
;
...
...
@@ -121,10 +121,8 @@ class CiviReportTestCase extends CiviUnitTestCase {
.
"
\n
===== ACTUAL DATA ====
\n
"
.
$this
->
flattenCsvArray
(
$actualCsvArray
);
$this
->
assertEquals
(
count
(
$actualCsvArray
),
count
(
$expectedCsvArray
),
'Arrays have different number of rows; in line '
.
__LINE__
.
'; data: '
.
$flatData
$this
->
assertCount
(
count
(
$actualCsvArray
),
$expectedCsvArray
,
'Arrays have different number of rows; data: '
.
$flatData
);
foreach
(
$actualCsvArray
as
$intKey
=>
$strVal
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment