aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/lib/classes/StringManipulationTest.php
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:07:19 +0200
committerJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:19:12 +0200
commita3da1483a9e689846179159355badfec8073dbec (patch)
tree770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /tests/unit/lib/classes/StringManipulationTest.php
current code from svn, revision 62608
Diffstat (limited to 'tests/unit/lib/classes/StringManipulationTest.php')
-rw-r--r--tests/unit/lib/classes/StringManipulationTest.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/unit/lib/classes/StringManipulationTest.php b/tests/unit/lib/classes/StringManipulationTest.php
new file mode 100644
index 0000000..e0a3eaa
--- /dev/null
+++ b/tests/unit/lib/classes/StringManipulationTest.php
@@ -0,0 +1,49 @@
+<?php
+
+class StringManipulationTest extends \Codeception\Test\Unit
+{
+ public function setUp()
+ {
+ require_once 'lib/functions.php';
+ }
+
+ /**
+ * @dataProvider camelCaseProvider
+ */
+ public function testCamelCase($input, $expected, $ucfirst = false)
+ {
+ $camel_cased = strtocamelcase($input, $ucfirst);
+ $this->assertEquals($camel_cased, $expected);
+ }
+
+ public function camelCaseProvider()
+ {
+ return [
+ ['foo bar', 'fooBar'],
+ ['lorem (ipsum) dolor', 'loremIpsumDolor'],
+ ['test with numbers 1 2 3 4', 'testWithNumbers1234'],
+ ['path/definitions/converted', 'pathDefinitionsConverted'],
+
+ ['foo bar', 'FooBar', true],
+ ];
+ }
+
+ /**
+ * @dataProvider snake_case_provider
+ */
+ public function test_snake_case($input, $expected)
+ {
+ $snake_cased = strtosnakecase($input);
+ $this->assertEquals($snake_cased, $expected);
+ }
+
+ public function snake_case_provider()
+ {
+ return [
+ ['foo bar', 'foo_bar'],
+ ['lorem (ipsum) dolor', 'lorem_ipsum_dolor'],
+ ['test with numbers 1 2 3 4', 'test_with_numbers_1_2_3_4'],
+ ['path/definitions/converted', 'path_definitions_converted'],
+ ];
+ }
+} \ No newline at end of file