diff --git a/api/v3/TwingleCampaign/Delete.php b/api/v3/TwingleCampaign/Delete.php new file mode 100644 index 0000000..cd1ae99 --- /dev/null +++ b/api/v3/TwingleCampaign/Delete.php @@ -0,0 +1,45 @@ + ['id' => 12, 'name' => 'Twelve'], + 34 => ['id' => 34, 'name' => 'Thirty four'], + 56 => ['id' => 56, 'name' => 'Fifty six'], + ); + // ALTERNATIVE: $returnValues = []; // OK, success + // ALTERNATIVE: $returnValues = ["Some value"]; // OK, return a single value + + // Spec: civicrm_api3_create_success($values = 1, $params = [], $entity = NULL, $action = NULL) + return civicrm_api3_create_success($returnValues, $params, 'TwingleCampaign', 'Delete'); + } + else { + throw new API_Exception(/*error_message*/ 'Everyone knows that the magicword is "sesame"', /*error_code*/ 'magicword_incorrect'); + } +} diff --git a/api/v3/TwingleEvent/Delete.php b/api/v3/TwingleEvent/Delete.php new file mode 100644 index 0000000..03c271a --- /dev/null +++ b/api/v3/TwingleEvent/Delete.php @@ -0,0 +1,45 @@ + ['id' => 12, 'name' => 'Twelve'], + 34 => ['id' => 34, 'name' => 'Thirty four'], + 56 => ['id' => 56, 'name' => 'Fifty six'], + ); + // ALTERNATIVE: $returnValues = []; // OK, success + // ALTERNATIVE: $returnValues = ["Some value"]; // OK, return a single value + + // Spec: civicrm_api3_create_success($values = 1, $params = [], $entity = NULL, $action = NULL) + return civicrm_api3_create_success($returnValues, $params, 'TwingleEvent', 'Delete'); + } + else { + throw new API_Exception(/*error_message*/ 'Everyone knows that the magicword is "sesame"', /*error_code*/ 'magicword_incorrect'); + } +} diff --git a/api/v3/TwingleProject/Delete.php b/api/v3/TwingleProject/Delete.php new file mode 100644 index 0000000..d984c63 --- /dev/null +++ b/api/v3/TwingleProject/Delete.php @@ -0,0 +1,45 @@ + ['id' => 12, 'name' => 'Twelve'], + 34 => ['id' => 34, 'name' => 'Thirty four'], + 56 => ['id' => 56, 'name' => 'Fifty six'], + ); + // ALTERNATIVE: $returnValues = []; // OK, success + // ALTERNATIVE: $returnValues = ["Some value"]; // OK, return a single value + + // Spec: civicrm_api3_create_success($values = 1, $params = [], $entity = NULL, $action = NULL) + return civicrm_api3_create_success($returnValues, $params, 'TwingleProject', 'Delete'); + } + else { + throw new API_Exception(/*error_message*/ 'Everyone knows that the magicword is "sesame"', /*error_code*/ 'magicword_incorrect'); + } +} diff --git a/tests/phpunit/api/v3/TwingleCampaign/DeleteTest.php b/tests/phpunit/api/v3/TwingleCampaign/DeleteTest.php new file mode 100644 index 0000000..42eea9f --- /dev/null +++ b/tests/phpunit/api/v3/TwingleCampaign/DeleteTest.php @@ -0,0 +1,53 @@ +installMe(__DIR__) + ->apply(); + } + + /** + * The setup() method is executed before the test is executed (optional). + */ + public function setUp() { + parent::setUp(); + } + + /** + * The tearDown() method is executed after the test was executed (optional) + * This can be used for cleanup. + */ + public function tearDown() { + parent::tearDown(); + } + + /** + * Simple example test case. + * + * Note how the function name begins with the word "test". + */ + public function testApiExample() { + $result = civicrm_api3('TwingleCampaign', 'Delete', array('magicword' => 'sesame')); + $this->assertEquals('Twelve', $result['values'][12]['name']); + } + +} diff --git a/tests/phpunit/api/v3/TwingleEvent/DeleteTest.php b/tests/phpunit/api/v3/TwingleEvent/DeleteTest.php new file mode 100644 index 0000000..e0525cd --- /dev/null +++ b/tests/phpunit/api/v3/TwingleEvent/DeleteTest.php @@ -0,0 +1,53 @@ +installMe(__DIR__) + ->apply(); + } + + /** + * The setup() method is executed before the test is executed (optional). + */ + public function setUp() { + parent::setUp(); + } + + /** + * The tearDown() method is executed after the test was executed (optional) + * This can be used for cleanup. + */ + public function tearDown() { + parent::tearDown(); + } + + /** + * Simple example test case. + * + * Note how the function name begins with the word "test". + */ + public function testApiExample() { + $result = civicrm_api3('TwingleEvent', 'Delete', array('magicword' => 'sesame')); + $this->assertEquals('Twelve', $result['values'][12]['name']); + } + +} diff --git a/tests/phpunit/api/v3/TwingleProject/DeleteTest.php b/tests/phpunit/api/v3/TwingleProject/DeleteTest.php new file mode 100644 index 0000000..8419e5d --- /dev/null +++ b/tests/phpunit/api/v3/TwingleProject/DeleteTest.php @@ -0,0 +1,53 @@ +installMe(__DIR__) + ->apply(); + } + + /** + * The setup() method is executed before the test is executed (optional). + */ + public function setUp() { + parent::setUp(); + } + + /** + * The tearDown() method is executed after the test was executed (optional) + * This can be used for cleanup. + */ + public function tearDown() { + parent::tearDown(); + } + + /** + * Simple example test case. + * + * Note how the function name begins with the word "test". + */ + public function testApiExample() { + $result = civicrm_api3('TwingleProject', 'Delete', array('magicword' => 'sesame')); + $this->assertEquals('Twelve', $result['values'][12]['name']); + } + +}