Permalink
Browse files

Massive changes to get test suite in working order (there are tons of…

… failing tests, though).

git-svn-id: http://svn.php.net/repository/pear/packages/Date_Holidays/trunk@321621 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 901e7b6 commit 32b2b5445ae942e5b2764182bbe1b5ad26bab1b4 Daniel Convissor committed Dec 31, 2011
Showing with 309 additions and 405 deletions.
  1. +3 −2 package.xml
  2. +1 −3 package_finland.xml
  3. +1 −3 package_japan.xml
  4. +1 −3 package_sweden.xml
  5. +2 −13 tests/AllTests.php
  6. +14 −12 tests/AllTestsUndeployed.php
  7. +3 −10 tests/Date_Holidays_Bugfix_Retests_TestSuite.php
  8. +4 −9 tests/Date_Holidays_Driver_AustraliaNSW_TestSuite.php
  9. +5 −10 tests/Date_Holidays_Driver_AustraliaQLD_TestSuite.php
  10. +5 −10 tests/Date_Holidays_Driver_AustraliaSA_TestSuite.php
  11. +4 −9 tests/Date_Holidays_Driver_AustraliaWA_TestSuite.php
  12. +5 −10 tests/Date_Holidays_Driver_Australia_TestSuite.php
  13. +6 −14 tests/Date_Holidays_Driver_Austria_TestSuite.php
  14. +4 −9 tests/Date_Holidays_Driver_Brazil_TestSuite.php
  15. +6 −14 tests/Date_Holidays_Driver_Christian_TestSuite.php
  16. +2 −4 tests/Date_Holidays_Driver_Denmark_TestSuite.php
  17. +2 −4 tests/Date_Holidays_Driver_Discordian_TestSuite.php
  18. +3 −7 tests/Date_Holidays_Driver_EnglandWales_TestSuite.php
  19. +6 −15 tests/Date_Holidays_Driver_Finland_TestSuite.php
  20. +7 −17 tests/Date_Holidays_Driver_Germany_TestSuite.php
  21. +2 −4 tests/Date_Holidays_Driver_Iceland_TestSuite.php
  22. +2 −4 tests/Date_Holidays_Driver_Ireland_TestSuite.php
  23. +2 −4 tests/Date_Holidays_Driver_Italy_TestSuite.php
  24. +24 −26 tests/Date_Holidays_Driver_Japan_TestSuite.php
  25. +2 −4 tests/Date_Holidays_Driver_Jewish_TestSuite.php
  26. +2 −4 tests/Date_Holidays_Driver_Netherlands_TestSuite.php
  27. +2 −4 tests/Date_Holidays_Driver_Norway_TestSuite.php
  28. +2 −4 tests/Date_Holidays_Driver_PHPdotNet_TestSuite.php
  29. +4 −9 tests/Date_Holidays_Driver_Portugal_TestSuite.php
  30. +8 −13 tests/Date_Holidays_Driver_Romania_TestSuite.php
  31. +2 −4 tests/Date_Holidays_Driver_Slovenia_TestSuite.php
  32. +4 −9 tests/Date_Holidays_Driver_Spain_TestSuite.php
  33. +25 −51 tests/Date_Holidays_Driver_Sweden_TestSuite.php
  34. +2 −4 tests/Date_Holidays_Driver_Template_TestSuite.php
  35. +65 −54 tests/Date_Holidays_Driver_TestSuite.php
  36. +2 −4 tests/Date_Holidays_Driver_UNO_TestSuite.php
  37. +2 −4 tests/Date_Holidays_Driver_USA_TestSuite.php
  38. +6 −14 tests/Date_Holidays_Driver_Ukraine_TestSuite.php
  39. +57 −0 tests/helper.inc
  40. +1 −2 tests/testHolidays2005stampsAndSavingsDay.php
  41. +2 −1 tests/test_UkraineRomanianHolidays.php
  42. +3 −2 tests/test_getHolidays.php
  43. +4 −2 tests/test_missingLocale.php
View
5 package.xml
@@ -88,9 +88,10 @@
</dir> <!-- /lang/Christian -->
</dir> <!-- /lang -->
<dir name="tests">
- <file baseinstalldir="Date" name="AllTests.php" role="test">
- <tasks:replace from="@test_dir@" to="test_dir" type="pear-config" />
+ <file baseinstalldir="Date" name="helper.inc" role="test">
+ <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" />
</file>
+ <file baseinstalldir="Date" name="AllTests.php" role="test" />
<file baseinstalldir="Date" name="AllTestsUndeployed.php" role="test" />
<file baseinstalldir="Date" name="Date_Holidays_Bugfix_Retests_TestSuite.php" role="test" />
<file baseinstalldir="Date" name="Date_Holidays_Driver_Christian_TestSuite.php" role="test" />
View
4 package_finland.xml
@@ -36,9 +36,7 @@
</dir> <!-- /Holidays -->
</dir>
<dir name="tests">
- <file name="Date_Holidays_Driver_Finland_TestSuite.php" role="test">
- <tasks:replace from="@DATA-DIR@" to="data_dir" type="pear-config" />
- </file>
+ <file name="Date_Holidays_Driver_Finland_TestSuite.php" role="test" />
</dir> <!-- /tests -->
</dir> <!-- / -->
</contents>
View
4 package_japan.xml
@@ -44,9 +44,7 @@
</dir> <!-- /lang/Japan -->
</dir> <!-- /lang -->
<dir name="tests">
- <file name="Date_Holidays_Driver_Japan_TestSuite.php" role="test">
- <tasks:replace from="@DATA-DIR@" to="data_dir" type="pear-config" />
- </file>
+ <file name="Date_Holidays_Driver_Japan_TestSuite.php" role="test"/>
</dir> <!-- /tests -->
</dir> <!-- / -->
</contents>
View
4 package_sweden.xml
@@ -62,9 +62,7 @@
</dir> <!-- /lang/Sweden -->
</dir> <!-- /lang -->
<dir name="tests">
- <file name="Date_Holidays_Driver_Sweden_TestSuite.php" role="test">
- <tasks:replace from="@DATA-DIR@" to="data_dir" type="pear-config" />
- </file>
+ <file name="Date_Holidays_Driver_Sweden_TestSuite.php" role="test" />
</dir> <!-- /tests -->
</dir> <!-- / -->
</contents>
View
15 tests/AllTests.php
@@ -15,19 +15,8 @@
define('PHPUnit_MAIN_METHOD', 'Date_Holidays_AllTests::main');
}
-if (! $fp = @fopen('Date.php', 'r', true)) {
- die("PEAR_Date is required for these tests to run.\n");
-}
-
-if ($fp = @fopen('PHPUnit/Autoload.php', 'r', true)) {
- require_once 'PHPUnit/Autoload.php';
-} elseif ($fp = @fopen('PHPUnit/Framework.php', 'r', true)) {
- require_once 'PHPUnit/Framework.php';
- require_once 'PHPUnit/TextUI/TestRunner.php';
-} else {
- die('skip could not find PHPUnit');
-}
-fclose($fp);
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
$dir = dirname(__FILE__);
require_once "$dir/Date_Holidays_TestSuite.php";
View
26 tests/AllTestsUndeployed.php
@@ -16,19 +16,21 @@
define('PHPUnit_MAIN_METHOD', 'AllTestsUndeployed::main');
}
-require_once 'PHPUnit/TextUI/TestRunner.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
-require_once 'Date_Holidays_TestSuite.php';
-require_once 'Date_Holidays_Driver_TestSuite.php';
-require_once 'Date_Holidays_Bugfix_Retests_TestSuite.php';
-require_once 'Date_Holidays_Driver_Christian_TestSuite.php';
-require_once 'Date_Holidays_Driver_Germany_TestSuite.php';
-require_once 'Date_Holidays_Driver_Jewish_TestSuite.php';
-require_once 'Date_Holidays_Driver_PHPdotNet_TestSuite.php';
-require_once 'Date_Holidays_Driver_UNO_TestSuite.php';
-require_once 'Date_Holidays_Driver_USA_TestSuite.php';
-require_once 'Date_Holidays_Driver_Sweden_TestSuite.php';
-require_once 'Date_Holidays_Driver_Finland_TestSuite.php';
+$dir = dirname(__FILE__);
+require_once "$dir/Date_Holidays_TestSuite.php";
+require_once "$dir/Date_Holidays_Driver_TestSuite.php";
+require_once "$dir/Date_Holidays_Bugfix_Retests_TestSuite.php";
+require_once "$dir/Date_Holidays_Driver_Christian_TestSuite.php";
+require_once "$dir/Date_Holidays_Driver_Germany_TestSuite.php";
+require_once "$dir/Date_Holidays_Driver_Jewish_TestSuite.php";
+require_once "$dir/Date_Holidays_Driver_PHPdotNet_TestSuite.php";
+require_once "$dir/Date_Holidays_Driver_UNO_TestSuite.php";
+require_once "$dir/Date_Holidays_Driver_USA_TestSuite.php";
+require_once "$dir/Date_Holidays_Driver_Sweden_TestSuite.php";
+require_once "$dir/Date_Holidays_Driver_Finland_TestSuite.php";
/**
* a test class for running all Date_Holidays unit tests whilst the package is undeployed.
View
13 tests/Date_Holidays_Bugfix_Retests_TestSuite.php
@@ -12,13 +12,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-//make cvs testing work
-chdir(dirname(__FILE__) . '/../');
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests that make sure bugs that have been
@@ -50,13 +46,10 @@ function setUp() {}
*/
function testBug12807()
{
- $message = '';
$drv = Date_Holidays::factory('Denmark');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- $message = $drv->getMessage();
+ $this->fail(helper_get_error_message($drv));
}
- $this->assertFalse(Date_Holidays::isError($drv), $message);
$this->assertTrue($drv->isHoliday(mktime(1, 1, 1, 12, 25, 2007)));
$this->assertTrue($drv->isHoliday(mktime(1, 1, 1, 1, 1, 2007)));
View
13 tests/Date_Holidays_Driver_AustraliaNSW_TestSuite.php
@@ -12,11 +12,9 @@
* @link http://pear.php.net/package/Date_Holidays
* @see http://australia.gov.au/topics/australian-facts-and-figures/public-holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Austria
@@ -58,16 +56,13 @@ public function testHolidays($name, $year, $dateInfo)
{
$dh = new Date_Holidays();
$drv = $dh->factory('AustraliaNSW', $year, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
View
15 tests/Date_Holidays_Driver_AustraliaQLD_TestSuite.php
@@ -12,11 +12,9 @@
* @link http://pear.php.net/package/Date_Holidays
* @see http://australia.gov.au/topics/australian-facts-and-figures/public-holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Queensland
@@ -83,16 +81,13 @@ public function testHolidays($name, $year, $dateInfo)
{
$dh = new Date_Holidays();
$drv = $dh->factory('AustraliaQLD', $year, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -102,4 +97,4 @@ public function testHolidays($name, $year, $dateInfo)
}
-}
+}
View
15 tests/Date_Holidays_Driver_AustraliaSA_TestSuite.php
@@ -12,11 +12,9 @@
* @link http://pear.php.net/package/Date_Holidays
* @see http://australia.gov.au/topics/australian-facts-and-figures/public-holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Austria
@@ -67,16 +65,13 @@ public function testHolidays($name, $year, $dateInfo)
{
$dh = new Date_Holidays();
$drv = $dh->factory('AustraliaSA', $year, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -86,4 +81,4 @@ public function testHolidays($name, $year, $dateInfo)
}
-}
+}
View
13 tests/Date_Holidays_Driver_AustraliaWA_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id: Date_Holidays_Driver_Austria_TestSuite.php 265332 2008-08-23 09:12:59Z kguest $
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays Western Australia
@@ -80,16 +78,13 @@ public function testHolidays($name, $year, $dateInfo)
{
$dh = new Date_Holidays();
$drv = $dh->factory('AustraliaWA', $year, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
View
15 tests/Date_Holidays_Driver_Australia_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id: Date_Holidays_Driver_Austria_TestSuite.php 265332 2008-08-23 09:12:59Z kguest $
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Austria
@@ -80,16 +78,13 @@ public function testHolidays($name, $year, $dateInfo)
{
$dh = new Date_Holidays();
$drv = $dh->factory('Australia', $year, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -99,4 +94,4 @@ public function testHolidays($name, $year, $dateInfo)
}
-}
+}
View
20 tests/Date_Holidays_Driver_Austria_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Austria
@@ -121,17 +119,14 @@ function setUp()
function testHolidays2007()
{
$drv = Date_Holidays::factory('Austria', 2007, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2007 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -150,17 +145,14 @@ function testHolidays2007()
function testHolidays2006()
{
$drv = Date_Holidays::factory('Austria', 2006, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2006 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
View
13 tests/Date_Holidays_Driver_Brazil_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Brazil
@@ -110,17 +108,14 @@ function setUp()
function testHolidays2008()
{
$drv = Date_Holidays::factory('Brazil', 2008, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2008 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
View
20 tests/Date_Holidays_Driver_Christian_TestSuite.php
@@ -12,11 +12,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to Christian holidays.
@@ -106,18 +104,15 @@ function testHolidays2005()
{
$drvChristian = Date_Holidays::factory('Christian', 2005, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drvChristian));
if (Date_Holidays::isError($drvChristian)) {
- print_r($drvChristian);
- die($drvChristian->getMessage());
+ $this->fail(helper_get_error_message($drvChristian));
}
foreach ($this->testDates2005 as $name => $dateInfo) {
$day = $drvChristian->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -137,18 +132,15 @@ function testHolidays2006()
{
$drvChristian = Date_Holidays::factory('Christian', 2006, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drvChristian));
if (Date_Holidays::isError($drvChristian)) {
- print_r($drvChristian);
- die($drvChristian->getMessage());
+ $this->fail(helper_get_error_message($drvChristian));
}
foreach ($this->testDates2006 as $name => $dateInfo) {
$day = $drvChristian->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
View
6 tests/Date_Holidays_Driver_Denmark_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Denmark
View
6 tests/Date_Holidays_Driver_Discordian_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Discordian
View
10 tests/Date_Holidays_Driver_EnglandWales_TestSuite.php
@@ -12,11 +12,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in
@@ -111,10 +109,8 @@ function setUp()
function testHolidays2009()
{
$drv = Date_Holidays::factory('EnglandWales', 2009, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2009 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
View
21 tests/Date_Holidays_Driver_Finland_TestSuite.php
@@ -11,13 +11,9 @@
* @version CVS: $Id: Date_Holidays_Driver_Finland_TestSuite.php 310677 2011-04-30 22:27:19Z kguest $
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-
-require_once 'Date/Holidays.php';
-define('LANG_FILE', '@DATA-DIR@/Date_Holidays_Finland/lang/');
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Finland
@@ -154,16 +150,14 @@ function setUp()
function testHolidays2005()
{
$drv = Date_Holidays::factory('Finland', 2005, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- $this->fail($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2005 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -182,17 +176,14 @@ function testHolidays2005()
function testHolidays2006()
{
$drv = Date_Holidays::factory('Finland', 2006, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2006 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
View
24 tests/Date_Holidays_Driver_Germany_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Austria
@@ -172,19 +170,15 @@ function setUp()
function testHolidays2005()
{
$drv = Date_Holidays::factory('Germany', 2005, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2005 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
-
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -204,18 +198,15 @@ function testHolidays2005()
function testHolidays2006()
{
$drv = Date_Holidays::factory('Germany', 2006, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2006 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -234,9 +225,8 @@ function testHolidays2006()
function testHolidays2005stampsAndSavingsDay()
{
$drv = Date_Holidays::factory('Germany', 2005);
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
$holidays = $drv->getHolidayForDate('2005-10-30', null, true);
$this->assertEquals('savingsDay',
View
6 tests/Date_Holidays_Driver_Iceland_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Austria
View
6 tests/Date_Holidays_Driver_Ireland_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Ireland
View
6 tests/Date_Holidays_Driver_Italy_TestSuite.php
@@ -12,11 +12,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Italy
View
50 tests/Date_Holidays_Driver_Japan_TestSuite.php
@@ -12,13 +12,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-
-require_once 'Date/Holidays.php';
-define('LANG_FILE', '/usr/local/lib/php5/pear/data/Date_Holidays_Japan/lang/');
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays
@@ -35,6 +31,7 @@
class Date_Holidays_Driver_Japan_TestSuite extends PHPUnit_Framework_TestCase
{
var $_holidays;
+ protected $lang_dir;
/**
* setUp
@@ -44,6 +41,7 @@ class Date_Holidays_Driver_Japan_TestSuite extends PHPUnit_Framework_TestCase
*/
function setUp()
{
+ $this->lang_dir = helper_get_lang_dir('Date_Holidays_Japan');
$this->_holidays = array(
'1970-01-01' => true,
'1970-01-15' => true,
@@ -1343,7 +1341,7 @@ function testHolidaysFrom1970to2050()
for ($year = 1970; $year < 2051; $year++) {
$obj =& Date_Holidays::factory('Japan', $year);
if (Date_Holidays::isError($obj)) {
- $this->fail('Factory was unable to produce driver-object');
+ $this->fail(helper_get_error_message($obj));
}
$invalid_holidays = array();
@@ -1373,7 +1371,7 @@ function testSubstituteHolidaysInMay2008()
{
$obj = Date_Holidays::factory('Japan', 2008);
if (Date_Holidays::isError($obj)) {
- $this->fail('Factory was unable to produce driver-object');
+ $this->fail(helper_get_error_message($obj));
}
// calculate substitute holiday for Children's Day (1st time)
$this->assertTrue($obj->isHoliday(new Date('2008-05-06')), '1st time');
@@ -1397,9 +1395,9 @@ function testSetYearWithXmlTranslationFile()
// with ja_JP.xml
$obj = Date_Holidays::factory('Japan', 2008);
if (Date_Holidays::isError($obj)) {
- $this->fail('Factory was unable to produce driver-object');
+ $this->fail(helper_get_error_message($obj));
}
- $obj->addTranslationFile(LANG_FILE . '/Japan/ja_JP.xml', 'ja_JP');
+ $obj->addTranslationFile($this->lang_dir . '/Japan/ja_JP.xml', 'ja_JP');
if (Date_Holidays::isError($obj)) {
$this->fail('fail to add translation file');
}
@@ -1424,9 +1422,9 @@ function testSetYearWithCompiledTranslationFile()
// with ja_JP.ser
$obj = Date_Holidays::factory('Japan', 2008);
if (Date_Holidays::isError($obj)) {
- $this->fail('Factory was unable to produce driver-object');
+ $this->fail(helper_get_error_message($obj));
}
- $obj->addCompiledTranslationFile(LANG_FILE . '/Japan/ja_JP.ser', 'ja_JP');
+ $obj->addCompiledTranslationFile($this->lang_dir . '/Japan/ja_JP.ser', 'ja_JP');
if (Date_Holidays::isError($obj)) {
$this->fail('fail to add translation file');
}
@@ -1451,7 +1449,7 @@ function testHolidaysFrom1970to2050WithSetYear()
{
$obj =& Date_Holidays::factory('Japan');
if (Date_Holidays::isError($obj)) {
- $this->fail('Factory was unable to produce driver-object');
+ $this->fail(helper_get_error_message($obj));
}
for ($year = 1970; $year < 2051; $year++) {
$obj->setYear($year);
@@ -1483,9 +1481,9 @@ function testShowaDay()
// with ja_JP.xml
$obj = Date_Holidays::factory('Japan', 1949);
if (Date_Holidays::isError($obj)) {
- $this->fail('Factory was unable to produce driver-object');
+ $this->fail(helper_get_error_message($obj));
}
- $obj->addTranslationFile(LANG_FILE . '/Japan/ja_JP.xml', 'ja_JP');
+ $obj->addTranslationFile($this->lang_dir . '/Japan/ja_JP.xml', 'ja_JP');
if (Date_Holidays::isError($obj)) {
$this->fail('fail to add translation file');
}
@@ -1510,9 +1508,9 @@ function testShowaDayWithCompiledTranslationFile()
// with ja_JP.ser
$obj = Date_Holidays::factory('Japan', 1949);
if (Date_Holidays::isError($obj)) {
- $this->fail('Factory was unable to produce driver-object');
+ $this->fail(helper_get_error_message($obj));
}
- $obj->addCompiledTranslationFile(LANG_FILE . '/Japan/ja_JP.ser', 'ja_JP');
+ $obj->addCompiledTranslationFile($this->lang_dir . '/Japan/ja_JP.ser', 'ja_JP');
if (Date_Holidays::isError($obj)) {
$this->fail('fail to add translation file');
}
@@ -1537,9 +1535,9 @@ function testGreeneyDay()
// with ja_JP.xml
$obj = Date_Holidays::factory('Japan', 1986);
if (Date_Holidays::isError($obj)) {
- $this->fail('Factory was unable to produce driver-object');
+ $this->fail(helper_get_error_message($obj));
}
- $obj->addTranslationFile(LANG_FILE . '/Japan/ja_JP.xml', 'ja_JP');
+ $obj->addTranslationFile($this->lang_dir . '/Japan/ja_JP.xml', 'ja_JP');
if (Date_Holidays::isError($obj)) {
$this->fail('fail to add translation file');
}
@@ -1565,9 +1563,9 @@ function testGreeneyDayWithCompiledTranslationFile()
// with ja_JP.ser
$obj = Date_Holidays::factory('Japan', 1986);
if (Date_Holidays::isError($obj)) {
- $this->fail('Factory was unable to produce driver-object');
+ $this->fail(helper_get_error_message($obj));
}
- $obj->addCompiledTranslationFile(LANG_FILE . '/Japan/ja_JP.ser', 'ja_JP');
+ $obj->addCompiledTranslationFile($this->lang_dir . '/Japan/ja_JP.ser', 'ja_JP');
if (Date_Holidays::isError($obj)) {
$this->fail('fail to add translation file');
}
@@ -1593,16 +1591,16 @@ function test16338()
for ($year = 1900; $year < date('Y'); $year++) {
$obj = Date_Holidays::factory('Japan', $year, 'ja_JP');
if (Date_Holidays::isError($obj)) {
- $this->fail('Factory was unable to produce driver-object');
+ $this->fail(helper_get_error_message($obj));
}
- $obj->addTranslationFile(LANG_FILE . '/Japan/ja_JP.xml', 'ja_JP');
- if (Date_Holidays::isError($obj)) {
- $this->fail('fail to add translation file');
+ $res = $obj->addTranslationFile($this->lang_dir . '/Japan/ja_JP.xml', 'ja_JP');
+ if (Date_Holidays::isError($res)) {
+ $this->fail(helper_get_error_message($res));
}
$holidays = array();
foreach ($obj->getHolidays() as $h) {
if (PEAR::isError($h)) {
- $this->fail('test failed');
+ $this->fail(helper_get_error_message($h));
}
$holidays[$h->getDate()->format('%Y-%m-%d')] = $h->getTitle();
}
View
6 tests/Date_Holidays_Driver_Jewish_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for Jewish Holidays
View
6 tests/Date_Holidays_Driver_Netherlands_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Netherlands
View
6 tests/Date_Holidays_Driver_Norway_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Norway
View
6 tests/Date_Holidays_Driver_PHPdotNet_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the PHPdotNet driver.
View
13 tests/Date_Holidays_Driver_Portugal_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id: Date_Holidays_Driver_Austria_TestSuite.php 265332 2008-08-23 09:12:59Z kguest $
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Austria
@@ -98,17 +96,14 @@ function setUp()
function testHolidays2009()
{
$drv = Date_Holidays::factory('Portugal', 2009, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2009 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
View
21 tests/Date_Holidays_Driver_Romania_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Austria
@@ -100,15 +98,15 @@ function setUp()
function testHolidays2007()
{
$drv = Date_Holidays::factory('Romania', 2007, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2007 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day), $name);
+ if (Date_Holidays::isError($day)) {
+ $this->fail(helper_get_error_message($day));
+ }
$this->assertEquals($name, $day->getInternalName(), $name);
$date = $day->getDate();
$this->assertEquals($dateInfo['day'], $date->getDay(), $name);
@@ -126,17 +124,14 @@ function testHolidays2007()
function testHolidays2006()
{
$drv = Date_Holidays::factory('Romania', 2006, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2006 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
View
6 tests/Date_Holidays_Driver_Slovenia_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Slovenia
View
13 tests/Date_Holidays_Driver_Spain_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id: Date_Holidays_Driver_Spain_TestSuite.php 265332 2008-08-23 09:12:59Z kguest $
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Spain
@@ -121,17 +119,14 @@ function setUp()
function testHolidays2009()
{
$drv = Date_Holidays::factory('Spain', 2009, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2009 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
View
76 tests/Date_Holidays_Driver_Sweden_TestSuite.php
@@ -11,13 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-
-require_once 'Date/Holidays.php';
-define('LANG_FILE', '@DATA-DIR@/Date_Holidays_Sweden/lang/');
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Sweden
@@ -135,6 +131,8 @@ class Date_Holidays_Driver_Sweden_TestSuite extends PHPUnit_Framework_TestCase
'month'=>12,
'year' => 2006));
+ protected $lang_dir;
+
/**
* setup
*
@@ -143,6 +141,7 @@ class Date_Holidays_Driver_Sweden_TestSuite extends PHPUnit_Framework_TestCase
*/
function setUp()
{
+ $this->lang_dir = helper_get_lang_dir('Date_Holidays_Sweden');
}
/**
@@ -154,16 +153,14 @@ function setUp()
function testHolidays2005()
{
$drv = Date_Holidays::factory('Sweden', 2005, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- $this->fail($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2005 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -182,17 +179,14 @@ function testHolidays2005()
function testHolidays2006()
{
$drv = Date_Holidays::factory('Sweden', 2006, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2006 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -213,17 +207,13 @@ function testGermanTranslations()
$locale = 'de_DE';
$drv = Date_Holidays::factory('Sweden', 2005, $locale);
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- $this->fail($drv->getMessage());
- }
- if (strpos('@DATA_DIR@', LANG_FILE) === false) {
- $result = $drv->addTranslationFile('../lang/Sweden/de_DE.xml', $locale);
- } else {
- $result = $drv->addTranslationFile(LANG_FILE . '/Sweden/de_DE.xml', $locale);
+ $this->fail(helper_get_error_message($drv));
}
+ $result = $drv->addTranslationFile(
+ $this->lang_dir . '/Sweden/de_DE.xml', $locale);
if ($result !== true) {
- $this->markTestSkipped("Could not load translation file.");
+ $this->fail(helper_get_error_message($result));
}
$easter = $drv->getHoliday('easter');
@@ -243,19 +233,13 @@ function testcompiledGermanTranslations()
$locale = 'de_DE';
$drv = Date_Holidays::factory('Sweden', 2005, $locale);
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- $this->fail($drv->getMessage());
- }
-
- if (strpos('@DATA_DIR@', LANG_FILE) === false) {
- $result = $drv->addCompiledTranslationFile('../lang/Sweden/de_DE.ser', $locale);
- } else {
- $result = $drv->addCompiledTranslationFile(LANG_FILE . '/Sweden/de_DE.ser',
- $locale);
+ $this->fail(helper_get_error_message($drv));
}
+ $result = $drv->addCompiledTranslationFile(
+ $this->lang_dir . '/Sweden/de_DE.ser',$locale);
if ($result !== true) {
- $this->markTestSkipped("Could not load compiled translation file.");
+ $this->fail(helper_get_error_message($result));
}
$easter = $drv->getHoliday('easter');
@@ -280,17 +264,13 @@ function testSwedishTranslations()
$locale = 'de_DE';
$drv = Date_Holidays::factory('Sweden', 2005, $locale);
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- $this->fail($drv->getMessage());
- }
- if (strpos('@DATA_DIR@', LANG_FILE) === false) {
- $result = $drv->addTranslationFile('../lang/Sweden/de_DE.xml', $locale);
- } else {
- $result = $drv->addTranslationFile(LANG_FILE . '/Sweden/de_DE.xml', $locale);
+ $this->fail(helper_get_error_message($drv));
}
+ $result = $drv->addTranslationFile(
+ $this->lang_dir . '/Sweden/de_DE.xml', $locale);
if ($result !== true) {
- $this->markTestSkipped("Could not load translation file.");
+ $this->fail(helper_get_error_message($result));
}
$easter = $drv->getHoliday('easter');
@@ -310,19 +290,13 @@ function testcompiledSwedishTranslations()
$locale = 'sv_SE';
$drv = Date_Holidays::factory('Sweden', 2005, $locale);
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- $this->fail($drv->getMessage());
- }
-
- if (strpos('@DATA_DIR@', LANG_FILE) === false) {
- $result = $drv->addCompiledTranslationFile('../lang/Sweden/sv_SE.ser', $locale);
- } else {
- $result = $drv->addCompiledTranslationFile(LANG_FILE . '/Sweden/sv_SE.ser',
- $locale);
+ $this->fail(helper_get_error_message($drv));
}
+ $result = $drv->addCompiledTranslationFile(
+ $this->lang_dir . '/Sweden/sv_SE.ser', $locale);
if ($result !== true) {
- $this->markTestSkipped("Could not load compiled translation file.");
+ $this->fail(helper_get_error_message($result));
}
$easter = $drv->getHoliday('easter');
View
6 tests/Date_Holidays_Driver_Template_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Template
View
119 tests/Date_Holidays_Driver_TestSuite.php
@@ -11,19 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-define('PEAR_DATADIR', '@data_dir@');
-if (is_dir(PEAR_DATADIR)) {
- define('LANG_DIR', PEAR_DATADIR . '/Date_Holidays/lang');
-} else {
- define('LANG_DIR', dirname(__FILE__) . '/../lang');
-// chdir(dirname(__FILE__) . '/../');
-}
-if (!defined("PHPUnit_MAIN_METHOD")) {
- //make cvs testing work
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running driver related unit tests.
@@ -38,8 +28,8 @@
*/
class Date_Holidays_Driver_TestSuite extends PHPUnit_Framework_TestCase
{
-
var $driver;
+ protected $lang_dir;
/**
* setup
@@ -49,23 +39,23 @@ class Date_Holidays_Driver_TestSuite extends PHPUnit_Framework_TestCase
*/
function setUp()
{
- $this->driver = Date_Holidays::factory('Germany', 2005, 'C');
+ $this->lang_dir = helper_get_lang_dir('Date_Holidays');
+
+ $this->driver = Date_Holidays::factory('Germany', 2005, 'de_DE');
if (Date_Holidays::isError($this->driver)) {
- echo "Driver creation failed: \n";
- foreach ($this->driver->getErrors() as $error) {
- echo $error['message'] . "\n";
- }
- //$this->markTestSkipped("KWG");
- die();
-
- } else {
-
- $this->driver->addCompiledTranslationFile(LANG_DIR .
- '/Christian/de_DE.ser',
- 'de_DE');
- $this->driver->addCompiledTranslationFile(LANG_DIR .
- '/Germany/de_DE.ser',
- 'de_DE');
+ $this->fail(helper_get_error_message($this->driver));
+ }
+
+ $ret = $this->driver->addCompiledTranslationFile(
+ $this->lang_dir . '/Christian/de_DE.ser', 'de_DE');
+ if (Date_Holidays::isError($ret)) {
+ $this->fail(helper_get_error_message($ret));
+ }
+
+ $ret = $this->driver->addCompiledTranslationFile(
+ $this->lang_dir . '/Germany/de_DE.ser', 'de_DE');
+ if (Date_Holidays::isError($ret)) {
+ $this->fail(helper_get_error_message($ret));
}
}
@@ -77,13 +67,18 @@ function setUp()
*/
function testAddCompiledTranslationFile()
{
- $result = $this->driver->addCompiledTranslationFile(LANG_DIR .
- '/Christian/de_DE.ser',
- 'de_DE');
+ $result = $this->driver->addCompiledTranslationFile(
+ $this->lang_dir . '/Christian/de_DE.ser', 'de_DE');
+ if (Date_Holidays::isError($result)) {
+ $this->fail(helper_get_error_message($result));
+ }
$this->assertTrue($result);
- $result = $this->driver->addCompiledTranslationFile(LANG_DIR .
- '/Germany/de_DE.ser',
- 'de_DE');
+
+ $result = $this->driver->addCompiledTranslationFile(
+ $this->lang_dir . '/Germany/de_DE.ser', 'de_DE');
+ if (Date_Holidays::isError($result)) {
+ $this->fail(helper_get_error_message($result));
+ }
$this->assertTrue($result);
}
/**
@@ -94,8 +89,11 @@ function testAddCompiledTranslationFile()
*/
function testAddTranslationFile()
{
- $result = $this->driver->addTranslationFile(LANG_DIR . '/Germany/de_DE.xml',
- 'de_DE');
+ $result = $this->driver->addTranslationFile(
+ $this->lang_dir . '/Germany/de_DE.xml', 'de_DE');
+ if (Date_Holidays::isError($result)) {
+ $this->fail(helper_get_error_message($result));
+ }
$this->assertTrue($result);
}
@@ -127,7 +125,7 @@ function testGetHolidays()
{
$holidays = $this->driver->getHolidays();
foreach ($holidays as $holiday) {
- $this->assertTrue(is_a($holiday, 'Date_Holidays_Holiday'));
+ $this->assertInstanceOf('Date_Holidays_Holiday', $holiday);
}
$filter = new Date_Holidays_Filter_Whitelist(array('ascensionDay',
@@ -151,14 +149,16 @@ function testGetHolidays()
function testGetHoliday()
{
$holiday = $this->driver->getHoliday('ascensionDay');
- $this->assertTrue(is_a($holiday, 'Date_Holidays_Holiday'));
-
+ $this->assertInstanceOf('Date_Holidays_Holiday', $holiday);
$this->assertEquals('ascensionDay', $holiday->getInternalName());
- $result = $this->driver->addCompiledTranslationFile(LANG_DIR .
- '/Germany/de_DE.ser',
- 'de_DE');
+ $result = $this->driver->addCompiledTranslationFile(
+ $this->lang_dir . '/Germany/de_DE.ser', 'de_DE');
+ if (Date_Holidays::isError($result)) {
+ $this->fail(helper_get_error_message($result));
+ }
$this->assertTrue($result, 'Adding compiled translation file');
+
$holiday = $this->driver->getHoliday('ascensionDay', 'de_DE');
$this->assertEquals('Christi Himmelfahrt', $holiday->getTitle());
}
@@ -172,7 +172,7 @@ function testGetHoliday()
function testGetHolidayDate()
{
$date = $this->driver->getHolidayDate('ascensionDay');
- $this->assertTrue(is_a($date, 'Date'));
+ $this->assertInstanceOf('Date', $date);
$this->assertTrue($date->equals(new Date('2005-05-05')));
}
@@ -186,7 +186,7 @@ function testGetHolidayDates()
{
$dates = $this->driver->getHolidayDates();
foreach ($dates as $date) {
- $this->assertTrue(is_a($date, 'Date'));
+ $this->assertInstanceOf('Date', $date);
}
$restrict = array('ascensionDay', 'easter');
@@ -213,25 +213,33 @@ function testGetHolidayDates()
function testGetHolidayForDate()
{
$holiday = $this->driver->getHolidayForDate('2005-05-05');
- $this->assertFalse(Date_Holidays::isError($holiday));
+ if (Date_Holidays::isError($holiday)) {
+ $this->fail(helper_get_error_message($holiday));
+ }
+
+ $result = $this->driver->addCompiledTranslationFile(
+ $this->lang_dir . '/Germany/de_DE.ser', 'de_DE');
+ if (Date_Holidays::isError($result)) {
+ $this->fail(helper_get_error_message($result));
+ }
- $result = $this->driver->addCompiledTranslationFile(LANG_DIR .
- '/Germany/de_DE.ser',
- 'de_DE');
$holiday = $this->driver->getHolidayForDate('2005-05-05', 'de_DE');
$this->assertEquals('Christi Himmelfahrt', $holiday->getTitle());
$result = $this->driver->getHolidayForDate('2005-05-05',
null,
true);
- $this->assertTrue(is_array($result));
+ $this->assertInternalType('array', $result);
$this->assertTrue(count($result) > 1);
foreach ($result as $holiday) {
- $this->assertTrue(is_a($holiday, 'Date_Holidays_Holiday'));
+ $this->assertInstanceOf('Date_Holidays_Holiday', $holiday);
}
$germany = Date_Holidays::factory('Germany', 2005, 'de_DE');
+ if (Date_Holidays::isError($germany)) {
+ $this->fail(helper_get_error_message($germany));
+ }
$holidays = $germany->getHolidayForDate(mktime(0, 0, 0, 10, 30, 2005),
null,
true);
@@ -268,6 +276,9 @@ function testGetHolidayProperties()
$result = $this->driver->addTranslationFile(dirname(__FILE__) .
'/Date_Holidays_Driver_TestSuite.xml',
'de_DE');
+ if (Date_Holidays::isError($result)) {
+ $this->fail(helper_get_error_message($result));
+ }
$this->assertTrue($result);
$properties = $this->driver->getHolidayProperties('jesusCircumcision', 'en');
@@ -302,7 +313,7 @@ function testGetHolidaysForDatespan()
$internalNames = array();
foreach ($holidays as $holiday) {
$internalNames[] = $holiday->getInternalName();
- $this->assertTrue(is_a($holiday, 'Date_Holidays_Holiday'));
+ $this->assertInstanceOf('Date_Holidays_Holiday', $holiday);
}
$this->assertContains('laughingDay', $internalNames);
@@ -410,9 +421,9 @@ function testGetYear()
*/
function testSetYear()
{
- $driver = Date_Holidays::factory('Germany', 2005, 'C');
+ $driver = Date_Holidays::factory('Germany', 2005, 'de_DE');
if (Date_Holidays::isError($driver)) {
- $this->fail('Driver creation failed: ' . $driver->getMessage());
+ $this->fail(helper_get_error_message($driver));
}
$driver->setYear(1999);
View
6 tests/Date_Holidays_Driver_UNO_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Date_Holidays_Driver_UNO_TestSuite
View
6 tests/Date_Holidays_Driver_USA_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in USA
View
20 tests/Date_Holidays_Driver_Ukraine_TestSuite.php
@@ -11,11 +11,9 @@
* @version CVS: $Id$
* @link http://pear.php.net/package/Date_Holidays
*/
-if (!defined("PHPUnit_MAIN_METHOD")) {
- define("PHPUnit_MAIN_METHOD", "Date_HolidaysTest::main");
-}
-require_once 'Date/Holidays.php';
+/** Set up the environment */
+require_once dirname(__FILE__) . '/helper.inc';
/**
* Test class for running unit tests related to the driver for holidays in Austria
@@ -124,17 +122,14 @@ function setUp()
function testHolidays2007()
{
$drv = Date_Holidays::factory('Ukraine', 2007, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2007 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
@@ -153,17 +148,14 @@ function testHolidays2007()
function testHolidays2006()
{
$drv = Date_Holidays::factory('Ukraine', 2006, 'en_EN');
- $this->assertFalse(Date_Holidays::isError($drv));
if (Date_Holidays::isError($drv)) {
- print_r($drv);
- die($drv->getMessage());
+ $this->fail(helper_get_error_message($drv));
}
foreach ($this->testDates2006 as $name => $dateInfo) {
$day = $drv->getHoliday($name);
- $this->assertFalse(Date_Holidays::isError($day));
if (Date_Holidays::isError($day)) {
- die($day->getMessage());
+ $this->fail(helper_get_error_message($day));
}
$this->assertEquals($name, $day->getInternalName());
$date = $day->getDate();
View
57 tests/helper.inc
@@ -0,0 +1,57 @@
+<?php
+
+if (! $fp = @fopen('Date.php', 'r', true)) {
+ die("PEAR_Date is required for these tests to run.\n");
+}
+
+if ($fp = @fopen('PHPUnit/Autoload.php', 'r', true)) {
+ require_once 'PHPUnit/Autoload.php';
+} elseif ($fp = @fopen('PHPUnit/Framework.php', 'r', true)) {
+ require_once 'PHPUnit/Framework.php';
+ require_once 'PHPUnit/TextUI/TestRunner.php';
+} else {
+ die('skip could not find PHPUnit');
+}
+fclose($fp);
+
+if ('@data_dir@' == '@'.'data_dir'.'@') {
+ // This package hasn't been installed.
+ // Adjust path to ensure includes find files in working directory.
+ set_include_path(dirname(dirname(__FILE__))
+ . PATH_SEPARATOR . dirname(__FILE__)
+ . PATH_SEPARATOR . get_include_path());
+}
+
+require_once 'Date/Holidays.php';
+
+function helper_get_lang_dir($package) {
+ if ('@data_dir@' == '@'.'data_dir'.'@') {
+ return dirname(dirname(__FILE__)) . '/lang';
+ } else {
+ return "@data_dir@/$package/lang";
+ }
+}
+
+/**
+ * Gets messages from error objects
+ *
+ * Needed because Date_Holidays is inconsistent about error returns.