6 class RequestTest
extends \CiviUnitTestCase
{
11 public function validEntityActionPairs() {
14 array('MyEntity', 'MyAction', 3),
15 array('MyEntity', 'myaction', 3),
18 array('my+entity', 'MyAction', 3),
19 array('MyEntity', 'myaction', 3),
22 array('my entity with under_scores', 'My_Action', 3),
23 array('MyEntityWithUnderScores', 'my_action', 3),
26 array('u_f_match', 'get Something', 3),
27 array('UFMatch', 'get_something', 3),
33 * @dataProvider validEntityActionPairs
36 * @throws \API_Exception
38 public function testCreateRequest_EntityActionMunging($input, $expected) {
39 list ($inEntity, $inAction, $inVersion) = $input;
40 $apiRequest = Request
::create($inEntity, $inAction, array('version' => $inVersion), NULL);
41 $this->assertEquals($expected, array($apiRequest['entity'], $apiRequest['action'], $apiRequest['version']));
47 public function invalidEntityActionPairs() {
49 $cases[] = array('Not!Valid', 'create', 4);
50 $cases[] = array('My+Entity', 'MyAction', 4);
51 $cases[] = array('My Entity', 'MyAction', 4);
52 $cases[] = array('2MyEntity', 'MyAction', 4);
53 $cases[] = array('MyEntity', 'My+Action', 4);
54 $cases[] = array('MyEntity', 'My Action', 4);
55 $cases[] = array('MyEntity', '2Action', 4);
60 * @dataProvider invalidEntityActionPairs
61 * @expectedException \Civi\API\Exception\NotImplementedException
65 * @throws \Civi\API\Exception\NotImplementedException
67 public function testCreateRequest_InvalidEntityAction($inEntity, $inAction, $inVersion) {
68 Request
::create($inEntity, $inAction, array('version' => $inVersion), NULL);