Open Journal Systems  3.3.0
StringHelperTest.php
1 <?php
2 /*
3  * citeproc-php
4  *
5  * @link http://github.com/seboettg/citeproc-php for the source repository
6  * @copyright Copyright (c) 2016 Sebastian Böttger.
7  * @license https://opensource.org/licenses/MIT
8  */
9 
10 namespace Seboettg\CiteProc\Util;
11 use PHPUnit\Framework\TestCase;
12 
19 class StringHelperTest extends TestCase
20 {
21 
22  public function testCamelCase2Hyphen()
23  {
24  $this->assertEquals("lower-camel-case", StringHelper::camelCase2Hyphen("lowerCamelCase"));
25  $this->assertEquals("upper-camel-case", StringHelper::camelCase2Hyphen("UpperCamelCase"));
26  $this->assertEquals("up-per-cam-el-ca-se", StringHelper::camelCase2Hyphen("Up-perCam-elCa-se"));
27  }
28 
29  public function testCheckUpperCase()
30  {
31  $this->assertTrue(StringHelper::checkUpperCaseString("HALLO WELT"));
32  $this->assertFalse(StringHelper::checkUpperCaseString("hallo welt"));
33  $this->assertTrue(StringHelper::checkUpperCaseString("ÄTHIOPIEN"));
34  $this->assertFalse(StringHelper::checkUpperCaseString("äTHIOPIEN"));
35  }
36 
37  public function testCheckLowerCase()
38  {
39  $this->assertFalse(StringHelper::checkLowerCaseString("HALLO WELT"));
40  $this->assertTrue(StringHelper::checkLowerCaseString("hallo welt"));
41  $this->assertFalse(StringHelper::checkLowerCaseString("Äthiopien"));
42  $this->assertTrue(StringHelper::checkLowerCaseString("äthiopien"));
43  }
44 
45  public function testReplaceOuterQuotes()
46  {
47  $string = "Getting Property Right: “Informal” Mortgages in the Japanese Courts";
48  $actual = StringHelper::replaceOuterQuotes($string, "“", "”", "‘", "’");
49  $this->assertEquals("Getting Property Right: ‘Informal’ Mortgages in the Japanese Courts", $actual);
50 
51  $string = "Getting Property Right: \"Informal\" Mortgages in the Japanese Courts";
52  $actual = StringHelper::replaceOuterQuotes($string, "\"", "\"", "‘", "’");
53  $this->assertEquals("Getting Property Right: ‘Informal’ Mortgages in the Japanese Courts", $actual);
54  }
55 
56  public function testIsLatinString()
57  {
58  $this->assertFalse(StringHelper::isLatinString("栄我妻"));
59  $this->assertFalse(StringHelper::isLatinString("栄我 妻"));
60  $this->assertFalse(StringHelper::isLatinString("栄我妻 Hello World.!¡"));
61  $this->assertTrue(StringHelper::isLatinString("Hello World"));
62  $this->assertFalse(StringHelper::isLatinString("АаБбВвГг"));
63  $this->assertFalse(StringHelper::isLatinString("HАllo"));
64  }
65 
66  public function testIsCyrillicString()
67  {
68  $this->assertFalse(StringHelper::isCyrillicString("栄我妻"));
69  $this->assertFalse(StringHelper::isCyrillicString("栄我 妻"));
70  $this->assertFalse(StringHelper::isCyrillicString("Hallo Welt оформления"));
71  $this->assertTrue(StringHelper::isCyrillicString("Пример чиком. : чиком!"));
72  $this->assertFalse(StringHelper::isCyrillicString("Nicht"));
73  $this->assertFalse(StringHelper::isCyrillicString("пеpеводчиком"));
74  }
75 }
Seboettg\CiteProc\Util\StringHelper\isLatinString
static isLatinString($string)
Definition: StringHelper.php:269
Seboettg\CiteProc\Util\StringHelperTest\testIsCyrillicString
testIsCyrillicString()
Definition: StringHelperTest.php:66
Seboettg\CiteProc\Util\StringHelper\isCyrillicString
static isCyrillicString($string)
Definition: StringHelper.php:279
Seboettg\CiteProc\Util\StringHelperTest\testCheckLowerCase
testCheckLowerCase()
Definition: StringHelperTest.php:37
Seboettg\CiteProc\Util\StringHelperTest\testCamelCase2Hyphen
testCamelCase2Hyphen()
Definition: StringHelperTest.php:22
Seboettg\CiteProc\Util\StringHelper\replaceOuterQuotes
static replaceOuterQuotes( $text, $outerOpenQuote, $outerCloseQuote, $innerOpenQuote, $innerCloseQuote)
Definition: StringHelper.php:252
Seboettg\CiteProc\Util\StringHelperTest\testCheckUpperCase
testCheckUpperCase()
Definition: StringHelperTest.php:29
Seboettg\CiteProc\Util\StringHelper\checkLowerCaseString
static checkLowerCaseString($string)
Definition: StringHelper.php:219
Seboettg\CiteProc\Util
Definition: CiteProcHelper.php:10
Seboettg\CiteProc\Util\StringHelperTest\testReplaceOuterQuotes
testReplaceOuterQuotes()
Definition: StringHelperTest.php:45
Seboettg\CiteProc\Util\StringHelperTest\testIsLatinString
testIsLatinString()
Definition: StringHelperTest.php:56
Seboettg\CiteProc\Util\StringHelper\camelCase2Hyphen
static camelCase2Hyphen($string)
Definition: StringHelper.php:208
Seboettg\CiteProc\Util\StringHelper\checkUpperCaseString
static checkUpperCaseString($string)
Definition: StringHelper.php:228
Seboettg\CiteProc\Util\StringHelperTest
Definition: StringHelperTest.php:19