Permalink
Browse files

Reintroduce logic in Partial for compatibility

  • Loading branch information...
1 parent 129f030 commit c84f0106b84d686adba5a312da6826927a1bf9be @bakura10 committed Nov 13, 2012
@@ -36,6 +36,16 @@ public function __invoke($name = null, $values = null)
return $this;
}
+ if (is_scalar($values)) {
+ $values = array();
+ } elseif (is_object($values)) {
+ if (method_exists($values, 'toArray')) {
+ $values = $values->toArray();
+ } else {
+ $values = get_object_vars($values);
+ }
+ }
+
return $this->getView()->render($name, $values);
}
}
@@ -208,7 +208,7 @@ public function testShouldAllowIteratingOverObjectsImplementingToArray()
* @group ZF-3350
* @group ZF-3352
*/
- /*public function testShouldNotCastToArrayIfObjectIsTraversable()
+ public function testShouldNotCastToArrayIfObjectIsTraversable()
{
$data = array(
new IteratorWithToArrayTestContainer(array('message' => 'foo')),
@@ -227,7 +227,7 @@ public function testShouldAllowIteratingOverObjectsImplementingToArray()
$string = 'This is an iteration: ' . $item->message;
$this->assertContains($string, $result, $result);
}
- }*/
+ }
/**
* @group ZF-3083
@@ -126,55 +126,11 @@ public function testObjectModelWithToArraySetsViewVariables()
}
}
- public function testObjectModelSetInObjectKeyWhenKeyPresent()
- {
- $model = new \stdClass();
- $model->footest = 'bar';
- $model->bartest = 'baz';
-
- $view = new View;
- $view->resolver()->addPath($this->basePath . '/application/views/scripts');
- $this->helper->setView($view);
- $return = $this->helper->__invoke('partialObj.phtml', $model);
-
- $this->assertNotContains('No object model passed', $return);
-
- foreach (get_object_vars($model) as $key => $value) {
- $string = sprintf('%s: %s', $key, $value);
- $this->assertContains($string, $return, "Checking for '$return' containing '$string'");
- }
- }
-
public function testPassingNoArgsReturnsHelperInstance()
{
$test = $this->helper->__invoke();
$this->assertSame($this->helper, $test);
}
-
- public function testObjectKeyIsNullByDefault()
- {
- $this->assertNull($this->helper->getObjectKey());
- }
-
- public function testCanSetObjectKey()
- {
- $this->testObjectKeyIsNullByDefault();
- $this->helper->setObjectKey('foo');
- $this->assertEquals('foo', $this->helper->getObjectKey());
- }
-
- public function testCanSetObjectKeyToNullValue()
- {
- $this->testCanSetObjectKey();
- $this->helper->setObjectKey(null);
- $this->assertNull($this->helper->getObjectKey());
- }
-
- public function testSetObjectKeyImplementsFluentInterface()
- {
- $test = $this->helper->setObjectKey('foo');
- $this->assertSame($this->helper, $test);
- }
}
class Aggregate

0 comments on commit c84f010

Please sign in to comment.