Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
justinfreeman (Agileware)
Core
Commits
49e101d0
Commit
49e101d0
authored
11 years ago
by
colemanw
Browse files
Options
Downloads
Patches
Plain Diff
CRM-13807 - Fix last to commit to getBAO and add unit test
parent
d9f036bb
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
api/v3/utils.php
+2
-2
2 additions, 2 deletions
api/v3/utils.php
tests/phpunit/api/v3/UtilsTest.php
+27
-23
27 additions, 23 deletions
tests/phpunit/api/v3/UtilsTest.php
with
29 additions
and
25 deletions
api/v3/utils.php
+
2
−
2
View file @
49e101d0
...
...
@@ -308,8 +308,8 @@ function _civicrm_api3_get_DAO($name) {
function
_civicrm_api3_get_BAO
(
$name
)
{
$dao
=
_civicrm_api3_get_DAO
(
$name
);
$bao
=
str_replace
(
"DAO"
,
"BAO"
,
$dao
);
$file
=
str
_replace
(
'_'
,
'/'
,
$dao
)
.
'.php'
;
return
file_exists
(
$file
)
?
$bao
:
$dao
;
$file
=
str
tr
(
$bao
,
'_'
,
'/'
)
.
'.php'
;
return
stream_resolve_include_path
(
$file
)
?
$bao
:
$dao
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/api/v3/UtilsTest.php
+
27
−
23
View file @
49e101d0
...
...
@@ -175,33 +175,37 @@ class api_v3_UtilsTest extends CiviUnitTestCase {
* Test GET DAO function returns DAO
*/
function
testGetDAO
()
{
$DAO
=
_civicrm_api3_get_DAO
(
'civicrm_api3_custom_group_get'
);
$this
->
assertEquals
(
'CRM_Core_DAO_CustomGroup'
,
$DAO
);
$DAO
=
_civicrm_api3_get_DAO
(
'custom_group'
);
$this
->
assertEquals
(
'CRM_Core_DAO_CustomGroup'
,
$DAO
);
$DAO
=
_civicrm_api3_get_DAO
(
'CustomGroup'
);
$this
->
assertEquals
(
'CRM_Core_DAO_CustomGroup'
,
$DAO
);
$DAO
=
_civicrm_api3_get_DAO
(
'civicrm_api3_custom_field_get'
);
$this
->
assertEquals
(
'CRM_Core_DAO_CustomField'
,
$DAO
);
$DAO
=
_civicrm_api3_get_DAO
(
'civicrm_api3_survey_get'
);
$this
->
assertEquals
(
'CRM_Campaign_DAO_Survey'
,
$DAO
);
$DAO
=
_civicrm_api3_get_DAO
(
'civicrm_api3_pledge_payment_get'
);
$this
->
assertEquals
(
'CRM_Pledge_DAO_PledgePayment'
,
$DAO
);
$DAO
=
_civicrm_api3_get_DAO
(
'civicrm_api3_website_get'
);
$this
->
assertEquals
(
'CRM_Core_DAO_Website'
,
$DAO
);
$DAO
=
_civicrm_api3_get_DAO
(
'Membership'
);
$this
->
assertEquals
(
'CRM_Member_DAO_Membership'
,
$DAO
);
$params
=
array
(
'civicrm_api3_custom_group_get'
=>
'CRM_Core_DAO_CustomGroup'
,
'custom_group'
=>
'CRM_Core_DAO_CustomGroup'
,
'CustomGroup'
=>
'CRM_Core_DAO_CustomGroup'
,
'civicrm_api3_custom_field_get'
=>
'CRM_Core_DAO_CustomField'
,
'civicrm_api3_survey_get'
=>
'CRM_Campaign_DAO_Survey'
,
'civicrm_api3_pledge_payment_get'
=>
'CRM_Pledge_DAO_PledgePayment'
,
'civicrm_api3_website_get'
=>
'CRM_Core_DAO_Website'
,
'Membership'
=>
'CRM_Member_DAO_Membership'
,
);
foreach
(
$params
as
$input
=>
$expected
)
{
$result
=
_civicrm_api3_get_DAO
(
$input
);
$this
->
assertEquals
(
$expected
,
$result
);
}
}
/*
* Test GET
D
AO function returns
D
AO
* Test GET
B
AO function returns
B
AO
when it exists
*/
function
testGetBAO
()
{
$BAO
=
_civicrm_api3_get_BAO
(
'civicrm_api3_website_get'
);
$this
->
assertEquals
(
'CRM_Core_BAO_Website'
,
$BAO
);
$BAO
=
_civicrm_api3_get_BAO
(
'civicrm_api3_survey_get'
);
$this
->
assertEquals
(
'CRM_Campaign_BAO_Survey'
,
$BAO
);
$BAO
=
_civicrm_api3_get_BAO
(
'civicrm_api3_pledge_payment_get'
);
$this
->
assertEquals
(
'CRM_Pledge_BAO_PledgePayment'
,
$BAO
);
$params
=
array
(
'civicrm_api3_website_get'
=>
'CRM_Core_BAO_Website'
,
'civicrm_api3_survey_get'
=>
'CRM_Campaign_BAO_Survey'
,
'civicrm_api3_pledge_payment_get'
=>
'CRM_Pledge_BAO_PledgePayment'
,
'Household'
=>
'CRM_Contact_BAO_Contact'
,
// Note this one DOES NOT have a BAO so we expect to fall back on returning the DAO
'mailing_group'
=>
'CRM_Mailing_DAO_MailingGroup'
,
);
foreach
(
$params
as
$input
=>
$expected
)
{
$result
=
_civicrm_api3_get_BAO
(
$input
);
$this
->
assertEquals
(
$expected
,
$result
);
}
}
function
test_civicrm_api3_validate_fields
()
{
...
...
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