Commit | Line | Data |
---|---|---|
87dde5eb TO |
1 | <?php |
2 | ||
3 | use Civi\Test\HeadlessInterface; | |
4 | use Civi\Test\TransactionalInterface; | |
5 | ||
6 | /** | |
7 | * @group headless | |
8 | */ | |
cf41f25a | 9 | class CRM_Afform_UtilTest extends \PHPUnit\Framework\TestCase implements HeadlessInterface, TransactionalInterface { |
87dde5eb TO |
10 | |
11 | /** | |
12 | * Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). | |
cf41f25a | 13 | * |
87dde5eb | 14 | * See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md |
cf41f25a | 15 | * |
16 | * @throws \CRM_Extension_Exception_ParseException | |
87dde5eb TO |
17 | */ |
18 | public function setUpHeadless() { | |
19 | return \Civi\Test::headless() | |
20 | ->installMe(__DIR__) | |
21 | ->install(['org.civicrm.api4']) | |
22 | ->apply(); | |
23 | } | |
24 | ||
25 | public function getNameExamples() { | |
26 | $exs = []; | |
27 | $exs[] = ['ab-cd-ef', 'camel', 'abCdEf']; | |
28 | $exs[] = ['abCd', 'camel', 'abCd']; | |
29 | $exs[] = ['AbCd', 'camel', 'abCd']; | |
30 | $exs[] = ['ab-cd', 'dash', 'ab-cd']; | |
31 | $exs[] = ['abCd', 'dash', 'ab-cd']; | |
32 | $exs[] = ['AbCd', 'dash', 'ab-cd']; | |
33 | ||
34 | $exs[] = ['ab-cd-ef23', 'camel', 'abCdEf23']; | |
35 | $exs[] = ['abCd23', 'camel', 'abCd23']; | |
36 | $exs[] = ['AbCd23', 'camel', 'abCd23']; | |
37 | $exs[] = ['ab-cd23', 'dash', 'ab-cd23']; | |
38 | $exs[] = ['abCd23', 'dash', 'ab-cd23']; | |
39 | $exs[] = ['AbCd23', 'dash', 'ab-cd23']; | |
40 | ||
41 | return $exs; | |
42 | } | |
43 | ||
44 | /** | |
45 | * @param $inputFileName | |
46 | * @param $toFormat | |
47 | * @param $expected | |
cf41f25a | 48 | * |
87dde5eb | 49 | * @dataProvider getNameExamples |
cf41f25a | 50 | * @throws \Exception |
87dde5eb TO |
51 | */ |
52 | public function testNameConversion($inputFileName, $toFormat, $expected) { | |
53 | $actual = _afform_angular_module_name($inputFileName, $toFormat); | |
54 | $this->assertEquals($expected, $actual); | |
55 | } | |
56 | ||
57 | } |