Skip to content
Snippets Groups Projects
Commit 4e88fc61 authored by Josh Pollock's avatar Josh Pollock
Browse files

impiment delete by entry ids

parent 0d713eeb
No related branches found
No related tags found
No related merge requests found
......@@ -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
......@@ -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
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment