Пример #1
0
 public function testHelperUsesServerAndBaseUrlFromHelpersByDefault()
 {
     $base = $this->view->getHelper('baseUrl');
     $base->setBaseUrl('/foo/bar');
     $server = $this->view->getHelper('serverUrl');
     $server->setScheme('https')->setHost('example.com:8080');
     $test = $this->helper->getBaseUrl();
     $this->assertEquals('https://example.com:8080/foo/bar/', $test);
 }
Пример #2
0
 public function testDatePickerOptionsAreRenderedInJavascript()
 {
     $options = array('foo' => uniqid());
     $this->_picker->setDatePickerOptions($options);
     // render the element
     $this->_picker->render($this->_view);
     /** @var $jq ZendX_JQuery_View_Helper_JQuery_Container */
     $jq = $this->_view->getHelper('jQuery');
     // test for date picker customization
     $this->assertContains("\$('#{$this->_picker->getId()}').datepicker", implode('', $jq->getOnLoadActions()), 'DatePicker should be initialized by id');
     $this->assertContains(Zend_Json::encode($options), implode('', $jq->getOnLoadActions()), 'DatePicker should be initialized with custom options');
 }
Пример #3
0
 public function init()
 {
     parent::init();
     $this->view->getHelper('headTitle')->headTitle('VAR_BASE_TITLE');
     $this->view->getHelper('HeadMeta')->appendHttpEquiv('pragma', 'no-cache')->appendHttpEquiv('Cache-Control', 'no-cache')->appendHttpEquiv('Content-Type', 'application/xhtml+xml; charset=UTF-8')->appendHttpEquiv('Content-Language', 'pl-PL');
     //		/->appendName('author', '');
     $this->view->getHelper('Doctype')->setDoctype(Zend_View_Helper_Doctype::XHTML11);
     $this->messages = Dfi_Controller_Action_Helper_Messages::getInstance();
     Zend_Controller_Action_HelperBroker::addHelper($this->messages);
     Zend_Auth::getInstance()->setStorage(new Dfi_Auth_Storage_Cookie('VAR_user'));
     /*   $this->messages->addMessage(Dfi_Controller_Action_Helper_Messages::TYPE_DEBUG, 'test  - DEBUG');
          $this->messages->addMessage('error', 'test');
          $this->messages->addMessage('confirmation', 'test');
          $this->messages->addMessage('notice', 'test');*/
     $this->view->addHelperPath('View/Helper', 'View_Helper');
     $this->view->addBasePath(APPLICATION_PATH . 'views/partials/');
 }
Пример #4
0
 /**
  * Regression Test fuer OPUSVIER-3192.
  */
 public function testBaseUrlUsedForFileLinks()
 {
     $helper = new Application_View_Helper_FileLink();
     $view = new Zend_View();
     $view->getHelper('BaseUrl')->setBaseUrl('/testbase');
     $helper->setView($view);
     $file = new Opus_File(126);
     $this->assertEquals('<a href="http:///testbase/files/146/test.pdf">foo-pdf</a>' . '<input type="hidden" name="" value="126" id="" />', $helper->fileLink(null, $file, array('useFileLabel' => true)));
 }
Пример #5
0
 /**
  * @group ZF-8177
  */
 public function testRegisterHelperShouldRegisterHelperWithView()
 {
     require_once dirname(__FILE__) . '/View/_stubs/HelperDir1/Stub1.php';
     $view = new Zend_View();
     $helper = new Foo_View_Helper_Stub1();
     $view->registerHelper($helper, 'stub1');
     $this->assertEquals($view->getHelper('stub1'), $helper);
     $this->assertEquals($view->stub1(), 'foo');
 }
Пример #6
0
    public function testGetHelperUsingDifferentCasesReturnsSameInstance()
    {
        $view    = new Zend_View();
        $helper1 = $view->getHelper('formHidden');
        $helper2 = $view->getHelper('FormHidden');

        $this->assertSame($helper1, $helper2);
    }
Пример #7
0
 /**
  * @issue ZF-2742
  */
 public function testGetHelperWorksWithPredefinedClassNames()
 {
     $view = new Zend_View();
     $view->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir2');
     try {
         $view->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir1', null);
         $this->fail('Exception for empty prefix was expected.');
     } catch (Exception $e) {
         $this->assertContains('only takes strings', $e->getMessage());
     }
     try {
         $view->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir1', null);
         $this->fail('Exception for empty prefix was expected.');
     } catch (Exception $e) {
         $this->assertContains('only takes strings', $e->getMessage());
     }
     try {
         $helper = $view->getHelper('Datetime');
     } catch (Exception $e) {
         $this->assertContains('not found', $e->getMessage());
     }
 }
Пример #8
0
 public function testGetHelper()
 {
     // require so we can do type hinting
     require_once 'Zend/View/Helper/DeclareVars.php';
     $view = new Zend_View();
     $view->declareVars();
     $helper = $view->getHelper('declareVars');
     $this->assertTrue($helper instanceof Zend_View_Helper_DeclareVars);
 }
Пример #9
0
    /**
     * @issue ZF-2742
     */
    public function testGetHelperWorksWithPredefinedClassNames()
    {
        $view = new Zend_View();

        $view->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir2');
        try {
            $view->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir1', null);
            $this->fail('Exception for empty prefix was expected.');
        } catch (Exception $e) {
            $this->assertEquals('The classPrefix cannot be empty.', $e->getMessage());
        }

        try {
            $view->setHelperPath(dirname(__FILE__) . '/View/_stubs/HelperDir1', null);
            $this->fail('Exception for empty prefix was expected.');
        } catch (Exception $e) {
            $this->assertEquals('The classPrefix cannot be empty.', $e->getMessage());
        }
        
        
        $helper = $view->getHelper('Datetime');
        $this->assertEquals('Zend_View_Helper_Datetime', get_class($helper));
    }
Пример #10
0
 /**
  * Returns the mocked url helper.
  *
  * @return Mol_Test_View_Helper_Url
  */
 private function getHelper()
 {
     return $this->view->getHelper('Url');
 }