Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix test suite when ext/intl isn't available #5111

Closed
wants to merge 8 commits into from

6 participants

@dshafik
  • This will hopefully enable the testsuite to run in HHVM (see: this blog post)
  • There were a bunch of errors caused by Zend\I18n\Validator\Int, switching some tests to use Zend\Validation\Digits might be a good idea
@Ocramius
Collaborator

did you look into #5110 first? :)

@dshafik

@Ocramius of... course not. BLAH!

I'll work with @TheFrozenFire to see which works better :)

@samsonasik samsonasik commented on the diff
...endTest/Form/View/Helper/MissingIntlExtensionTest.php
((7 lines not shown))
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Form
+ */
+
+namespace ZendTest\Form\View\Helper;
+
+use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Form\Element\DateSelect;
+use Zend\Form\View\Helper\FormDateSelect as FormDateSelectHelper;
+use Zend\Form\View\Helper\FormDateTimeSelect as FormDateTimeSelectHelper;
+use Zend\Form\View\Helper\FormMonthSelect as FormMonthSelectHelper;
+
+/**
+ * @category Zend
+ * @package Zend_Form
+ * @subpackage UnitTest

remove @category @package and @subpackage

@dshafik
dshafik added a note

I'm not sure why you are wanting to do this? I followed the convention in the other tests.

@dshafik
dshafik added a note

#3508 only applies to library and explicitly says not to apply to tests.

please take a look #3508 , it's old issue that we agree to remove all @category @package and @subpackage. I only comment to remove new created one/all of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@samsonasik samsonasik commented on the diff
...endTest/Form/View/Helper/MissingIntlExtensionTest.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Form

remove @package

@dshafik
dshafik added a note

Same as above: what's the reasoning?

please take a look #3508 , it's old issue that we agree to remove all @category @package and @subpackage annotations.
ping @weierophinney

@dshafik
dshafik added a note

#3508 only applies to library and explicitly says not to apply to tests.

ah, yes. Library only. but I think we need to prevent new created one :)

ping @Maks3w

@Maks3w I can't push someone that decline to remove @package docblock, maybe you can ? :)

@Maks3w Collaborator
Maks3w added a note

@dshafik that docblock tags are deprecated if you use namespaces since the namespace reflects the same info about package categorization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@dshafik

This latest change takes sebastianbergmann/phpunit#997 into account — it's conditional on PHPUnit 3.8 (unreleased) and works with < PHPUnit 3.8 as well for now. Don't let it stop this going in. If @sebastianbergmann rejects the PR I'll patch these tests to remove it.

@Maks3w Maks3w commented on the diff
...endTest/Form/View/Helper/MissingIntlExtensionTest.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Form
+ */
+
+namespace ZendTest\Form\View\Helper;
+
+use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Form\Element\DateSelect;
+use Zend\Form\View\Helper\FormDateSelect as FormDateSelectHelper;
@Maks3w Collaborator
Maks3w added a note

Following framework practice please split this test file and add a new one for each helper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Maks3w Maks3w commented on the diff
tests/ZendTest/I18n/Filter/NumberFormatTest.php
((6 lines not shown))
{
+ if (!extension_loaded('intl')) {
@Maks3w Collaborator
Maks3w added a note

Please remove this from the dataprovider and add it in the test method

@dshafik
dshafik added a note

This is actually required for this to work. The data providers are called BEFORE the test and use ext/intl to generate the test data. If you remove this, the tests will fatal error without ext/intl enabled.

I will not be changing this.

@Maks3w Collaborator
Maks3w added a note

Instead return an empty array.

@dshafik
dshafik added a note

On what condition would I return this array? Your comment makes no sense and doesn't help solve the issue.

You'll notice I do return an empty nested array (otherwise it's an error, instead of a warning) 4 lines down, unless you have a newer version of phpunit which allows you to markTestSkipped in the provider.

@Maks3w Collaborator
Maks3w added a note

@dshafik There is no option for add references to non existing PHPUnit versions. So don't add this kind of code.

@dshafik
dshafik added a note

OK, last try:

The data provider requires ext/intl. The test also requires ext/intl. If ext/intl doesn't exist, it would be correct to skip the test (markTestSkipped). However, the data provider is called before the test (which makes sense, as it gives the arguments for the test method), so it fatal errors before it hits the markTestSkipped.

The obvious solution therefore, is to markTestSkipped in the data provider. In the current PHPUnit (3.7) this is not possible. So you instead return an empty data set.

If you return an empty data set (array(array())), phpunit will emit a warning, and the test suite may be considered failed (e.g. continuous integration that blocks on errors/warnings).

So, I added a PR for PHPUnit to add the ability to markTestSkipped in the provider.

This code in the tests will stop the fatal errors in PHPUnit 3.7 (by checking for ext/intl and returning an empty data set when it doesn't exist) , and in newer versions of PHPUnit (> 3.7, e.g. 3.8-dev) will stop the warnings (and skip the test correctly).

I did not add this just for funsies, I added it for well thought out reasons. If you do not want to merge these changes (after I remove the @package tags) then just close the PR and reject it.

@jmather
jmather added a note

What if instead the test that was dependent on php/intl was moved to a separate php/intl test suite, so that only the test in question is skipped. Is that the core of the issue, @Maks3w? Other tests being skipped? If so, this one just needs to be silo'd in it's own test suite so it can be skipped properly.

@weierophinney Owner

@Maks3w I'm okay with it as written, as it allows changing the behavior based on PHPUnit version. The logic here is sound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Maks3w Maks3w commented on the diff
tests/ZendTest/I18n/Filter/NumberFormatTest.php
@@ -91,8 +106,16 @@ public static function numberToFormattedProvider()
);
}
- public static function formattedToNumberProvider()
+ public function formattedToNumberProvider()
@Maks3w Collaborator
Maks3w added a note

here too

@dshafik
dshafik added a note

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Maks3w Maks3w commented on the diff
tests/ZendTest/I18n/Validator/DateTimeTest.php
@@ -65,6 +71,14 @@ public function testBasic($value, $expected, $options = array())
public function basicProvider()
{
+ if (!extension_loaded('intl')) {
+ if (version_compare(\PHPUnit_Runner_Version::VERSION, '3.8.0-dev') === 1) {
@Maks3w Collaborator
Maks3w added a note

here too

@dshafik
dshafik added a note

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Maks3w Maks3w commented on the diff
tests/ZendTest/I18n/View/Helper/DateFormatTest.php
@@ -55,6 +59,14 @@ public function tearDown()
public function dateTestsDataProvider()
{
+ if (!extension_loaded('intl')) {
+ if (version_compare(\PHPUnit_Runner_Version::VERSION, '3.8.0-dev') === 1) {
@Maks3w Collaborator
Maks3w added a note

here too

@dshafik
dshafik added a note

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Maks3w Maks3w commented on the diff
tests/ZendTest/I18n/View/Helper/DateFormatTest.php
@@ -147,6 +159,14 @@ public function dateTestsDataProvider()
public function dateTestsDataProviderWithPattern()
{
+ if (!extension_loaded('intl')) {
@Maks3w Collaborator
Maks3w added a note

here too

@dshafik
dshafik added a note

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Maks3w Maks3w commented on the diff
tests/ZendTest/I18n/View/Helper/NumberFormatTest.php
@@ -54,6 +58,14 @@ public function tearDown()
public function currencyTestsDataProvider()
{
+ if (!extension_loaded('intl')) {
+ if (version_compare(\PHPUnit_Runner_Version::VERSION, '3.8.0-dev') === 1) {
@Maks3w Collaborator
Maks3w added a note

here too

@dshafik
dshafik added a note

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Maks3w
Collaborator

@dshafik ZF2 has a minimum requirement on PHPUnit 3.7 so why not use @requires annotation?

http://phpunit.de/manual/3.7/en/incomplete-and-skipped-tests.html#incomplete-and-skipped-tests.requires.tables.api

@dshafik

@Maks3w I believe it's because the data provider is still called. I don't remember why they didn't work, but I did try this and other options first.

@Maks3w
Collaborator

@dshafik You'll get a better success in your PHPUnit PR if you prevent trigger @dataProvider when @requires is false

@dshafik

@Maks3w then it would still run in older versions and fatal error. This has to be something that is possible to work in current and newer versions of PHPUnit. Fixing the @dataProvider/@requires thing for > 3.7 doesn't help, this code would STILL need to be in the dataProvider (at least the intl check and return empty data set).

@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#5111] CS fixes
- EOF ending
- Remove unnecessary annotations
a6e86c3
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/5111' into develop
Forward port #5111

Conflicts:
	tests/ZendTest/I18n/Translator/Loader/GettextTest.php
	tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
8644746
@Maks3w
Collaborator

@weierophinney The referenced PHPUnit versions DON'T EXISTS! The patch proposed is not merged.

@weierophinney

@Maks3w If Sebastian chooses not to merge it, @dshafik has indicated he'll issue a revert. Indications at this point are that it will be merged, however.

@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-config
@weierophinney weierophinney Merge pull request zendframework/zf2#5111 from dshafik/fix/ext-intl-m…
…issing-failure

Fix test suite when ext/intl isn't available
c8a1dba
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-config
@weierophinney weierophinney Merge branch 'hotfix/5111' c6bda54
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-config
@weierophinney weierophinney Merge branch 'hotfix/5111' into develop
Forward port zendframework/zf2#5111

Conflicts:
	tests/ZendTest/I18n/Translator/Loader/GettextTest.php
	tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
d97c259
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-i18n
@weierophinney weierophinney Merge pull request zendframework/zf2#5111 from dshafik/fix/ext-intl-m…
…issing-failure

Fix test suite when ext/intl isn't available
80d00fa
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-i18n
@weierophinney weierophinney Merge branch 'hotfix/5111' c05aee7
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-i18n
@weierophinney weierophinney Merge branch 'hotfix/5111' into develop
Forward port zendframework/zf2#5111

Conflicts:
	tests/ZendTest/I18n/Translator/Loader/GettextTest.php
	tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
39d06a8
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-inputfilter
@weierophinney weierophinney Merge pull request zendframework/zf2#5111 from dshafik/fix/ext-intl-m…
…issing-failure

Fix test suite when ext/intl isn't available
347844b
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-inputfilter
@weierophinney weierophinney Merge branch 'hotfix/5111' 035e666
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-inputfilter
@weierophinney weierophinney Merge branch 'hotfix/5111' into develop
Forward port zendframework/zf2#5111

Conflicts:
	tests/ZendTest/I18n/Translator/Loader/GettextTest.php
	tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
2595c1a
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-filter
@weierophinney weierophinney Merge pull request zendframework/zf2#5111 from dshafik/fix/ext-intl-m…
…issing-failure

Fix test suite when ext/intl isn't available
0e2f483
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-filter
@weierophinney weierophinney Merge branch 'hotfix/5111' 9e7e067
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-filter
@weierophinney weierophinney Merge branch 'hotfix/5111' into develop
Forward port zendframework/zf2#5111

Conflicts:
	tests/ZendTest/I18n/Translator/Loader/GettextTest.php
	tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
2094f47
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-validator
@weierophinney weierophinney Merge pull request zendframework/zf2#5111 from dshafik/fix/ext-intl-m…
…issing-failure

Fix test suite when ext/intl isn't available
fc97106
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-validator
@weierophinney weierophinney Merge branch 'hotfix/5111' 047576f
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-validator
@weierophinney weierophinney Merge branch 'hotfix/5111' into develop
Forward port zendframework/zf2#5111

Conflicts:
	tests/ZendTest/I18n/Translator/Loader/GettextTest.php
	tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
997a8a7
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-log
@weierophinney weierophinney Merge pull request zendframework/zf2#5111 from dshafik/fix/ext-intl-m…
…issing-failure

Fix test suite when ext/intl isn't available
c7cc5bc
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-log
@weierophinney weierophinney Merge branch 'hotfix/5111' e5fd689
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-log
@weierophinney weierophinney Merge branch 'hotfix/5111' into develop
Forward port zendframework/zf2#5111

Conflicts:
	tests/ZendTest/I18n/Translator/Loader/GettextTest.php
	tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
d074ac7
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-view
@weierophinney weierophinney Merge pull request zendframework/zf2#5111 from dshafik/fix/ext-intl-m…
…issing-failure

Fix test suite when ext/intl isn't available
9cbb4dd
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-view
@weierophinney weierophinney Merge branch 'hotfix/5111' 6bc8c90
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-view
@weierophinney weierophinney Merge branch 'hotfix/5111' into develop
Forward port zendframework/zf2#5111

Conflicts:
	tests/ZendTest/I18n/Translator/Loader/GettextTest.php
	tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
b9b648c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 493 additions and 23 deletions.
  1. +41 −0 tests/ZendTest/Config/ProcessorTest.php
  2. +21 −13 tests/ZendTest/Filter/InflectorTest.php
  3. +10 −0 tests/ZendTest/Form/Element/CollectionTest.php
  4. +10 −0 tests/ZendTest/Form/Element/NumberTest.php
  5. +10 −0 tests/ZendTest/Form/Element/RangeTest.php
  6. +25 −0 tests/ZendTest/Form/FormTest.php
  7. +24 −0 tests/ZendTest/Form/View/Helper/CommonTestCase.php
  8. +4 −0 tests/ZendTest/Form/View/Helper/FormDateSelectTest.php
  9. +4 −0 tests/ZendTest/Form/View/Helper/FormDateTimeSelectTest.php
  10. +4 −0 tests/ZendTest/Form/View/Helper/FormMonthSelectTest.php
  11. +62 −0 tests/ZendTest/Form/View/Helper/MissingIntlExtensionTest.php
  12. +4 −0 tests/ZendTest/I18n/Filter/AlnumTest.php
  13. +4 −0 tests/ZendTest/I18n/Filter/AlphaTest.php
  14. +25 −2 tests/ZendTest/I18n/Filter/NumberFormatTest.php
  15. +7 −1 tests/ZendTest/I18n/Translator/Loader/GettextTest.php
  16. +7 −1 tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
  17. +7 −1 tests/ZendTest/I18n/Translator/TranslatorTest.php
  18. +4 −0 tests/ZendTest/I18n/Validator/AlnumTest.php
  19. +4 −0 tests/ZendTest/I18n/Validator/AlphaTest.php
  20. +15 −1 tests/ZendTest/I18n/Validator/DateTimeTest.php
  21. +7 −1 tests/ZendTest/I18n/Validator/FloatTest.php
  22. +12 −1 tests/ZendTest/I18n/Validator/IntTest.php
  23. +4 −0 tests/ZendTest/I18n/Validator/PostCodeTest.php
  24. +4 −0 tests/ZendTest/I18n/View/Helper/CurrencyFormatTest.php
  25. +20 −0 tests/ZendTest/I18n/View/Helper/DateFormatTest.php
  26. +12 −0 tests/ZendTest/I18n/View/Helper/NumberFormatTest.php
  27. +4 −0 tests/ZendTest/I18n/View/Helper/PluralTest.php
  28. +44 −0 tests/ZendTest/InputFilter/BaseInputFilterTest.php
  29. +44 −0 tests/ZendTest/InputFilter/CollectionInputFilterTest.php
  30. +2 −2 tests/ZendTest/Log/Filter/ValidatorTest.php
  31. +12 −0 tests/ZendTest/Validator/AbstractTest.php
  32. +4 −0 tests/ZendTest/Validator/EmailAddressTest.php
  33. +4 −0 tests/ZendTest/Validator/HostnameTest.php
  34. +4 −0 tests/ZendTest/Validator/StaticValidatorTest.php
  35. +4 −0 tests/ZendTest/View/Helper/HeadTitleTest.php
  36. +8 −0 tests/ZendTest/View/Helper/Navigation/BreadcrumbsTest.php
  37. +8 −0 tests/ZendTest/View/Helper/Navigation/MenuTest.php
  38. +4 −0 tests/ZendTest/View/Helper/Navigation/NavigationTest.php
View
41 tests/ZendTest/Config/ProcessorTest.php
@@ -329,6 +329,10 @@ public function testPHPConstants()
public function testTranslator()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$config = new Config($this->translatorData, true);
$translator = new Translator();
$translator->addTranslationFile('phparray', $this->translatorFile);
@@ -342,6 +346,23 @@ public function testTranslator()
$this->assertEquals('zwei Hunde', $config->pages[1]->label);
}
+ public function testTranslatorWithoutIntl()
+ {
+ if (extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl enabled');
+ }
+
+ $this->setExpectedException('Zend\I18n\Exception\ExtensionNotLoadedException',
+ 'Zend\I18n\Translator component requires the intl PHP extension');
+
+ $config = new Config($this->translatorData, true);
+ $translator = new Translator();
+ $translator->addTranslationFile('phparray', $this->translatorFile);
+ $processor = new TranslatorProcessor($translator);
+
+ $processor->process($config);
+ }
+
public function testTranslatorReadOnly()
{
$config = new Config($this->translatorData, false);
@@ -355,6 +376,26 @@ public function testTranslatorReadOnly()
public function testTranslatorSingleValue()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
+ $translator = new Translator();
+ $translator->addTranslationFile('phparray', $this->translatorFile);
+ $processor = new TranslatorProcessor($translator);
+
+ $this->assertEquals('ein Hund', $processor->processValue('one dog'));
+ }
+
+ public function testTranslatorSingleValueWithoutIntl()
+ {
+ if (extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl enabled');
+ }
+
+ $this->setExpectedException('Zend\I18n\Exception\ExtensionNotLoadedException',
+ 'Zend\I18n\Translator component requires the intl PHP extension');
+
$translator = new Translator();
$translator->addTranslationFile('phparray', $this->translatorFile);
$processor = new TranslatorProcessor($translator);
View
34 tests/ZendTest/Filter/InflectorTest.php
@@ -111,8 +111,12 @@ public function testSetFilterRuleWithFilterObjectCreatesRuleEntryWithFilterObjec
$this->assertSame($filter, $received);
}
- public function testSetFilterRuleWithArrayOfRulesCreatesRuleEntries()
+ public function testAddFilterRuleAppendsRuleEntries()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$rules = $this->inflector->getRules();
$this->assertEquals(0, count($rules));
$this->inflector->setFilterRule('controller', array('PregReplace', 'Alpha'));
@@ -122,18 +126,6 @@ public function testSetFilterRuleWithArrayOfRulesCreatesRuleEntries()
$this->assertTrue($rules[1] instanceof \Zend\Filter\FilterInterface);
}
- public function testAddFilterRuleAppendsRuleEntries()
- {
- $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', 'Alpha');
- $rules = $this->inflector->getRules('controller');
- $this->assertEquals(2, count($rules));
- }
-
public function testSetStaticRuleCreatesScalarRuleEntry()
{
$rules = $this->inflector->getRules();
@@ -170,6 +162,10 @@ public function testSetStaticRuleReferenceAllowsUpdatingRuleByReference()
public function testAddRulesCreatesAppropriateRuleEntries()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$rules = $this->inflector->getRules();
$this->assertEquals(0, count($rules));
$this->inflector->addRules(array(
@@ -184,6 +180,10 @@ public function testAddRulesCreatesAppropriateRuleEntries()
public function testSetRulesCreatesAppropriateRuleEntries()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->inflector->setStaticRule('some-rules', 'some-value');
$rules = $this->inflector->getRules();
$this->assertEquals(1, count($rules));
@@ -199,6 +199,10 @@ public function testSetRulesCreatesAppropriateRuleEntries()
public function testGetRule()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->inflector->setFilterRule(':controller', array('Alpha', 'StringToLower'));
$this->assertTrue($this->inflector->getRule('controller', 1) instanceof \Zend\Filter\StringToLower);
$this->assertFalse($this->inflector->getRule('controller', 2));
@@ -414,6 +418,10 @@ public function testNoInflectableTarget()
*/
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');
View
10 tests/ZendTest/Form/Element/CollectionTest.php
@@ -288,6 +288,11 @@ public function testExtractFromObjectDoesntTouchOriginalObject()
public function testDoesNotCreateNewObjects()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$form = new \Zend\Form\Form();
$form->setHydrator(new \Zend\Stdlib\Hydrator\ClassMethods());
$this->productFieldset->setUseAsBaseFieldset(true);
@@ -326,6 +331,11 @@ public function testDoesNotCreateNewObjects()
public function testCreatesNewObjectsIfSpecified()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->productFieldset->setUseAsBaseFieldset(true);
$categories = $this->productFieldset->get('categories');
$categories->setOptions(array(
View
10 tests/ZendTest/Form/Element/NumberTest.php
@@ -17,6 +17,11 @@ class NumberTest extends TestCase
{
public function testProvidesInputSpecificationWithDefaultAttributes()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$element = new NumberElement();
$inputSpec = $element->getInputSpecification();
@@ -42,6 +47,11 @@ public function testProvidesInputSpecificationWithDefaultAttributes()
public function testProvidesInputSpecificationThatIncludesValidatorsBasedOnAttributes()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$element = new NumberElement();
$element->setAttributes(array(
'inclusive' => true,
View
10 tests/ZendTest/Form/Element/RangeTest.php
@@ -17,6 +17,11 @@ class RangeTest extends TestCase
{
public function testProvidesInputSpecificationWithDefaultAttributes()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$element = new RangeElement();
$inputSpec = $element->getInputSpecification();
@@ -52,6 +57,11 @@ public function testProvidesInputSpecificationWithDefaultAttributes()
public function testProvidesInputSpecificationThatIncludesValidator()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$element = new RangeElement();
$element->setAttributes(array(
'inclusive' => true,
View
25 tests/ZendTest/Form/FormTest.php
@@ -208,6 +208,11 @@ public function testCallingIsValidRaisesExceptionIfNoDataSet()
public function testHasValidatedFlag()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$form = new TestAsset\NewProductForm();
$this->assertFalse($form->hasValidated());
@@ -247,6 +252,11 @@ public function testValidatesEntireDataSetByDefault()
public function testSpecifyingValidationGroupForcesPartialValidation()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->populateForm();
$invalidSet = array(
'foo' => 'a',
@@ -264,6 +274,11 @@ public function testSpecifyingValidationGroupForcesPartialValidation()
public function testSpecifyingValidationGroupForNestedFieldsetsForcesPartialValidation()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$form = new TestAsset\NewProductForm();
$form->setData(array(
'product' => array(
@@ -985,6 +1000,11 @@ public function testCanCorrectlyPopulateDataToComposedEntities()
public function testCanCorrectlyExtractDataFromOneToManyRelationship()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$product = $this->getOneToManyEntity();
$form = new TestAsset\NewProductForm();
@@ -1472,6 +1492,11 @@ public function testGetValidationGroupReturnsNullWhenNoneSet()
public function testPreserveEntitiesBoundToCollectionAfterValidation()
{
+ if (!extension_loaded('intl')) {
+ // Required by \Zend\I18n\Validator\Float
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->form->setInputFilter(new \Zend\InputFilter\InputFilter());
$fieldset = new TestAsset\ProductCategoriesFieldset();
$fieldset->setUseAsBaseFieldset(true);
View
24 tests/ZendTest/Form/View/Helper/CommonTestCase.php
@@ -41,17 +41,29 @@ public function setUp()
public function testUsesUtf8ByDefault()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->assertEquals('UTF-8', $this->helper->getEncoding());
}
public function testCanInjectEncoding()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->helper->setEncoding('iso-8859-1');
$this->assertEquals('iso-8859-1', $this->helper->getEncoding());
}
public function testInjectingEncodingProxiesToEscapeHelper()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$escape = $this->renderer->plugin('escapehtml');
$this->helper->setEncoding('iso-8859-1');
$this->assertEquals('iso-8859-1', $escape->getEncoding());
@@ -59,6 +71,10 @@ public function testInjectingEncodingProxiesToEscapeHelper()
public function testAssumesHtml4LooseDoctypeByDefault()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$helperClass = get_class($this->helper);
$helper = new $helperClass();
$this->assertEquals(Doctype::HTML4_LOOSE, $helper->getDoctype());
@@ -66,12 +82,20 @@ public function testAssumesHtml4LooseDoctypeByDefault()
public function testCanInjectDoctype()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->helper->setDoctype(Doctype::HTML5);
$this->assertEquals(Doctype::HTML5, $this->helper->getDoctype());
}
public function testCanGetDoctypeFromDoctypeHelper()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->renderer->doctype(Doctype::XHTML1_STRICT);
$this->assertEquals(Doctype::XHTML1_STRICT, $this->helper->getDoctype());
}
View
4 tests/ZendTest/Form/View/Helper/FormDateSelectTest.php
@@ -22,6 +22,10 @@ class FormDateSelectTest extends CommonTestCase
{
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->helper = new FormDateSelectHelper();
parent::setUp();
}
View
4 tests/ZendTest/Form/View/Helper/FormDateTimeSelectTest.php
@@ -22,6 +22,10 @@ class FormDateTimeSelectTest extends CommonTestCase
{
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->helper = new FormDateTimeSelectHelper();
parent::setUp();
}
View
4 tests/ZendTest/Form/View/Helper/FormMonthSelectTest.php
@@ -22,6 +22,10 @@ class FormMonthSelectTest extends CommonTestCase
{
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->helper = new FormMonthSelectHelper();
parent::setUp();
}
View
62 tests/ZendTest/Form/View/Helper/MissingIntlExtensionTest.php
@@ -0,0 +1,62 @@
+<?php
+/**
+ * Zend Framework (http://framework.zend.com/)
+ *
+ * @link http://github.com/zendframework/zf2 for the canonical source repository
+ * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @package Zend_Form

remove @package

@dshafik
dshafik added a note

Same as above: what's the reasoning?

please take a look #3508 , it's old issue that we agree to remove all @category @package and @subpackage annotations.
ping @weierophinney

@dshafik
dshafik added a note

#3508 only applies to library and explicitly says not to apply to tests.

ah, yes. Library only. but I think we need to prevent new created one :)

ping @Maks3w

@Maks3w I can't push someone that decline to remove @package docblock, maybe you can ? :)

@Maks3w Collaborator
Maks3w added a note

@dshafik that docblock tags are deprecated if you use namespaces since the namespace reflects the same info about package categorization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ */
+
+namespace ZendTest\Form\View\Helper;
+
+use PHPUnit_Framework_TestCase as TestCase;
+use Zend\Form\Element\DateSelect;
+use Zend\Form\View\Helper\FormDateSelect as FormDateSelectHelper;
@Maks3w Collaborator
Maks3w added a note

Following framework practice please split this test file and add a new one for each helper

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+use Zend\Form\View\Helper\FormDateTimeSelect as FormDateTimeSelectHelper;
+use Zend\Form\View\Helper\FormMonthSelect as FormMonthSelectHelper;
+
+/**
+ * @category Zend
+ * @package Zend_Form
+ * @subpackage UnitTest

remove @category @package and @subpackage

@dshafik
dshafik added a note

I'm not sure why you are wanting to do this? I followed the convention in the other tests.

@dshafik
dshafik added a note

#3508 only applies to library and explicitly says not to apply to tests.

please take a look #3508 , it's old issue that we agree to remove all @category @package and @subpackage. I only comment to remove new created one/all of them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ */
+class MissingIntlExtensionTest extends TestCase
+{
+ public function setUp()
+ {
+ if (extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl enabled');
+ }
+ }
+
+ public function testFormDateSelectHelper()
+ {
+ $this->setExpectedException(
+ 'Zend\Form\Exception\ExtensionNotLoadedException',
+ 'Zend\Form\View\Helper component requires the intl PHP extension'
+ );
+
+ $helper = new FormDateSelectHelper();
+ }
+
+ public function testFormDateTimeSelectHelper()
+ {
+ $this->setExpectedException(
+ 'Zend\Form\Exception\ExtensionNotLoadedException',
+ 'Zend\Form\View\Helper component requires the intl PHP extension'
+ );
+
+ $helper = new FormDateTimeSelectHelper();
+ }
+
+ public function testFormMonthSelectHelper()
+ {
+ $this->setExpectedException(
+ 'Zend\Form\Exception\ExtensionNotLoadedException',
+ 'Zend\Form\View\Helper component requires the intl PHP extension'
+ );
+
+ $helper = new FormMonthSelectHelper();
+ }
+}
View
4 tests/ZendTest/I18n/Filter/AlnumTest.php
@@ -56,6 +56,10 @@ class AlnumTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->filter = new AlnumFilter();
$this->locale = Locale::getDefault();
View
4 tests/ZendTest/I18n/Filter/AlphaTest.php
@@ -56,6 +56,10 @@ class AlphaTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->filter = new AlphaFilter();
$this->locale = Locale::getDefault();
View
27 tests/ZendTest/I18n/Filter/NumberFormatTest.php
@@ -16,6 +16,13 @@
class NumberFormatTest extends TestCase
{
+ public function setUp()
+ {
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+ }
+
public function testConstructWithOptions()
{
$filter = new NumberFormatFilter(array(
@@ -64,8 +71,16 @@ public function testFormattedToNumber($locale, $style, $type, $value, $expected)
$this->assertEquals($expected, $filter->filter($value));
}
- public static function numberToFormattedProvider()
+ public function numberToFormattedProvider()
{
+ if (!extension_loaded('intl')) {
@Maks3w Collaborator
Maks3w added a note

Please remove this from the dataprovider and add it in the test method

@dshafik
dshafik added a note

This is actually required for this to work. The data providers are called BEFORE the test and use ext/intl to generate the test data. If you remove this, the tests will fatal error without ext/intl enabled.

I will not be changing this.

@Maks3w Collaborator
Maks3w added a note

Instead return an empty array.

@dshafik
dshafik added a note

On what condition would I return this array? Your comment makes no sense and doesn't help solve the issue.

You'll notice I do return an empty nested array (otherwise it's an error, instead of a warning) 4 lines down, unless you have a newer version of phpunit which allows you to markTestSkipped in the provider.

@Maks3w Collaborator
Maks3w added a note

@dshafik There is no option for add references to non existing PHPUnit versions. So don't add this kind of code.

@dshafik
dshafik added a note

OK, last try:

The data provider requires ext/intl. The test also requires ext/intl. If ext/intl doesn't exist, it would be correct to skip the test (markTestSkipped). However, the data provider is called before the test (which makes sense, as it gives the arguments for the test method), so it fatal errors before it hits the markTestSkipped.

The obvious solution therefore, is to markTestSkipped in the data provider. In the current PHPUnit (3.7) this is not possible. So you instead return an empty data set.

If you return an empty data set (array(array())), phpunit will emit a warning, and the test suite may be considered failed (e.g. continuous integration that blocks on errors/warnings).

So, I added a PR for PHPUnit to add the ability to markTestSkipped in the provider.

This code in the tests will stop the fatal errors in PHPUnit 3.7 (by checking for ext/intl and returning an empty data set when it doesn't exist) , and in newer versions of PHPUnit (> 3.7, e.g. 3.8-dev) will stop the warnings (and skip the test correctly).

I did not add this just for funsies, I added it for well thought out reasons. If you do not want to merge these changes (after I remove the @package tags) then just close the PR and reject it.

@jmather
jmather added a note

What if instead the test that was dependent on php/intl was moved to a separate php/intl test suite, so that only the test in question is skipped. Is that the core of the issue, @Maks3w? Other tests being skipped? If so, this one just needs to be silo'd in it's own test suite so it can be skipped properly.

@weierophinney Owner

@Maks3w I'm okay with it as written, as it allows changing the behavior based on PHPUnit version. The logic here is sound.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if (version_compare(\PHPUnit_Runner_Version::VERSION, '3.8.0-dev') === 1) {
+ $this->markTestSkipped('ext/intl not enabled');
+ } else {
+ return array(array());
+ }
+ }
+
return array(
array(
'en_US',
@@ -91,8 +106,16 @@ public static function numberToFormattedProvider()
);
}
- public static function formattedToNumberProvider()
+ public function formattedToNumberProvider()
@Maks3w Collaborator
Maks3w added a note

here too

@dshafik
dshafik added a note

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
{
+ if (!extension_loaded('intl')) {
+ if (version_compare(\PHPUnit_Runner_Version::VERSION, '3.8.0-dev') === 1) {
+ $this->markTestSkipped('ext/intl not enabled');
+ } else {
+ return array(array());
+ }
+ }
+
return array(
array(
'en_US',
View
8 tests/ZendTest/I18n/Translator/Loader/GettextTest.php
@@ -21,6 +21,10 @@ class GettextTest extends TestCase
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->originalLocale = Locale::getDefault();
Locale::setDefault('en_EN');
@@ -29,7 +33,9 @@ public function setUp()
public function tearDown()
{
- Locale::setDefault($this->originalLocale);
+ if (extension_loaded('intl')) {
+ Locale::setDefault($this->originalLocale);
+ }
}
public function testLoaderFailsToLoadMissingFile()
View
8 tests/ZendTest/I18n/Translator/Loader/PhpArrayTest.php
@@ -21,6 +21,10 @@ class PhpArrayTest extends TestCase
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->originalLocale = Locale::getDefault();
Locale::setDefault('en_EN');
@@ -29,7 +33,9 @@ public function setUp()
public function tearDown()
{
- Locale::setDefault($this->originalLocale);
+ if (extension_loaded('intl')) {
+ Locale::setDefault($this->originalLocale);
+ }
}
public function testLoaderFailsToLoadMissingFile()
View
8 tests/ZendTest/I18n/Translator/TranslatorTest.php
@@ -36,6 +36,10 @@ class TranslatorTest extends TestCase
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->originalLocale = Locale::getDefault();
$this->translator = new Translator();
@@ -46,7 +50,9 @@ public function setUp()
public function tearDown()
{
- Locale::setDefault($this->originalLocale);
+ if (extension_loaded('intl')) {
+ Locale::setDefault($this->originalLocale);
+ }
}
public function testFactoryCreatesTranslator()
View
4 tests/ZendTest/I18n/Validator/AlnumTest.php
@@ -32,6 +32,10 @@ class AlnumTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->validator = new AlnumValidator();
}
View
4 tests/ZendTest/I18n/Validator/AlphaTest.php
@@ -27,6 +27,10 @@ class AlphaTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->validator = new AlphaValidator();
}
View
16 tests/ZendTest/I18n/Validator/DateTimeTest.php
@@ -32,6 +32,10 @@ class DateTimeTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->locale = Locale::getDefault();
$this->timezone = date_default_timezone_get();
@@ -40,7 +44,9 @@ public function setUp()
public function tearDown()
{
- Locale::setDefault($this->locale);
+ if (extension_loaded('intl')) {
+ Locale::setDefault($this->locale);
+ }
date_default_timezone_set($this->timezone);
}
@@ -65,6 +71,14 @@ public function testBasic($value, $expected, $options = array())
public function basicProvider()
{
+ if (!extension_loaded('intl')) {
+ if (version_compare(\PHPUnit_Runner_Version::VERSION, '3.8.0-dev') === 1) {
@Maks3w Collaborator
Maks3w added a note

here too

@dshafik
dshafik added a note

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ $this->markTestSkipped('ext/intl not enabled');
+ } else {
+ return array(array());
+ }
+ }
+
return array(
array('May 30, 2013', true, array('locale'=>'en', 'dateType' => \IntlDateFormatter::MEDIUM, 'timeType' => \IntlDateFormatter::NONE)),
array('30.Mai.2013', true, array('locale'=>'de', 'dateType' => \IntlDateFormatter::MEDIUM, 'timeType' => \IntlDateFormatter::NONE)),
View
8 tests/ZendTest/I18n/Validator/FloatTest.php
@@ -31,13 +31,19 @@ class FloatTest extends \PHPUnit_Framework_TestCase
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->locale = Locale::getDefault();
$this->validator = new FloatValidator(array('locale' => 'en'));
}
public function tearDown()
{
- Locale::setDefault($this->locale);
+ if (extension_loaded('intl')) {
+ Locale::setDefault($this->locale);
+ }
}
/**
View
13 tests/ZendTest/I18n/Validator/IntTest.php
@@ -26,15 +26,26 @@ class IntTest extends \PHPUnit_Framework_TestCase
*/
protected $validator;
+ /**
+ * @var string
+ */
+ protected $locale;
+
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->locale = Locale::getDefault();
$this->validator = new IntValidator();
}
public function tearDown()
{
- Locale::setDefault($this->locale);
+ if (extension_loaded('intl')) {
+ Locale::setDefault($this->locale);
+ }
}
public function intDataProvider()
View
4 tests/ZendTest/I18n/Validator/PostCodeTest.php
@@ -32,6 +32,10 @@ class PostCodeTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->validator = new PostCodeValidator(array('locale' => 'de_AT'));
}
View
4 tests/ZendTest/I18n/View/Helper/CurrencyFormatTest.php
@@ -35,6 +35,10 @@ class CurrencyFormatTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->helper = new CurrencyFormatHelper();
}
View
20 tests/ZendTest/I18n/View/Helper/DateFormatTest.php
@@ -39,6 +39,10 @@ class DateFormatTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->helper = new DateFormatHelper();
}
@@ -55,6 +59,14 @@ public function tearDown()
public function dateTestsDataProvider()
{
+ if (!extension_loaded('intl')) {
+ if (version_compare(\PHPUnit_Runner_Version::VERSION, '3.8.0-dev') === 1) {
@Maks3w Collaborator
Maks3w added a note

here too

@dshafik
dshafik added a note

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ $this->markTestSkipped('ext/intl not enabled');
+ } else {
+ return array(array());
+ }
+ }
+
$date = new DateTime('2012-07-02T22:44:03Z');
return array(
@@ -147,6 +159,14 @@ public function dateTestsDataProvider()
public function dateTestsDataProviderWithPattern()
{
+ if (!extension_loaded('intl')) {
@Maks3w Collaborator
Maks3w added a note

here too

@dshafik
dshafik added a note

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if (version_compare(\PHPUnit_Runner_Version::VERSION, '3.8.0-dev') === 1) {
+ $this->markTestSkipped('ext/intl not enabled');
+ } else {
+ return array(array());
+ }
+ }
+
$date = new DateTime('2012-07-02T22:44:03Z');
return array(
View
12 tests/ZendTest/I18n/View/Helper/NumberFormatTest.php
@@ -38,6 +38,10 @@ class NumberFormatTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->helper = new NumberFormatHelper();
}
@@ -54,6 +58,14 @@ public function tearDown()
public function currencyTestsDataProvider()
{
+ if (!extension_loaded('intl')) {
+ if (version_compare(\PHPUnit_Runner_Version::VERSION, '3.8.0-dev') === 1) {
@Maks3w Collaborator
Maks3w added a note

here too

@dshafik
dshafik added a note

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ $this->markTestSkipped('ext/intl not enabled');
+ } else {
+ return array(array());
+ }
+ }
+
return array(
array(
'de_DE',
View
4 tests/ZendTest/I18n/View/Helper/PluralTest.php
@@ -34,6 +34,10 @@ class PluralTest extends \PHPUnit_Framework_TestCase
*/
public function setUp()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->helper = new PluralHelper();
}
View
44 tests/ZendTest/InputFilter/BaseInputFilterTest.php
@@ -188,6 +188,10 @@ public function dataSets()
*/
public function testCanValidateEntireDataset($dataset, $expected)
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$filter->setData($dataset);
$this->assertSame($expected, $filter->isValid());
@@ -195,6 +199,10 @@ public function testCanValidateEntireDataset($dataset, $expected)
public function testCanValidatePartialDataset()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$validData = array(
'foo' => ' bazbat ',
@@ -218,6 +226,10 @@ public function testCanValidatePartialDataset()
public function testCanRetrieveInvalidInputsOnFailedValidation()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$invalidData = array(
'foo' => ' bazbat ',
@@ -243,6 +255,10 @@ public function testCanRetrieveInvalidInputsOnFailedValidation()
public function testCanRetrieveValidInputsOnFailedValidation()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$invalidData = array(
'foo' => ' bazbat ',
@@ -269,6 +285,10 @@ public function testCanRetrieveValidInputsOnFailedValidation()
public function testValuesRetrievedAreFiltered()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$validData = array(
'foo' => ' bazbat ',
@@ -297,6 +317,10 @@ public function testValuesRetrievedAreFiltered()
public function testCanGetRawInputValues()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$validData = array(
'foo' => ' bazbat ',
@@ -316,6 +340,10 @@ public function testCanGetRawInputValues()
public function testCanGetValidationMessages()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$filter->get('baz')->setRequired(true);
$filter->get('nest')->get('baz')->setRequired(true);
@@ -622,6 +650,10 @@ public function testValidationMarksInputValidWhenAllowEmptyFlagIsTrueAndContinue
public function testCanRetrieveRawValuesIndividuallyWithoutValidating()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$data = array(
'foo' => ' bazbat ',
@@ -638,6 +670,10 @@ public function testCanRetrieveRawValuesIndividuallyWithoutValidating()
public function testCanRetrieveUnvalidatedButFilteredInputValue()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$data = array(
'foo' => ' baz 2 bat ',
@@ -672,6 +708,10 @@ public function testGetRequiredNotEmptyValidationMessages()
}
public function testHasUnknown()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$validData = array(
'foo' => ' bazbat ',
@@ -692,6 +732,10 @@ public function testHasUnknown()
}
public function testGetUknown()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$filter = $this->getInputFilter();
$unknown = array(
'bar' => '12345',
View
44 tests/ZendTest/InputFilter/CollectionInputFilterTest.php
@@ -111,6 +111,10 @@ public function testSetInputFilter()
public function testInputFilterInputsAppliedToCollection()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->filter->setInputFilter($this->getBaseInputFilter());
$this->assertCount(4, $this->filter->getInputs());
@@ -158,6 +162,10 @@ public function testGetCountUsesSpecifiedCount()
public function testCanValidateValidData()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->filter->setInputFilter($this->getBaseInputFilter());
$this->filter->setData($this->getValidCollectionData());
$this->assertTrue($this->filter->isValid());
@@ -165,6 +173,10 @@ public function testCanValidateValidData()
public function testCanValidateValidDataWithNonConsecutiveKeys()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$collectionData = $this->getValidCollectionData();
$collectionData[2] = $collectionData[0];
unset($collectionData[0]);
@@ -175,6 +187,10 @@ public function testCanValidateValidDataWithNonConsecutiveKeys()
public function testInvalidDataReturnsFalse()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$invalidCollectionData = array(
array(
'foo' => ' bazbatlong ',
@@ -195,6 +211,10 @@ public function testInvalidDataReturnsFalse()
public function testDataLessThanCountIsInvalid()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$invalidCollectionData = array(
array(
'foo' => ' bazbat ',
@@ -216,6 +236,10 @@ public function testDataLessThanCountIsInvalid()
public function testGetValues()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$expectedData = array(
array(
'foo' => 'bazbat',
@@ -253,6 +277,10 @@ public function testGetValues()
public function testGetRawValues()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$expectedData = array(
array(
'foo' => ' bazbat ',
@@ -285,6 +313,10 @@ public function testGetRawValues()
public function testGetMessagesForInvalidInputs()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$invalidCollectionData = array(
array(
'foo' => ' bazbattoolong ',
@@ -327,6 +359,10 @@ public function testGetMessagesForInvalidInputs()
public function testSetValidationGroupUsingFormStyle()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
// forms set an array of identical validation groups for each set of data
$formValidationGroup = array(
array(
@@ -367,6 +403,10 @@ public function testSetValidationGroupUsingFormStyle()
public function testEmptyCollectionIsValidByDefault()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$data = array();
$this->filter->setInputFilter($this->getBaseInputFilter());
@@ -377,6 +417,10 @@ public function testEmptyCollectionIsValidByDefault()
public function testEmptyCollectionIsNotValidIfRequired()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$data = array();
$this->filter->setInputFilter($this->getBaseInputFilter());
View
4 tests/ZendTest/Log/Filter/ValidatorTest.php
@@ -13,7 +13,7 @@
use Zend\Log\Filter\Validator;
use Zend\Validator\ValidatorChain;
use Zend\Validator\Digits as DigitsFilter;
-use Zend\I18n\Validator\Int;
+use Zend\Validator\NotEmpty as NotEmptyFilter;
/**
* @category Zend
@@ -35,8 +35,8 @@ public function testValidatorFilter()
public function testValidatorChain()
{
$validatorChain = new ValidatorChain();
+ $validatorChain->attach(new NotEmptyFilter());
$validatorChain->attach(new DigitsFilter());
- $validatorChain->attach(new Int());
$filter = new Validator($validatorChain);
$this->assertTrue($filter->filter(array('message' => '123')));
$this->assertFalse($filter->filter(array('message' => 'test')));
View
12 tests/ZendTest/Validator/AbstractTest.php
@@ -74,6 +74,10 @@ public function testGlobalDefaultTranslatorNullByDefault()
public function testErrorMessagesAreTranslatedWhenTranslatorPresent()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$loader = new TestAsset\ArrayTranslator();
$loader->translations = array(
'fooMessage' => 'This is the translated message for %value%',
@@ -92,6 +96,10 @@ public function testErrorMessagesAreTranslatedWhenTranslatorPresent()
public function testCanTranslateMessagesInsteadOfKeys()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$loader = new TestAsset\ArrayTranslator();
$loader->translations = array(
'%value% was passed' => 'This is the translated message for %value%',
@@ -153,6 +161,10 @@ public function testTranslatorEnabledPerDefault()
public function testCanDisableTranslator()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$loader = new TestAsset\ArrayTranslator();
$loader->translations = array(
'%value% was passed' => 'This is the translated message for %value%',
View
4 tests/ZendTest/Validator/EmailAddressTest.php
@@ -417,6 +417,10 @@ public function testGetMessages()
*/
public function testHostnameValidatorMessagesShouldBeTranslated()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$hostnameValidator = new Hostname();
$translations = array(
'hostnameIpAddressNotAllowed' => 'hostnameIpAddressNotAllowed translation',
View
4 tests/ZendTest/Validator/HostnameTest.php
@@ -260,6 +260,10 @@ public function testGetAllow()
*/
public function testValidatorMessagesShouldBeTranslated()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$translations = array(
'hostnameInvalidLocalName' => 'this is the IP error message',
);
View
4 tests/ZendTest/Validator/StaticValidatorTest.php
@@ -90,6 +90,10 @@ public function testLocalTranslatorPreferredOverGlobalTranslator()
public function testMaximumErrorMessageLength()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->assertEquals(-1, AbstractValidator::getMessageLength());
AbstractValidator::setMessageLength(10);
$this->assertEquals(10, AbstractValidator::getMessageLength());
View
4 tests/ZendTest/View/Helper/HeadTitleTest.php
@@ -168,6 +168,10 @@ public function testZF3577()
public function testCanTranslateTitle()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$loader = new TestAsset\ArrayTranslator();
$loader->translations = array(
'Message_1' => 'Message 1 (en)',
View
8 tests/ZendTest/View/Helper/Navigation/BreadcrumbsTest.php
@@ -165,6 +165,10 @@ public function testUseAclResourceFromPages()
public function testTranslationUsingZendTranslate()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->_helper->setTranslator($this->_getTranslator());
$expected = $this->_getExpected('bc/translated.html');
@@ -173,6 +177,10 @@ public function testTranslationUsingZendTranslate()
public function testTranslationUsingZendTranslateAdapter()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$translator = $this->_getTranslator();
$this->_helper->setTranslator($translator);
View
8 tests/ZendTest/View/Helper/Navigation/MenuTest.php
@@ -212,6 +212,10 @@ public function testOptionEscapeLabelsAsFalse()
public function testTranslationUsingZendTranslate()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$translator = $this->_getTranslator();
$this->_helper->setTranslator($translator);
@@ -221,6 +225,10 @@ public function testTranslationUsingZendTranslate()
public function testTranslationUsingZendTranslateAdapter()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$translator = $this->_getTranslator();
$this->_helper->setTranslator($translator);
View
4 tests/ZendTest/View/Helper/Navigation/NavigationTest.php
@@ -187,6 +187,10 @@ public function testDisablingAclInjection()
public function testInjectingTranslator()
{
+ if (!extension_loaded('intl')) {
+ $this->markTestSkipped('ext/intl not enabled');
+ }
+
$this->_helper->setTranslator($this->_getTranslator());
$expected = $this->_getExpected('menu/translated.html');
Something went wrong with that request. Please try again.