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
177b66d2
Unverified
Commit
177b66d2
authored
4 years ago
by
Eileen McNaughton
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #19931 from eileenmcnaughton/fa
#2486
Add v4 batch api
parents
ceda85a3
f294ab85
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Batch/BAO/Batch.php
+2
-1
2 additions, 1 deletion
CRM/Batch/BAO/Batch.php
Civi/Api4/Batch.php
+30
-0
30 additions, 0 deletions
Civi/Api4/Batch.php
tests/phpunit/api/v3/BatchTest.php
+36
-11
36 additions, 11 deletions
tests/phpunit/api/v3/BatchTest.php
with
68 additions
and
12 deletions
CRM/Batch/BAO/Batch.php
+
2
−
1
View file @
177b66d2
...
...
@@ -40,10 +40,11 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
*
* @return object
* $batch batch object
* @throws \Exception
*/
public
static
function
create
(
&
$params
)
{
if
(
empty
(
$params
[
'id'
])
&&
empty
(
$params
[
'name'
]))
{
$params
[
'name'
]
=
CRM_Utils_String
::
titleToVar
(
$params
[
'title'
]);
$params
[
'name'
]
=
CRM_Utils_String
::
titleToVar
(
$params
[
'title'
]
??
'batch_ref_'
.
random_int
(
0
,
100000
)
);
}
return
self
::
writeRecord
(
$params
);
}
...
...
This diff is collapsed.
Click to expand it.
Civi/Api4/Batch.php
0 → 100644
+
30
−
0
View file @
177b66d2
<?php
/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/
namespace
Civi\Api4
;
/**
* Batch entity.
*
* @see https://docs.civicrm.org/user/en/latest/pledges/everyday-tasks/#batch-entry-of-pledges
* @package Civi\Api4
*/
class
Batch
extends
Generic\DAOEntity
{
}
This diff is collapsed.
Click to expand it.
tests/phpunit/api/v3/BatchTest.php
+
36
−
11
View file @
177b66d2
...
...
@@ -17,7 +17,6 @@
*/
class
api_v3_BatchTest
extends
CiviUnitTestCase
{
protected
$_params
=
[];
protected
$_entity
=
'batch'
;
/**
...
...
@@ -27,24 +26,36 @@ class api_v3_BatchTest extends CiviUnitTestCase {
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
useTransaction
(
TRUE
);
$this
->
useTransaction
();
}
/**
* Test civicrm_batch_get - success expected.
*
* @dataProvider versionThreeAndFour
*
* @param int $version
*/
public
function
testGet
()
{
public
function
testGet
(
int
$version
):
void
{
$this
->
_apiversion
=
$version
;
$params
=
[
'id'
=>
$this
->
batchCreate
(),
];
$result
=
$this
->
callAPIAndDocument
(
'
b
atch'
,
'get'
,
$params
,
__FUNCTION__
,
__FILE__
);
$result
=
$this
->
callAPIAndDocument
(
'
B
atch'
,
'get'
,
$params
,
__FUNCTION__
,
__FILE__
);
$this
->
assertEquals
(
$params
[
'id'
],
$result
[
'id'
]);
}
/**
* Test civicrm_batch_create - success expected.
*
* @dataProvider versionThreeAndFour
*
* @param int $version
*
* @throws \CRM_Core_Exception
*/
public
function
testCreate
()
{
public
function
testCreate
(
int
$version
):
void
{
$this
->
_apiversion
=
$version
;
$params
=
[
'name'
=>
'New_Batch_03'
,
'title'
=>
'New Batch 03'
,
...
...
@@ -56,13 +67,20 @@ class api_v3_BatchTest extends CiviUnitTestCase {
$result
=
$this
->
callAPIAndDocument
(
'batch'
,
'create'
,
$params
,
__FUNCTION__
,
__FILE__
);
$this
->
assertNotNull
(
$result
[
'id'
]);
$this
->
getAndCheck
(
$params
,
$result
[
'id'
],
$this
->
_entity
);
$this
->
getAndCheck
(
$params
,
$result
[
'id'
],
'Batch'
);
}
/**
* Test civicrm_batch_create with id.
*
* @dataProvider versionThreeAndFour
*
* @param int $version
*
* @throws \CRM_Core_Exception
*/
public
function
testUpdate
()
{
public
function
testUpdate
(
int
$version
):
void
{
$this
->
_apiversion
=
$version
;
$params
=
[
'name'
=>
'New_Batch_04'
,
'title'
=>
'New Batch 04'
,
...
...
@@ -79,24 +97,31 @@ class api_v3_BatchTest extends CiviUnitTestCase {
/**
* Test civicrm_batch_delete using the old $params['batch_id'] syntax.
*
* @throws \CRM_Core_Exception
*/
public
function
testBatchDeleteOldSyntax
()
{
public
function
testBatchDeleteOldSyntax
()
:
void
{
$batchID
=
$this
->
batchCreate
();
$params
=
[
'batch_id'
=>
$batchID
,
];
$result
=
$this
->
callAPISuccess
(
'
b
atch'
,
'delete'
,
$params
);
$this
->
callAPISuccess
(
'
B
atch'
,
'delete'
,
$params
);
}
/**
* Test civicrm_batch_delete using the new $params['id'] syntax.
*
* @dataProvider versionThreeAndFour
*
* @param int $version
*/
public
function
testBatchDeleteCorrectSyntax
()
{
public
function
testBatchDeleteCorrectSyntax
(
int
$version
):
void
{
$this
->
_apiversion
=
$version
;
$batchID
=
$this
->
batchCreate
();
$params
=
[
'id'
=>
$batchID
,
];
$result
=
$this
->
callAPIAndDocument
(
'
b
atch'
,
'delete'
,
$params
,
__FUNCTION__
,
__FILE__
);
$this
->
callAPIAndDocument
(
'
B
atch'
,
'delete'
,
$params
,
__FUNCTION__
,
__FILE__
);
}
}
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