Exemplo n.º 1
0
 public function testOperatingOnData()
 {
     $val1 = array('key' => 'foo', 'val' => 1);
     $val2 = array('key' => 'bar', 'val' => array(1, 2, 3));
     $this->object->setVal($val1['key'], $val1['val']);
     $this->object->setVal($val2['key'], $val2['val']);
     $this->assertEquals(2, count($this->object->getData()));
     $this->assertEquals($val1['val'], $this->object->getVal($val1['key']));
     $this->assertEquals($val2['val'], $this->object->getVal($val2['key']));
     $this->assertEquals('HelloWorld', $this->object->getVal('nonExistentVal', 'HelloWorld'));
     $this->object->setData(array());
     $this->assertEmpty($this->object->getData());
 }
Exemplo n.º 2
0
 /**
  * factory method - create view object for given controller and method name
  *
  * @param string $controllerName
  * @param string $methodName
  * @param array $data
  * @param string $format
  *
  * @return WikiaView
  */
 public static function newFromControllerAndMethodName($controllerName, $methodName, array $data = [], $format = WikiaResponse::FORMAT_HTML)
 {
     // Service classes must be dispatched by full name otherwise we default to a controller.
     $controllerClassName = self::normalizeControllerClass($controllerName);
     $response = new WikiaResponse($format);
     $response->setControllerName($controllerName);
     $response->setMethodName($methodName);
     $response->setData($data);
     /* @var $controllerClassName WikiaController */
     $response->setTemplateEngine($controllerClassName::DEFAULT_TEMPLATE_ENGINE);
     return $response->getView();
 }