public function testElementParams() { $this->CommentWidget->options(array('theme' => 'flat')); $expectedParams = array('comments/flat/view', array('target' => false, 'ajaxAction' => false, 'displayUrlToComment' => false, 'urlToComment' => '', 'allowAnonymousComment' => false, 'url' => null, 'ajaxOptions' => array(), 'viewInstance' => null, 'theme' => 'flat')); // Test params: they must be passed to the element "as is". Note that the theme has not effect on the element being fetched $expectedParams[1]['target'] = 'wrapper'; $expectedParams[1]['theme'] = 'threaded'; $this->View->expects($this->at(0))->method('element')->with($this->equalTo($expectedParams[0]), $this->equalTo($expectedParams[1])); $expected = 'Comment element content'; $this->View->expects($this->at(1))->method('element')->will($this->returnValue($expected)); $this->assertEqual($this->CommentWidget->element('view', array('target' => 'wrapper', 'theme' => 'threaded')), $expected); }
/** * Test element method * * @return void */ public function testElement() { $this->__mockView(); $this->CommentWidget->options(array('theme' => 'flat')); $expectedParams = array('comments/flat/view', array('target' => false, 'ajaxAction' => false, 'displayUrlToComment' => false, 'urlToComment' => '', 'allowAnonymousComment' => false, 'url' => null, 'ajaxOptions' => array(), 'viewInstance' => null, 'theme' => 'flat')); $expected = 'Comment element content'; $this->View->expects($this->at(0))->method('element')->will($this->returnValue($expected)); $this->assertEqual($this->CommentWidget->element('view'), $expected); // Test missing element in project elements path. The helper must try to search the element from the comments plugin $this->View->expects($this->at(1))->method('element')->will($this->returnValue('Not Found: /path/to/project/views/elements/comments/flat/view.ctp')); $this->assertEqual($this->CommentWidget->element('view'), 'Not Found: /path/to/project/views/elements/comments/flat/view.ctp'); // Test params: they must be passed to the element "as is". Note that the theme has not effect on the element being fetched $this->View->expects($this->at(1))->method('element')->will($this->returnValue($expected)); $this->assertEqual($this->CommentWidget->element('view', array('target' => 'wrapper', 'theme' => 'threaded')), $expected); }