示例#1
0
 public function testOccurences()
 {
     $str = new Text('let it go');
     $this->assertTrue($str->startsWith('let'));
     $this->assertTrue($str->startsWith(new Text('let')));
     $this->assertFalse($str->startsWith('go'));
     $this->assertFalse($str->startsWith(new Text('go')));
     $this->assertTrue($str->endsWith('go'));
     $this->assertTrue($str->endsWith(new Text('go')));
     $this->assertFalse($str->endsWith('let'));
     $this->assertFalse($str->endsWith(new Text('let')));
     $this->assertTrue($str->contains('it'));
     $this->assertTrue($str->contains(new Text('it')));
     $this->assertFalse($str->contains('Hulk'));
     $this->assertFalse($str->contains(new Text('Hulk')));
     $this->assertTrue($str->equals('let it go'));
     $this->assertTrue($str->equals(new Text('let it go')));
     $this->assertFalse($str->equals('Let It Go'));
     $this->assertTrue($str->equalsIgnoreCase('Let It Go'));
     $this->assertTrue($str->equalsIgnoreCase(new Text('Let It Go')));
     $this->assertFalse($str->isEmpty());
 }
示例#2
0
文件: Path.php 项目: phootwork/file
 /**
  * Checks whether both paths point to the same location
  * 
  * @param Path|string $anotherPath
  * @return boolean true if the do, false if they don't
  */
 public function equals($anotherPath)
 {
     $anotherPath = $anotherPath instanceof Path ? $anotherPath : new Path($anotherPath);
     // do something else, when path's are urls
     $regexp = '/^[a-zA-Z]+:\\/\\//';
     $thisUrl = $this->pathname->match($regexp);
     $anotherUrl = $anotherPath->getPathname()->match($regexp);
     if ($thisUrl ^ $anotherUrl) {
         return false;
     } else {
         if ($thisUrl && $anotherUrl) {
             return $this->pathname->equals($anotherPath->getPathname());
         }
     }
     return realpath($this->pathname->toString()) == realpath($anotherPath->toString());
 }