Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
caldera-forms-query
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
plugins
cf-dependencies
caldera-forms-query
Commits
4e88fc61
Commit
4e88fc61
authored
6 years ago
by
Josh Pollock
Browse files
Options
Downloads
Patches
Plain Diff
impiment delete by entry ids
parent
0d713eeb
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Tests/Integration/Features/FeatureHelperMethodsTest.php
+42
-0
42 additions, 0 deletions
Tests/Integration/Features/FeatureHelperMethodsTest.php
src/Features/FeatureContainer.php
+23
-0
23 additions, 0 deletions
src/Features/FeatureContainer.php
with
65 additions
and
0 deletions
Tests/Integration/Features/FeatureHelperMethodsTest.php
+
42
−
0
View file @
4e88fc61
...
...
@@ -17,6 +17,7 @@ class FeatureHelperMethodsTest extends IntegrationTestCase
* @covers FeatureContainer::selectByUserId()
* @covers FeatureContainer::collectResults()
* @covers FeatureContainer::collectEntryValues()
* @covers FeatureContainer::select()
*/
public
function
testByUserId
()
{
...
...
@@ -52,6 +53,7 @@ class FeatureHelperMethodsTest extends IntegrationTestCase
* Test selecting by a field value such as an email
*
* @covers FeatureContainer::selectByFieldValue()
* @covers FeatureContainer::select()
*/
public
function
testByFieldValue
()
{
...
...
@@ -77,4 +79,44 @@ class FeatureHelperMethodsTest extends IntegrationTestCase
$this
->
assertSame
(
$email
,
$results
[
1
][
'values'
][
1
]
->
value
);
}
/**
*
* @covers FeatureContainer::deleteByEntryIds()
* @covers FeatureContainer::delete()
*/
public
function
testDeleteByIds
()
{
$container
=
$this
->
containerFactory
();
//Create three entries
$entryIdOne
=
$this
->
createEntryWithMockFormAndGetEntryId
();
$entryIdTwo
=
$this
->
createEntryWithMockFormAndGetEntryId
();
$entryIdThree
=
$this
->
createEntryWithMockFormAndGetEntryId
();
//Delete entry one and three
$container
->
deleteByEntryIds
([
$entryIdOne
,
$entryIdThree
]);
//No Entry results for entry One
$entryQueryGenerator
=
$this
->
entryGeneratorFactory
();
$entryQueryGenerator
->
queryByEntryId
(
$entryIdOne
);
$sql
=
$entryQueryGenerator
->
getPreparedSql
();
$results
=
$this
->
queryWithWPDB
(
$sql
);
$this
->
assertSame
(
0
,
count
(
$results
)
);
//No Entry Value results for entry One
$entryValuesQueryGenerator
=
$this
->
entryValuesGeneratorFactory
();
$entryValuesQueryGenerator
->
queryByEntryId
(
$entryIdOne
);
$sql
=
$entryValuesQueryGenerator
->
getPreparedSql
();
$results
=
$this
->
queryWithWPDB
(
$sql
);
$this
->
assertSame
(
0
,
count
(
$results
)
);
//Results for entry Two
$entryValuesQueryGenerator
=
$this
->
entryValuesGeneratorFactory
();
$entryValuesQueryGenerator
->
queryByEntryId
(
$entryIdTwo
);
$sql
=
$entryValuesQueryGenerator
->
getPreparedSql
();
$results
=
$this
->
queryWithWPDB
(
$sql
);
$this
->
assertTrue
(
0
<
count
(
$results
)
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/Features/FeatureContainer.php
+
23
−
0
View file @
4e88fc61
...
...
@@ -169,6 +169,29 @@ class FeatureContainer extends Container
return
$this
->
collectResults
(
$this
->
select
(
$queryForValues
)
);
}
/**
* Delete all entry data, including field values for a collection of entries
*
* @param array $entryIds Entry Ids to delete
* @return $this
*/
public
function
deleteByEntryIds
(
array
$entryIds
)
{
$this
->
delete
(
$this
->
getQueries
()
->
entryDelete
()
->
deleteByEntryIds
(
$entryIds
)
);
$this
->
delete
(
$this
->
getQueries
()
->
entryValueDelete
()
->
deleteByEntryIds
(
$entryIds
)
);
return
$this
;
}
/**
* @return string
*/
...
...
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