示例#1
0
 /**
  * @issue ZF-7544
  */
 public function testAddFilterRuleMultipleTimes()
 {
     $rules = $this->inflector->getRules();
     $this->assertEquals(0, count($rules));
     $this->inflector->setFilterRule('controller', 'PregReplace');
     $rules = $this->inflector->getRules('controller');
     $this->assertEquals(1, count($rules));
     $this->inflector->addFilterRule('controller', array('Alpha', 'StringToLower'));
     $rules = $this->inflector->getRules('controller');
     $this->assertEquals(3, count($rules));
     $this->_context = 'StringToLower';
     $this->inflector->setStaticRuleReference('context', $this->_context);
     $this->inflector->addFilterRule('controller', array('Alpha', 'StringToLower'));
     $rules = $this->inflector->getRules('controller');
     $this->assertEquals(5, count($rules));
 }
示例#2
0
 /**
  * @issue ZF-7544
  */
 public function testAddFilterRuleMultipleTimes()
 {
     if (!extension_loaded('intl')) {
         $this->markTestSkipped('ext/intl not enabled');
     }
     $rules = $this->inflector->getRules();
     $this->assertEquals(0, count($rules));
     $this->inflector->setFilterRule('controller', 'PregReplace');
     $rules = $this->inflector->getRules('controller');
     $this->assertEquals(1, count($rules));
     $this->inflector->addFilterRule('controller', array('Alpha', 'StringToLower'));
     $rules = $this->inflector->getRules('controller');
     $this->assertEquals(3, count($rules));
     $this->_context = 'StringToLower';
     $this->inflector->setStaticRuleReference('context', $this->_context);
     $this->inflector->addFilterRule('controller', array('Alpha', 'StringToLower'));
     $rules = $this->inflector->getRules('controller');
     $this->assertEquals(5, count($rules));
 }
示例#3
0
    public function testCustomInflectorCanUseItsOwnTarget()
    {
        $this->request->setModuleName('bar')
                      ->setControllerName('index')
                      ->setActionName('index');
        $controller = new \Bar\IndexController($this->request, $this->response, array());
        $controller->setHelperBroker($this->broker);

        $this->helper->view->resolver()->addPath($this->basePath . '/_files/modules/bar/views');

        $inflector = new Filter\Inflector('test.phtml');
        $inflector->addFilterRule(':controller', array('Word\CamelCaseToDash'));
        $this->helper->setInflector($inflector);

        $this->helper->render();
        $body = $this->response->getBody();
        $this->assertContains('Rendered test.phtml in bar module', $body);
    }