Пример #1
0
 public function testCompareToIgnoreCase()
 {
     $str1 = new Str("apple");
     $str2 = new Str("APPLE");
     $str3 = new Str("banana");
     $str4 = new Str("BANANA");
     $this->assertLessThanOrEqual(-1, $str1->compareToIgnoreCase($str3));
     $this->assertLessThanOrEqual(-1, $str2->compareToIgnoreCase($str4));
     $this->assertEquals(0, $str1->compareToIgnoreCase($str2));
     $this->assertEquals(0, $str3->compareToIgnoreCase($str4));
     $this->assertGreaterThanOrEqual(1, $str4->compareToIgnoreCase($str1));
     $this->assertGreaterThanOrEqual(1, $str4->compareToIgnoreCase($str2));
     $str5 = new Str("1234");
     try {
         $this->assertNotEquals(0, $str5->compareTo(1234));
     } catch (StrInvalidArgumentException $ex) {
         $this->assertEquals(get_class($ex), 'Str\\StrInvalidArgumentException');
     }
 }