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
a5280e5d
Commit
a5280e5d
authored
4 years ago
by
DaveD
Browse files
Options
Downloads
Patches
Plain Diff
fix test and convert to civi statics
parent
4a5987ac
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
CRM/Activity/BAO/Activity.php
+4
-13
4 additions, 13 deletions
CRM/Activity/BAO/Activity.php
tests/phpunit/CRM/Activity/Import/Parser/ActivityTest.php
+8
-10
8 additions, 10 deletions
tests/phpunit/CRM/Activity/Import/Parser/ActivityTest.php
with
12 additions
and
23 deletions
CRM/Activity/BAO/Activity.php
+
4
−
13
View file @
a5280e5d
...
...
@@ -37,13 +37,6 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity {
*/
public
static
$_exportableFields
=
NULL
;
/**
* Static field for all the activity information that we can potentially import.
*
* @var array
*/
public
static
$_importableFields
=
NULL
;
/**
* Check if there is absolute minimum of data to add the object.
*
...
...
@@ -1505,10 +1498,8 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity {
* array of importable Fields
*/
public
static
function
&
importableFields
(
$status
=
FALSE
)
{
if
(
!
self
::
$_importableFields
)
{
if
(
!
self
::
$_importableFields
)
{
self
::
$_importableFields
=
[];
}
if
(
empty
(
Civi
::
$statics
[
__CLASS__
][
__FUNCTION__
]))
{
Civi
::
$statics
[
__CLASS__
][
__FUNCTION__
]
=
[];
if
(
!
$status
)
{
$fields
=
[
''
=>
[
'title'
=>
ts
(
'- do not import -'
)]];
}
...
...
@@ -1544,9 +1535,9 @@ class CRM_Activity_BAO_Activity extends CRM_Activity_DAO_Activity {
$fields
=
array_merge
(
$fields
,
$tmpConatctField
);
$fields
=
array_merge
(
$fields
,
$tmpFields
);
$fields
=
array_merge
(
$fields
,
CRM_Core_BAO_CustomField
::
getFieldsForImport
(
'Activity'
));
self
::
$_importableFields
=
$fields
;
Civi
::
$statics
[
__CLASS__
][
__FUNCTION__
]
=
$fields
;
}
return
self
::
$_importableFields
;
return
Civi
::
$statics
[
__CLASS__
][
__FUNCTION__
]
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Activity/Import/Parser/ActivityTest.php
+
8
−
10
View file @
a5280e5d
<?php
/**
* File for the TestActivityType class
*
* (PHP 5)
*
* @package CiviCRM
*
* This file is part of CiviCRM
*
* CiviCRM is free software; you can redistribute it and/or
...
...
@@ -25,7 +19,7 @@
*/
/**
* Test
CRM/Member/BAO Membership Log add , delete
functions
* Test
Activity Import Parser
functions
*
* @package CiviCRM
* @group headless
...
...
@@ -47,7 +41,7 @@ class CRM_Activity_Import_Parser_ActivityTest extends CiviUnitTestCase {
* @throws \CRM_Core_Exception
*/
public
function
tearDown
():
void
{
$this
->
quickCleanup
([
'civicrm_contact'
,
'civicrm_activity'
],
TRUE
);
$this
->
quickCleanup
([
'civicrm_contact'
,
'civicrm_activity'
,
'civicrm_activity_contact'
],
TRUE
);
parent
::
tearDown
();
}
...
...
@@ -64,11 +58,11 @@ class CRM_Activity_Import_Parser_ActivityTest extends CiviUnitTestCase {
public
function
testImport
():
void
{
$this
->
createCustomGroupWithFieldOfType
([
'extends'
=>
'Activity'
],
'checkbox'
);
$values
=
[
'activity_detail'
=>
'fascinating'
,
'activity_detail
s
'
=>
'fascinating'
,
'activity_type_id'
=>
1
,
'activity_date_time'
=>
'2010-01-06'
,
'target_contact_id'
=>
$this
->
individualCreate
(),
'subject'
=>
'riveting stuff'
,
'
activity_
subject'
=>
'riveting stuff'
,
$this
->
getCustomFieldName
(
'checkbox'
)
=>
'L'
,
];
$this
->
importValues
(
$values
);
...
...
@@ -83,6 +77,10 @@ class CRM_Activity_Import_Parser_ActivityTest extends CiviUnitTestCase {
* @return \CRM_Activity_Import_Parser_Activity
*/
protected
function
createImportObject
(
array
$fields
):
\CRM_Activity_Import_Parser_Activity
{
// @todo Eyes are weary so sanity-check this later:
// This loop seems the same as array_values($fields)? And this appears
// to only be called from one place that already has them sequentially
// indexed so is it even needed?
$fieldMapper
=
[];
foreach
(
$fields
as
$index
=>
$field
)
{
$fieldMapper
[]
=
$field
;
...
...
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