Skip to content

Commit

Permalink
Fixing failing tests due to new duplicity checks in Mautic
Browse files Browse the repository at this point in the history
  • Loading branch information
escopecz committed Jan 16, 2023
1 parent c348cf1 commit 5aadcf0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
11 changes: 10 additions & 1 deletion tests/Api/CompaniesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ public function testAddAndRemove()

public function testBatchEndpoints()
{
$this->standardTestBatchEndpoints();
$batch = [];

// Company name must be unique
for ($i = 0; $i < 3; ++$i) {
$company = $this->testPayload;
$company['companyname'] = 'test'.$i;
$batch[] = $company;
}

$this->standardTestBatchEndpoints($batch);
}
}
12 changes: 12 additions & 0 deletions tests/Api/ContactsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Mautic\Tests\Api;

use Mautic\Api\Contacts;
use Mautic\QueryBuilder\QueryBuilder;

class ContactsTest extends AbstractCustomFieldsTest
{
Expand Down Expand Up @@ -365,6 +366,17 @@ public function testEditPatchFormError()

public function testEditPut()
{
$qb = new QueryBuilder();
$qb->addWhere($qb->getWhereBuilder()->eq('email', $this->testPayload['email']));
$response = $this->api->getCustomList($qb, 0, 1);
$this->assertErrors($response);

// Making sure that if the contact exists, it won't try to create it. Otherwise we'll get an error about duplicated email.
if (isset($response[$this->api->listName()]) && count($response[$this->api->listName()])) {
$response = $this->api->delete(array_pop($response[$this->api->listName()])['id']);
$this->assertErrors($response);
}

$this->standardTestEditPut();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Api/MauticApiTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public function standardTestEditPut()
$response = $this->api->edit(10000, $this->testPayload, true);
$this->assertPayload($response);

//now delete the category
//now delete the entity
$response = $this->api->delete($response[$this->api->itemName()]['id']);
$this->assertErrors($response);
}
Expand Down

0 comments on commit 5aadcf0

Please sign in to comment.