public function testHasAccessToStrMethods()
 {
     $string1 = Strings::limit('foo', 1);
     $string2 = Underscore::from('foo')->limit(1)->obtain();
     $this->assertEquals('f...', $string1);
     $this->assertEquals('f...', $string2);
 }
Пример #2
0
 public function testCanWrapObject()
 {
     $under1 = new Underscore($this->array);
     $under2 = Underscore::from($this->array);
     $this->assertInstanceOf('Underscore\\Underscore', $under1);
     $this->assertInstanceOf('Underscore\\Types\\Arrays', $under2);
 }
Пример #3
0
 public function testWrapAndUnwrap()
 {
     $collection = new TestCollection(['a', 'b', 'c']);
     // Wrap and unwrap the collection
     $unwrapped = Underscore::from($collection)->collection();
     // The collection should a clone
     $this->assertNotSame($collection, $unwrapped);
     // But should be the same type
     $this->assertInstanceOf(get_class($collection), $unwrapped);
     // And have the same values
     $this->assertSame($collection->toArray(), $unwrapped->toArray());
 }
Пример #4
0
 public function testCanCreateChainableObject()
 {
     $under = Underscore::from($this->arrayNumbers);
     $under = $under->get(1);
     $this->assertEquals(2, $under);
 }
Пример #5
0
 public function testShuffle()
 {
     $original = $this->getDummy3();
     $values = Underscore::from($original)->shuffle()->toArray();
     // Not necessarily the same, but contains the same values.
     // We cannot check the sorting of the keys because it is entirely
     // possible that keys were not randomized at all!
     $this->assertEquals($original, $values);
 }