Example #1
0
 public function testCanRenderAnotherResourceWithoutVersion()
 {
     $currentViewModel = new ResourceViewModel([], ['version' => 'default']);
     $viewModelHelper = $this->getMock(ViewModelHelper::class);
     $viewModelHelper->expects($this->once())->method('getCurrent')->will($this->returnValue($currentViewModel));
     $this->view->expects($this->once())->method('viewModel')->will($this->returnValue($viewModelHelper));
     $this->view->expects($this->once())->method('render')->with($this->callback(function (ResourceViewModel $resourceViewModel) {
         $this->assertEquals('default/foo.php', $resourceViewModel->getTemplate());
         $this->assertEquals('default', $resourceViewModel->getVersion());
         $this->assertEquals(['key' => 'value'], $resourceViewModel->getVariables());
         return true;
     }));
     $helper = $this->helper;
     $helper('foo', ['key' => 'value']);
 }
Example #2
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  */
 public function setUp()
 {
     parent::setUp();
     if (empty(static::$helperClass) || !class_exists(static::$helperClass)) {
         throw new PHPUnit_Framework_Exception(sprintf('%s: view-helper class "%s" does not exists', __METHOD__, static::$helperClass));
     }
     $this->viewMock = $this->getMock(static::$rendererClass);
     if (method_exists($this->viewMock, 'plugin')) {
         $this->viewMock->expects($this->any())->method('plugin')->will($this->returnCallback(array($this, 'plugin')));
     }
     $this->helper = $this->createHelper();
     $this->pluginInstances = array();
 }