public function testExtend() { // from js $result = __u::extend(array(), array('a' => 'b')); $this->assertEquals(array('a' => 'b'), $result, 'can extend an array with the attributes of another'); $result = __u::extend((object) array(), (object) array('a' => 'b')); $this->assertEquals((object) array('a' => 'b'), $result, 'can extend an object with the attributes of another'); $result = __u::extend(array('a' => 'x'), array('a' => 'b')); $this->assertEquals(array('a' => 'b'), $result, 'properties in source override destination'); $result = __u::extend(array('x' => 'x'), array('a' => 'b')); $this->assertEquals(array('x' => 'x', 'a' => 'b'), $result, "properties not in source don't get overriden"); $result = __u::extend(array('x' => 'x'), array('a' => 'b'), array('b' => 'b')); $this->assertEquals(array('x' => 'x', 'a' => 'b', 'b' => 'b'), $result, 'can extend from multiple sources'); $result = __u::extend(array('x' => 'x'), array('a' => 'a', 'x' => 2), array('a' => 'b')); $this->assertEquals(array('x' => 2, 'a' => 'b'), $result, 'extending from multiple source objects last property trumps'); // extra $result = __u(array('x' => 'x'))->extend(array('a' => 'a', 'x' => 2), array('a' => 'b')); $this->assertEquals(array('x' => 2, 'a' => 'b'), $result, 'extending from multiple source objects last property trumps'); // docs $expected = (object) array('name' => 'moe', 'age' => 50); $result = __u::extend((object) array('name' => 'moe'), (object) array('age' => 50)); $this->assertEquals($expected, $result); }