/** * 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); }
/** * 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"); } }
/** * 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); }
public function clearRegistry() { if (Registry::isRegistered('Zend_Translator')) { $registry = Registry::getInstance(); unset($registry['Zend_Translator']); } }
public function clearRegistry() { $regKey = 'Zend_Currency'; if (\Zend\Registry::isRegistered($regKey)) { $registry = \Zend\Registry::getInstance(); unset($registry[$regKey]); } }
/** * 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); }
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'; }
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()); }
/** * 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(); }
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); }
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'])); }
/** * 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); }
/** * 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); }
/** * 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(); }
/** * 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); } }
/** * 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; }
/** * 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); }
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'); }
/** * 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(); }
/** * 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); }
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(); }
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); }
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); }
/** * 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); }
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); }
/** * 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); }
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); }
/** * 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); }
/** * 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"); } }
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); }