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
7176ec2a
Unverified
Commit
7176ec2a
authored
5 years ago
by
Seamus Lee
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #14321 from eileenmcnaughton/test_dbunit
#980
[dbunit] remove dependency on discontinued dbunit
parents
1ab29eeb
8fee8f1c
Branches
5.65
Tags
5.65.2
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/fixtures/contacts.yaml
+10
-50
10 additions, 50 deletions
tests/fixtures/contacts.yaml
tests/phpunit/CiviTest/CiviUnitTestCase.php
+23
-6
23 additions, 6 deletions
tests/phpunit/CiviTest/CiviUnitTestCase.php
with
33 additions
and
56 deletions
tests/fixtures/contacts.yaml
+
10
−
50
View file @
7176ec2a
...
...
@@ -3,14 +3,13 @@ civicrm_contact:
id
:
3
contact_type
:
Individual
contact_sub_type
:
do_not_email
:
do_not_phone
:
do_not_mail
:
do_not_sms
:
do_not_trade
:
do_not_email
:
0
do_not_phone
:
0
do_not_mail
:
0
do_not_sms
:
0
do_not_trade
:
0
is_opt_out
:
0
legal_identifier
:
external_identifier
:
sort_name
:
Site Administrator
display_name
:
Site Administrator
nick_name
:
...
...
@@ -24,38 +23,18 @@ civicrm_contact:
first_name
:
Site
middle_name
:
last_name
:
Administrator
prefix_id
:
suffix_id
:
email_greeting_id
:
email_greeting_custom
:
postal_greeting_id
:
postal_greeting_custom
:
addressee_id
:
addressee_custom
:
job_title
:
gender_id
:
birth_date
:
is_deceased
:
deceased_date
:
household_name
:
primary_contact_id
:
organization_name
:
sic_code
:
user_unique_id
:
employer_id
:
-
id
:
17
contact_type
:
Individual
contact_sub_type
:
do_not_email
:
do_not_phone
:
do_not_mail
:
do_not_sms
:
do_not_trade
:
do_not_email
:
0
do_not_phone
:
0
do_not_mail
:
0
do_not_sms
:
0
do_not_trade
:
0
is_opt_out
:
0
legal_identifier
:
external_identifier
:
sort_name
:
display_name
:
Test Contact
nick_name
:
...
...
@@ -69,22 +48,3 @@ civicrm_contact:
first_name
:
Test
middle_name
:
last_name
:
Contact
prefix_id
:
suffix_id
:
email_greeting_id
:
email_greeting_custom
:
postal_greeting_id
:
postal_greeting_custom
:
addressee_id
:
addressee_custom
:
job_title
:
gender_id
:
birth_date
:
is_deceased
:
0
deceased_date
:
household_name
:
primary_contact_id
:
organization_name
:
sic_code
:
user_unique_id
:
employer_id
:
This diff is collapsed.
Click to expand it.
tests/phpunit/CiviTest/CiviUnitTestCase.php
+
23
−
6
View file @
7176ec2a
...
...
@@ -27,6 +27,7 @@
*/
use
Civi\Payment\System
;
use
Symfony\Component\Yaml\Yaml
;
/**
* Include class definitions
...
...
@@ -371,17 +372,33 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
public
function
loadAllFixtures
()
{
$fixturesDir
=
__DIR__
.
'/../../fixtures'
;
$this
->
getConnection
()
->
getConnection
()
->
q
uery
(
"SET FOREIGN_KEY_CHECKS = 0;"
);
CRM_Core_DAO
::
executeQ
uery
(
"SET FOREIGN_KEY_CHECKS = 0;"
);
$yamlFiles
=
glob
(
$fixturesDir
.
'/*.yaml'
);
foreach
(
$yamlFiles
as
$yamlFixture
)
{
$op
=
new
PHPUnit_Extensions_Database_Operation_Insert
();
$dataset
=
new
PHPUnit_Extensions_Database_DataSet_YamlDataSet
(
$yamlFixture
);
$this
->
_tablesToTruncate
=
array_merge
(
$this
->
_tablesToTruncate
,
$dataset
->
getTableNames
());
$op
->
execute
(
$this
->
_dbconn
,
$dataset
);
$yaml
=
Yaml
::
parse
(
file_get_contents
(
$yamlFixture
));
foreach
(
$yaml
as
$tableName
=>
$vars
)
{
if
(
$tableName
===
'civicrm_contact'
)
{
CRM_Core_DAO
::
executeQuery
(
'DELETE c FROM civicrm_contact c LEFT JOIN civicrm_domain d ON d.contact_id = c.id WHERE d.id IS NULL'
);
}
else
{
CRM_Core_DAO
::
executeQuery
(
"TRUNCATE
$tableName
"
);
}
foreach
(
$vars
as
$entity
)
{
$keys
=
$values
=
[];
foreach
(
$entity
as
$key
=>
$value
)
{
$keys
[]
=
$key
;
$values
[]
=
is_numeric
(
$value
)
?
$value
:
"'
{
$value
}
'"
;
}
CRM_Core_DAO
::
executeQuery
(
"
INSERT INTO
$tableName
("
.
implode
(
','
,
$keys
)
.
') VALUES('
.
implode
(
','
,
$values
)
.
')'
);
}
}
}
$this
->
getConnection
()
->
getConnection
()
->
q
uery
(
"SET FOREIGN_KEY_CHECKS = 1;"
);
CRM_Core_DAO
::
executeQ
uery
(
"SET FOREIGN_KEY_CHECKS = 1;"
);
}
/**
...
...
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