X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=tests%2Fphpunit%2FCiviTest%2FCiviUnitTestCase.php;h=83fff3e4185cae226db4a55ae446b90a74260078;hb=1eb67ea32fba44568ddef4c9891f1e986607c0fc;hp=b003861d858d3ba7ff30e16d476c1a3959a9a55e;hpb=704d27ceb1afe752dd738a8de497e6c64675725d;p=civicrm-core.git diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index b003861d85..83fff3e418 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -495,14 +495,14 @@ class CiviUnitTestCase extends PHPUnit\Framework\TestCase { * Create a batch of external API calls which can * be executed concurrently. * - * @code + * ``` * $calls = $this->createExternalAPI() * ->addCall('Contact', 'get', ...) * ->addCall('Contact', 'get', ...) * ... * ->run() * ->getResults(); - * @endcode + * ``` * * @return \Civi\API\ExternalBatch * @throws PHPUnit_Framework_SkippedTestError @@ -3562,4 +3562,35 @@ VALUES } } + /** + * Generic create test. + * + * @param int $version + * + * @throws \CRM_Core_Exception + */ + protected function basicCreateTest(int $version) { + $this->_apiversion = $version; + $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params, __FUNCTION__, __FILE__); + $this->assertEquals(1, $result['count']); + $this->assertNotNull($result['values'][$result['id']]['id']); + $this->getAndCheck($this->params, $result['id'], $this->_entity); + } + + /** + * Generic delete test. + * + * @param int $version + * + * @throws \CRM_Core_Exception + */ + protected function basicDeleteTest($version) { + $this->_apiversion = $version; + $result = $this->callAPISuccess($this->_entity, 'create', $this->params); + $deleteParams = ['id' => $result['id']]; + $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__); + $checkDeleted = $this->callAPISuccess($this->_entity, 'get', []); + $this->assertEquals(0, $checkDeleted['count']); + } + }