Ejemplo n.º 1
0
 /**
  * Sets validator options
  *
  * @param  string|array|Traversable $options OPTIONAL
  * @return void
  */
 public function __construct($options = array())
 {
     if ($options instanceof Traversable) {
         $options = IteratorToArray::convert($options);
     } elseif (!is_array($options)) {
         $options = func_get_args();
         $temp['format'] = array_shift($options);
         if (!empty($options)) {
             $temp['locale'] = array_shift($options);
         }
         $options = $temp;
     }
     if (array_key_exists('format', $options)) {
         $this->setFormat($options['format']);
     }
     if (!array_key_exists('locale', $options)) {
         if (Registry::isRegistered('Zend_Locale')) {
             $options['locale'] = Registry::get('Zend_Locale');
         }
     }
     if (array_key_exists('locale', $options)) {
         $this->setLocale($options['locale']);
     }
     parent::__construct($options);
 }
Ejemplo n.º 2
0
    /**
     * Constructor for the integer validator
     *
     * Accepts either a string locale, a Zend_Locale object, or an array or
     * Zend_Config object containing the keys "locale" and/or "format".
     *
     * @param string|Zend_Locale|array|\Zend\Config\Config $options
     * @throws \Zend\Validator\Exception On empty format
     */
    public function __construct($options = null)
    {
        if ($options instanceof \Zend\Config\Config) {
            $options = $options->toArray();
        }

        if (empty($options)) {
            if (\Zend\Registry::isRegistered('Zend_Locale')) {
                $this->setLocale(\Zend\Registry::get('Zend_Locale'));
            }
        } elseif (is_array($options)) {
            // Received
            if (array_key_exists('locale', $options)) {
                $this->setLocale($options['locale']);
            }

            if (array_key_exists('format', $options)) {
                $this->setFormat($options['format']);
            }
        } elseif ($options instanceof Locale\Locale || is_string($options)) {
            // Received Locale object or string locale
            $this->setLocale($options);
        }

        $format = $this->getFormat();
        if (empty($format)) {
            throw new Exception\InvalidArgumentException("A postcode-format string has to be given for validation");
        }
    }
Ejemplo n.º 3
0
 /**
  * Sets validator options
  *
  * @param  null|string|Locale|array|Traversable $locale OPTIONAL
  * @return void
  */
 public function __construct($locale = null)
 {
     $options = array();
     if ($locale instanceof Traversable) {
         $locale = IteratorToArray::convert($locale);
     }
     if (is_array($locale)) {
         $options = $locale;
         if (array_key_exists('locale', $locale)) {
             $locale = $locale['locale'];
             unset($options['locale']);
         } else {
             $locale = null;
         }
     }
     if (empty($locale) && $locale !== false) {
         if (Registry::isRegistered('Zend_Locale')) {
             $locale = Registry::get('Zend_Locale');
         }
     }
     if ($locale !== null) {
         $this->setLocale($locale);
     }
     parent::__construct($options);
 }
Ejemplo n.º 4
0
 public function clearRegistry()
 {
     if (Registry::isRegistered('Zend_Translator')) {
         $registry = Registry::getInstance();
         unset($registry['Zend_Translator']);
     }
 }
Ejemplo n.º 5
0
 public function clearRegistry()
 {
     $regKey = 'Zend_Currency';
     if (\Zend\Registry::isRegistered($regKey)) {
         $registry = \Zend\Registry::getInstance();
         unset($registry[$regKey]);
     }
 }
Ejemplo n.º 6
0
 /**
  * Constructor for manually handling
  *
  * @param  \Zend\Currency\Currency $currency Instance of \Zend\Currency\Currency
  * @return void
  */
 public function __construct($currency = null)
 {
     if ($currency === null) {
         if (\Zend\Registry::isRegistered('Zend_Currency')) {
             $currency = \Zend\Registry::get('Zend_Currency');
         }
     }
     $this->setCurrency($currency);
 }
Ejemplo n.º 7
0
 public function setup()
 {
     Reader\Reader::reset();
     if (\Zend\Registry::isRegistered('Zend_Locale')) {
         $registry = \Zend\Registry::getInstance();
         unset($registry['Zend_Locale']);
     }
     $this->_feedSamplePath = dirname(__FILE__) . '/_files/Common';
 }
Ejemplo n.º 8
0
 public function testMultiplePlaceholdersUseSameRegistry()
 {
     $this->assertTrue(Registry::isRegistered(PlaceholderRegistry::REGISTRY_KEY));
     $registry = Registry::get(PlaceholderRegistry::REGISTRY_KEY);
     $this->assertSame($registry, $this->placeholder->getRegistry());
     $placeholder = new Helper\Placeholder();
     $this->assertSame($registry, $placeholder->getRegistry());
     $this->assertSame($this->placeholder->getRegistry(), $placeholder->getRegistry());
 }
Ejemplo n.º 9
0
 /**
  * Creates a new Zend_Validator_Float object for each test method
  *
  * @return void
  */
 public function setUp()
 {
     $this->_locale = setlocale(LC_ALL, 0);
     //backup locale
     if (\Zend\Registry::isRegistered('Zend_Locale')) {
         \Zend\Registry::getInstance()->offsetUnset('Zend_Locale');
     }
     $this->_validator = new Validator\Float();
 }
Ejemplo n.º 10
0
 public function testOptionsPassedToResourceAreUsedToSetLocaleState()
 {
     $resource = new TranslateResource($this->_translationOptions);
     $resource->setBootstrap($this->bootstrap);
     $resource->init();
     $translate = $resource->getTranslate();
     $this->assertTrue(Registry::isRegistered('Zend_Translate'));
     $this->assertSame(Registry::get('Zend_Translate'), $translate);
 }
Ejemplo n.º 11
0
 public function testRegistryEntryCreatedAfterInstantiation()
 {
     $this->assertTrue(\Zend\Registry::isRegistered('Zend_View_Helper_Doctype'));
     $doctype = \Zend\Registry::get('Zend_View_Helper_Doctype');
     $this->assertTrue($doctype instanceof \ArrayObject);
     $this->assertTrue(isset($doctype['doctype']));
     $this->assertTrue(isset($doctype['doctypes']));
     $this->assertTrue(is_array($doctype['doctypes']));
 }
Ejemplo n.º 12
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     if (\Zend\Registry::isRegistered('Zend_View_Helper_Doctype')) {
         $registry = \Zend\Registry::getInstance();
         unset($registry['Zend_View_Helper_Doctype']);
     }
     $this->view = new \Zend\View\PhpRenderer();
     $this->helper = new \Zend\View\Helper\FormFile();
     $this->helper->setView($this->view);
 }
Ejemplo n.º 13
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     if (Registry::isRegistered('Zend_View_Helper_Doctype')) {
         $registry = Registry::getInstance();
         unset($registry['Zend_View_Helper_Doctype']);
     }
     $this->view = new View();
     $this->helper = new FormMultiCheckbox();
     $this->helper->setView($this->view);
 }
Ejemplo n.º 14
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $regKey = Registry\Registry::REGISTRY_KEY;
     if (\Zend\Registry::isRegistered($regKey)) {
         $registry = \Zend\Registry::getInstance();
         unset($registry[$regKey]);
     }
     $this->basePath = dirname(__FILE__) . '/_files/modules';
     $this->helper = new Helper\HeadTitle();
 }
Ejemplo n.º 15
0
 /**
  * Constructor
  *
  * Map constants to doctype strings, and set default doctype
  *
  * @return void
  */
 public function __construct()
 {
     if (!\Zend\Registry::isRegistered($this->_regKey)) {
         $this->_registry = new \ArrayObject(array('doctypes' => array(self::XHTML11 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">', self::XHTML1_STRICT => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', self::XHTML1_TRANSITIONAL => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', self::XHTML1_FRAMESET => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">', self::XHTML_BASIC1 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">', self::XHTML5 => '<!DOCTYPE html>', self::HTML4_STRICT => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', self::HTML4_LOOSE => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">', self::HTML4_FRAMESET => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">', self::HTML5 => '<!DOCTYPE html>')));
         \Zend\Registry::set($this->_regKey, $this->_registry);
         $this->setDoctype($this->_defaultDoctype);
     } else {
         $this->_registry = \Zend\Registry::get($this->_regKey);
     }
 }
Ejemplo n.º 16
0
 /**
  * Retrieve or create registry instnace
  *
  * @return void
  */
 public static function getRegistry()
 {
     if (\Zend\Registry::isRegistered(self::REGISTRY_KEY)) {
         $registry = \Zend\Registry::get(self::REGISTRY_KEY);
     } else {
         $registry = new self();
         \Zend\Registry::set(self::REGISTRY_KEY, $registry);
     }
     return $registry;
 }
Ejemplo n.º 17
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     if (Registry::isRegistered('Zend_View_Helper_Doctype')) {
         $registry = Registry::getInstance();
         unset($registry['Zend_View_Helper_Doctype']);
     }
     $this->view = new View();
     $this->helper = new FormTextHelper();
     $this->helper->setView($this->view);
 }
Ejemplo n.º 18
0
 public function setUp()
 {
     if (Registry::isRegistered('Zend_Locale')) {
         $registry = Registry::getInstance();
         unset($registry['Zend_Locale']);
     }
     Cldr::removeCache();
     $this->_locale = setlocale(LC_ALL, 0);
     setlocale(LC_ALL, 'de');
 }
Ejemplo n.º 19
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $regKey = Registry::REGISTRY_KEY;
     if (\Zend\Registry::isRegistered($regKey)) {
         $registry = \Zend\Registry::getInstance();
         unset($registry[$regKey]);
     }
     $this->basePath = __DIR__ . '/_files/modules';
     $this->helper = new Helper\HeadStyle();
 }
Ejemplo n.º 20
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     if (\Zend\Registry::isRegistered('Zend_View_Helper_Doctype')) {
         $registry = \Zend\Registry::getInstance();
         unset($registry['Zend_View_Helper_Doctype']);
     }
     $this->view = new \Zend\View\View();
     $this->helper = new \Zend\View\Helper\FormReset();
     $this->helper->setView($this->view);
 }
Ejemplo n.º 21
0
 public function setUp()
 {
     // Necessary to ensure placeholders do not persist between individual tests
     if (Registry::isRegistered(PlaceholderRegistry::REGISTRY_KEY)) {
         Registry::getInstance()->offsetUnset(PlaceholderRegistry::REGISTRY_KEY);
     }
     $this->renderer = new PhpRenderer();
     $this->strategy = new PhpRendererStrategy($this->renderer);
     $this->event = new ViewEvent();
     $this->response = new HttpResponse();
 }
Ejemplo n.º 22
0
 public function testContainerIsStoredInRegistry()
 {
     $options = array('pages' => array(new MvcPage(array('action' => 'index', 'controller' => 'index'))), 'storage' => array('registry' => true));
     $resource = new NavigationResource($options);
     $resource->setBootstrap($this->bootstrap)->init();
     $key = NavigationResource::DEFAULT_REGISTRY_KEY;
     $this->assertEquals(Registry::isRegistered($key), true);
     $container = Registry::get($key);
     $number = $container->count();
     $this->assertEquals($number, 1);
 }
Ejemplo n.º 23
0
 public function testOptionsPassedToResourceAreUsedToSetLocaleState()
 {
     $options = array('default' => 'kok_IN', 'registry_key' => 'Foo_Bar', 'force' => true);
     $resource = new LocaleResource($options);
     $resource->setBootstrap($this->bootstrap);
     $resource->init();
     $locale = $resource->getLocale();
     $this->assertEquals('kok_IN', $locale->__toString());
     $this->assertTrue(Registry::isRegistered('Foo_Bar'));
     $this->assertSame(Registry::get('Foo_Bar'), $locale);
 }
Ejemplo n.º 24
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     foreach (array(Registry\Registry::REGISTRY_KEY, 'Zend_View_Helper_Doctype') as $key) {
         if (\Zend\Registry::isRegistered($key)) {
             $registry = \Zend\Registry::getInstance();
             unset($registry[$key]);
         }
     }
     $this->basePath = dirname(__FILE__) . '/_files/modules';
     $this->view = new View\View();
     $this->helper = new Helper\HeadLink();
     $this->helper->setView($this->view);
 }
Ejemplo n.º 25
0
 public function setUp()
 {
     $regKey = 'Zend_View_Helper_Doctype';
     if (Registry::isRegistered($regKey)) {
         $registry = Registry::getInstance();
         unset($registry[$regKey]);
     }
     $this->renderer = new PhpRenderer();
     $helpers = $this->renderer->getHelperPluginManager();
     $config = new HelperConfiguration();
     $config->configureServiceManager($helpers);
     $this->helper->setView($this->renderer);
 }
Ejemplo n.º 26
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     foreach (array(PlaceholderRegistry::REGISTRY_KEY, 'Zend_View_Helper_Doctype') as $key) {
         if (Registry::isRegistered($key)) {
             $registry = Registry::getInstance();
             unset($registry[$key]);
         }
     }
     $this->basePath = __DIR__ . '/_files/modules';
     $this->view = new View();
     $this->helper = new Helper\HeadLink();
     $this->helper->setView($this->view);
 }
Ejemplo n.º 27
0
    public function setUp()
    {
        $regKey = 'Zend_View_Helper_Doctype';
        if (Registry::isRegistered($regKey)) {
            $registry = Registry::getInstance();
            unset($registry[$regKey]);
        }

        $this->renderer = new PhpRenderer;
        $broker = $this->renderer->getBroker();
        $loader = $broker->getClassLoader();
        $loader->registerPlugins(new HelperLoader());
        $this->helper->setView($this->renderer);
    }
Ejemplo n.º 28
0
 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->error = false;
     foreach (array(Registry::REGISTRY_KEY, 'Zend_View_Helper_Doctype') as $key) {
         if (\Zend\Registry::isRegistered($key)) {
             $registry = \Zend\Registry::getInstance();
             unset($registry[$key]);
         }
     }
     $this->basePath = __DIR__ . '/_files/modules';
     $this->view = new View\View();
     $this->view->doctype('XHTML1_STRICT');
     $this->helper = new Helper\HeadMeta();
     $this->helper->setView($this->view);
 }
Ejemplo n.º 29
0
 /**
  * Constructor for the integer validator
  *
  * Accepts either a string locale, a Zend_Locale object, or an array or
  * Zend_Config object containing the keys "locale" and/or "format".
  *
  * @param string|Zend_Locale|array|\Zend\Config\Config $options
  * @throws \Zend\Validator\Exception On empty format
  */
 public function __construct($options = null)
 {
     if (empty($options)) {
         if (\Zend\Registry::isRegistered('Zend_Locale')) {
             $this->setLocale(\Zend\Registry::get('Zend_Locale'));
         }
     } elseif ($options instanceof Locale\Locale || is_string($options)) {
         // Received Locale object or string locale
         $this->setLocale($options);
     }
     parent::__construct($options);
     $format = $this->getFormat();
     if (empty($format)) {
         throw new Exception\InvalidArgumentException("A postcode-format string has to be given for validation");
     }
 }
Ejemplo n.º 30
0
 public function testShouldProxyToMenuHelperByDeafult()
 {
     // setup
     $oldReg = null;
     if (\Zend\Registry::isRegistered(self::REGISTRY_KEY)) {
         $oldReg = \Zend\Registry::get(self::REGISTRY_KEY);
     }
     \Zend\Registry::set(self::REGISTRY_KEY, $this->_nav1);
     $this->_helper->setContainer(null);
     // result
     $expected = $this->_getExpected('menu/default1.html');
     $actual = $this->_helper->render();
     // teardown
     \Zend\Registry::set(self::REGISTRY_KEY, $oldReg);
     $this->assertEquals($expected, $actual);
 }