Exemplo n.º 1
0
 public function test02()
 {
     ### startsWith($needle, $haystack)
     $this->assertTrue(Util::starts_with('Odd', 'Odd Greg'));
     $this->assertFalse(Util::starts_with('Greg', 'Odd Greg'));
     ### endsWith($needle, $haystack)
     $this->assertTrue(Util::ends_with('Greg', 'Odd Greg'));
     $this->assertFalse(Util::ends_with('Odd', 'Odd Greg'));
     ### stripTrailing($characters, $string)
     $this->assertEquals('All_The_Things', Util::strip_tail('_', "All_The_Things__"));
     $this->assertNotEquals('All_The_Things', Util::strip_tail('_', "All_The_Things--"));
     ### truncate($string, $endlength = "30", $end = "...")
     $this->assertEquals('A line tha...', Util::truncate("A line that is in need of shortening and I ain't talking about cooking.", $endlength = "10", $end = "..."));
 }
Exemplo n.º 2
0
 function test_Paths()
 {
     $paths = $this->paths;
     $this->assertEquals($paths->copy(), ['root' => ROOT, 'vendors' => VENDOR, 'config' => Util::strip_tail('/', realpath(__DIR__ . '/../../config/')) . '/']);
     $paths->add('goop', '/here/to/goop');
     $this->assertEquals(VENDOR, $paths['vendors']);
     $this->assertEquals(ROOT, $paths->{'root'});
     $this->assertEquals('/here/to/goop', $paths['goop']);
     $paths->set('test', 'nothing');
     $this->assertTrue($paths->has('test'));
     $this->assertNull($paths->set(0, 'value'));
     $paths['test'] = 'something';
     $paths->offsetUnset('test');
     $this->assertFalse($paths->has('test'));
 }