From: Seamus Lee Date: Sat, 14 Dec 2019 22:03:56 +0000 (+1100) Subject: Add in Country and StateProvince APIv4 Entities X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=1e810dc920e9bf584d6789d9a1fb0b42ab697446;p=civicrm-core.git Add in Country and StateProvince APIv4 Entities --- diff --git a/Civi/Api4/Country.php b/Civi/Api4/Country.php new file mode 100644 index 0000000000..619cc6c360 --- /dev/null +++ b/Civi/Api4/Country.php @@ -0,0 +1,30 @@ +_apiversion = 3; parent::setUp(); $this->useTransaction(TRUE); $this->_params = [ @@ -31,6 +29,9 @@ class api_v3_CountryTest extends CiviUnitTestCase { ]; } + /** + * @dataProvider versionThreeAndFour + */ public function testCreateCountry() { $result = $this->callAPIAndDocument('country', 'create', $this->_params, __FUNCTION__, __FILE__); @@ -40,6 +41,9 @@ class api_v3_CountryTest extends CiviUnitTestCase { $this->callAPISuccess('country', 'delete', ['id' => $result['id']]); } + /** + * @dataProvider versionThreeAndFour + */ public function testDeleteCountry() { //create one $create = $this->callAPISuccess('country', 'create', $this->_params); @@ -54,6 +58,7 @@ class api_v3_CountryTest extends CiviUnitTestCase { /** * Test civicrm_phone_get with empty params. + * @dataProvider versionThreeAndFour */ public function testGetEmptyParams() { $result = $this->callAPISuccess('Country', 'Get', []); @@ -61,6 +66,7 @@ class api_v3_CountryTest extends CiviUnitTestCase { /** * Test civicrm_phone_get with wrong params. + * @dataProvider versionThreeAndFour */ public function testGetWrongParams() { $this->callAPIFailure('Country', 'Get', ['id' => 'abc']); @@ -68,6 +74,7 @@ class api_v3_CountryTest extends CiviUnitTestCase { /** * Test civicrm_phone_get - success expected. + * @dataProvider versionThreeAndFour */ public function testGet() { $country = $this->callAPISuccess('Country', 'create', $this->_params); @@ -84,6 +91,7 @@ class api_v3_CountryTest extends CiviUnitTestCase { /** * If a new country is created and it is created again it should not create a second one. * We check on the iso code (there should be only one iso code + * @dataProvider versionThreeAndFour */ public function testCreateDuplicateFail() { $params = $this->_params; diff --git a/tests/phpunit/api/v3/StateProvinceTest.php b/tests/phpunit/api/v3/StateProvinceTest.php index 8afa132a3e..7085bf5efb 100644 --- a/tests/phpunit/api/v3/StateProvinceTest.php +++ b/tests/phpunit/api/v3/StateProvinceTest.php @@ -17,11 +17,9 @@ * @group headless */ class api_v3_StateProvinceTest extends CiviUnitTestCase { - protected $_apiversion; protected $_params; public function setUp() { - $this->_apiversion = 3; parent::setUp(); $this->useTransaction(TRUE); $this->_params = [ @@ -31,6 +29,9 @@ class api_v3_StateProvinceTest extends CiviUnitTestCase { ]; } + /** + * @dataProvider versionThreeAndFour + */ public function testCreateStateProvince() { $result = $this->callAPIAndDocument('StateProvince', 'create', $this->_params, __FUNCTION__, __FILE__); $this->assertEquals(1, $result['count']); @@ -38,6 +39,9 @@ class api_v3_StateProvinceTest extends CiviUnitTestCase { $this->callAPISuccess('StateProvince', 'delete', ['id' => $result['id']]); } + /** + * @dataProvider versionThreeAndFour + */ public function testDeleteStateProvince() { // Create $create = $this->callAPISuccess('StateProvince', 'create', $this->_params); @@ -53,6 +57,7 @@ class api_v3_StateProvinceTest extends CiviUnitTestCase { /** * Test with empty params + * @dataProvider versionThreeAndFour */ public function testGetEmptyParams() { $result = $this->callAPISuccess('StateProvince', 'Get', []); @@ -60,6 +65,7 @@ class api_v3_StateProvinceTest extends CiviUnitTestCase { /** * Test with wrong params + * @dataProvider versionThreeAndFour */ public function testGetWrongParams() { $this->callAPIFailure('StateProvince', 'Get', ['id' => 'abc']); @@ -67,6 +73,7 @@ class api_v3_StateProvinceTest extends CiviUnitTestCase { /** * Test get + * @dataProvider versionThreeAndFour */ public function testGet() { $province = $this->callAPISuccess('StateProvince', 'create', $this->_params); @@ -80,6 +87,7 @@ class api_v3_StateProvinceTest extends CiviUnitTestCase { /** * There cannot be two state/provinces with the same name in the same country. + * @dataProvider versionThreeAndFour */ public function testCreateDuplicateFail() { $params = $this->_params;