forked from hechoendrupal/drupal-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringUtilsTest.php
More file actions
56 lines (48 loc) · 1.35 KB
/
Copy pathStringUtilsTest.php
File metadata and controls
56 lines (48 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace Drupal\AppConsole\Test\Utils;
use \Drupal\AppConsole\Utils\StringUtils;
class StringUtilsTest extends \PHPUnit_Framework_TestCase
{
/* @var StringUtils */
protected $stringUtil;
protected function setUp()
{
$this->stringUtil = new StringUtils();
}
/**
* @dataProvider getDataNames
*/
public function testCreateMachineName($input, $machine_name)
{
$this->assertEquals($this->stringUtil->createMachineName($input), $machine_name);
}
/**
* @dataProvider getDataCamelCaseNames
*/
public function testCamelCaseToMachineName($camel_case, $machine_name)
{
$this->assertEquals($this->stringUtil->camelCaseToMachineName($camel_case), $machine_name);
}
/**
* Random strings and their equivalent machine-name
*/
public function getDataNames()
{
return [
['Test Space between words', 'test_space_between_words'],
['test$special*characters!', 'test_special_characters'],
['URL', 'url'],
];
}
/**
* Camel-case strings and their equivalent machine-name
*/
public function getDataCamelCaseNames()
{
return [
['camelCase', 'camel_case'],
['greatestFunctionEverWritten', 'greatest_function_ever_written'],
['WakeUp', 'wake_up'],
];
}
}