Ejemplo n.º 1
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.º 2
0
 public function setUp()
 {
     $this->forceAutoloader();
     $this->error = false;
     $this->manager = new SessionManager();
     Registry::_unsetInstance();
 }
Ejemplo n.º 3
0
 /**
  * Returns TRUE if the $index is a named value in the registry,
  * or FALSE if $index was not found in the registry.
  *
  * @param  string $index
  * @return boolean
  */
 public static function isRegistered($index)
 {
     if (self::$_registry === null) {
         return false;
     }
     return self::$_registry->offsetExists($index);
 }
Ejemplo n.º 4
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.º 5
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()
    {
        Registry::_unsetInstance();
        DojoHelper::setUseDeclarative();

        $this->view   = $this->getView();
    }
Ejemplo n.º 6
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.º 7
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()
 {
     Registry::_unsetInstance();
     DojoHelper::setUseDeclarative();
     $this->view = $this->getView();
     $this->helper = new TextareaHelper();
     $this->helper->setView($this->view);
 }
Ejemplo n.º 8
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()
 {
     Registry::_unsetInstance();
     DojoHelper::setUseDeclarative();
     $this->view = $this->getView();
     $this->helper = new AccordionContainerHelper();
     $this->helper->setView($this->view);
 }
Ejemplo n.º 9
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()
 {
     $registry = Registry::getInstance();
     if (isset($registry['Zend\\Dojo\\View\\Helper\\Dojo'])) {
         unset($registry['Zend\\Dojo\\View\\Helper\\Dojo']);
     }
     $this->view = new View\PhpRenderer();
     \Zend\Dojo\Dojo::enableView($this->view);
 }
Ejemplo n.º 10
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.º 11
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()
 {
     Registry::_unsetInstance();
     $this->view   = $this->getView();
     $this->helper = new DojoContainer();
     $this->helper->setView($this->view);
     Registry::set('Zend\Dojo\View\Helper\Dojo', $this->helper);
     DojoHelper::setUseProgrammatic();
 }
Ejemplo n.º 12
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.º 13
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.º 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()
 {
     Registry::_unsetInstance();
     DojoHelper::setUseDeclarative();
     $this->view = $this->getView();
     $this->decorator = new TabContainerDecorator();
     $this->element = $this->getElement();
     $this->element->setView($this->view);
     $this->decorator->setElement($this->element);
 }
Ejemplo n.º 15
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.º 16
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.º 17
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.º 18
0
 /**
  * Constructor
  *
  * Map constants to doctype strings, and set default doctype
  */
 public function __construct()
 {
     if (!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_RDFA1 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.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>')));
         Registry::set($this->_regKey, $this->_registry);
         $this->setDoctype($this->_defaultDoctype);
     } else {
         $this->_registry = Registry::get($this->_regKey);
     }
 }
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::REGISTRY_KEY;
     if (\Zend\Registry::isRegistered($regKey)) {
         $registry = \Zend\Registry::getInstance();
         unset($registry[$regKey]);
     }
     $this->basePath = dirname(__FILE__) . '/_files/modules';
     $this->helper = new Helper\InlineScript();
 }
Ejemplo n.º 20
0
 public function setUp()
 {
     Registry::_unsetInstance();
     Form::setDefaultTranslator(null);
     if (isset($this->error)) {
         unset($this->error);
     }
     $this->loader = new PluginLoader(array('Zend\\Form\\Decorator' => 'Zend/Form/Decorator'));
     $this->group = new DisplayGroup('test', $this->loader);
 }
Ejemplo n.º 21
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.º 22
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.º 23
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.º 24
0
 /**
  * Initialize helper
  *
  * Retrieve container from registry or create new container and store in
  * registry.
  *
  * @return void
  */
 public function __construct()
 {
     $registry = Registry::getInstance();
     $key = __CLASS__;
     if (!isset($registry[$key])) {
         $container = new Dojo\Container();
         $registry[$key] = $container;
     }
     $this->_container = $registry[$key];
 }
Ejemplo n.º 25
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.º 26
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.º 27
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()
 {
     Registry::_unsetInstance();
     DojoHelper::setUseDeclarative();
     $this->errors = array();
     $this->view = $this->getView();
     $this->decorator = new DijitElementDecorator();
     $this->element = $this->getElement();
     $this->element->setView($this->view);
     $this->decorator->setElement($this->element);
 }
Ejemplo n.º 28
0
 /**
  * @group ZF-7352
  */
 public function testTranslationIsAddedIfRegistryKeyExistsAlready()
 {
     $options1 = array('foo' => 'bar');
     $options2 = array_merge_recursive($this->_translationOptions, array('content' => array('message4' => 'bericht4')));
     $translate = new \Zend\Translator\Translator(\Zend\Translator\Translator::AN_ARRAY, $options1);
     Registry::set('Zend_Translator', $translate);
     $resource = new TranslateResource($options2);
     $this->assertTrue($translate === $resource->getTranslate());
     $this->assertEquals('bar', $translate->translate('foo'));
     $this->assertEquals('bericht4', $translate->translate('message4'));
     $this->assertEquals('shouldNotExist', $translate->translate('shouldNotExist'));
 }
Ejemplo n.º 29
0
 /**
  * Constructor
  * 
  * @param string $value
  * @param array $columns
  * @param array|string $cache
  * @param string $criteria
  */
 public function __construct($value, $columns, $cache, $criteria = self::CRITERIA_BEGINS)
 {
     parent::__construct($columns, $value);
     if (empty($cache)) {
         $this->_cache = false;
     } elseif (is_array($cache)) {
         $this->_cache = $cache;
     } else {
         $this->_cache = \Zend\Registry::get($cache);
     }
     $this->_criteria = $criteria;
     $this->_setValue();
 }
Ejemplo n.º 30
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);
 }