Permalink
Browse files

added tests for Holidays/Driver/Iceland.php

git-svn-id: http://svn.php.net/repository/pear/packages/Date_Holidays/trunk@251316 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 1e2ccc6 commit 4cfb2615445c1d6946eed06ebae738d34fdfdd2d @kenguest kenguest committed Jan 25, 2008
Showing with 166 additions and 9 deletions.
  1. +1 −3 Holidays/Driver/Iceland.php
  2. +6 −0 docs/Iceland
  3. +1 −0 package2.xml
  4. +8 −6 tests/AllTests.php
  5. +150 −0 tests/Date_Holidays_Driver_Iceland_TestSuite.php
View
4 Holidays/Driver/Iceland.php
@@ -86,7 +86,6 @@ function _buildHolidays()
*/
$hdate = new Date($this->_year . "-01-19");
while ($hdate->getDayOfWeek() != 5) {
- var_dump($hdate->getDayOfWeek());
$hdate = $hdate->getNextDay();
}
$this->_addHoliday('husbandsDay', $hdate, 'Husband\'s Day');
@@ -97,8 +96,7 @@ function _buildHolidays()
* Calculate Sunday in the 18th week of winter, ie between Feb 18-24.
*/
$wdate = new Date($this->_year . "-02-18");
- while ($wdate->getDayOfWeek() != 5) {
- var_dump($wdate->getDayOfWeek());
+ while ($wdate->getDayOfWeek() != 0) {
$wdate = $wdate->getNextDay();
}
$this->_addHoliday('womansDay', $wdate, 'Woman\'s Day');
View
6 docs/Iceland
@@ -11,3 +11,9 @@ Ascension Day is a public holiday in May.
Festivals for which the employer is to pay are:
1 May and 17 June and the first Monday in August."
+Husband's Day
+From http://www.isholf.is/gullis/jo/feasts_and_celebrations.htm
+Þorri is one of the old Icelandic months. It always begins on
+a Friday, between the 19th and the 25th of January, and ends on
+a Saturday between the 18th and 24th of February. The first day
+of Þorri is called Bóndadagur or "Husband's Day/Farmer's Day"
View
1 package2.xml
@@ -160,6 +160,7 @@
<file baseinstalldir="Date" name="Date_Holidays_Driver_Christian_TestSuite.php" role="test" />
<file baseinstalldir="Date" name="Date_Holidays_Driver_EnglandWales_TestSuite.php" role="test" />
<file baseinstalldir="Date" name="Date_Holidays_Driver_Germany_TestSuite.php" role="test" />
+ <file baseinstalldir="Date" name="Date_Holidays_Driver_Iceland_TestSuite.php" role="test" />
<file baseinstalldir="Date" name="Date_Holidays_Driver_Ireland_TestSuite.php" role="test" />
<file baseinstalldir="Date" name="Date_Holidays_Driver_Jewish_TestSuite.php" role="test" />
<file baseinstalldir="Date" name="Date_Holidays_Driver_PHPdotNet_TestSuite.php" role="test" />
View
14 tests/AllTests.php
@@ -1,7 +1,7 @@
<?php
/**
* a test class for running all Date_Holidays unit tests
- *
+ *
* PHP versions 4 and 5
*
* @category Date
@@ -25,6 +25,7 @@
require_once 'Date_Holidays_Driver_Christian_TestSuite.php';
require_once 'Date_Holidays_Driver_EnglandWales_TestSuite.php';
require_once 'Date_Holidays_Driver_Germany_TestSuite.php';
+require_once 'Date_Holidays_Driver_Iceland_TestSuite.php';
require_once 'Date_Holidays_Driver_Ireland_TestSuite.php';
require_once 'Date_Holidays_Driver_Jewish_TestSuite.php';
require_once 'Date_Holidays_Driver_PHPdotNet_TestSuite.php';
@@ -35,7 +36,7 @@
/**
* a test class for running all Date_Holidays unit tests
- *
+ *
* @category Date
* @package Date_Holidays
* @author Carsten Lucke <luckec@tool-garage.de>
@@ -46,8 +47,8 @@
class Date_Holidays_AllTests
{
/**
- * main
- *
+ * main
+ *
* @static
* @access public
* @return void
@@ -58,8 +59,8 @@ public static function main()
}
/**
- * suite
- *
+ * suite
+ *
* @static
* @access public
* @return void
@@ -77,6 +78,7 @@ public static function suite()
$suite->addTestSuite('Date_Holidays_Driver_Christian_TestSuite');
$suite->addTestSuite('Date_Holidays_Driver_EnglandWales_TestSuite');
$suite->addTestSuite('Date_Holidays_Driver_Germany_TestSuite');
+ $suite->addTestSuite('Date_Holidays_Driver_Iceland_TestSuite');
$suite->addTestSuite('Date_Holidays_Driver_Ireland_TestSuite');
$suite->addTestSuite('Date_Holidays_Driver_Jewish_TestSuite');
$suite->addTestSuite('Date_Holidays_Driver_PHPdotNet_TestSuite');
View
150 tests/Date_Holidays_Driver_Iceland_TestSuite.php
@@ -0,0 +1,150 @@
+<?php
+ /**
+ * Test class for running unit tests related to the driver for holidays in Austria
+ *
+ * PHP Versions 4 and 5
+ *
+ * @category Date
+ * @package Date_Holidays
+ * @author Carsten Lucke <luckec@tool-garage.de>
+ * @license http://www.php.net/license/3_01.txt PHP License 3.0.1
+ * @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';
+
+/**
+ * Test class for running unit tests related to the driver for holidays in Austria
+ *
+ * @uses PHPUnit_Framework_TestCase
+ * @category Date
+ * @package Date_Holidays
+ * @author Carsten Lucke <luckec@tool-garage.de>
+ * @license http://www.php.net/license/3_01.txt PHP License 3.0.1
+ * @version CVS: $Id$
+ * @link http://pear.php.net/package/Date_Holidays
+ */
+class Date_Holidays_Driver_Iceland_TestSuite extends PHPUnit_Framework_TestCase
+{
+
+ var $testDates2006;
+ var $testDates2007;
+
+ /**
+ * setUp
+ *
+ * @access public
+ * @return void
+ */
+ function setUp()
+ {
+
+ $this->testDates2006 = array(
+ 'newYearsDay' => array('day' => 1,
+ 'month' => 1,
+ 'year' => 2006),
+ 'womansDay' => array('day' => 19,
+ 'month' => 2,
+ 'year' => 2006),
+ 'easterMonday' => array('day' => 17,
+ 'month' => 4,
+ 'year' => 2006),
+ 'independenceDay' => array('day' => 1,
+ 'month' => 12,
+ 'year' => 2006),
+ 'xmasDay' => array('day' => 25,
+ 'month' => 12,
+ 'year' => 2006),
+ 'boxingDay' => array('day' => 26,
+ 'month' => 12,
+ 'year' => 2006)
+ );
+ $this->testDates2007 = array(
+ 'newYearsDay' => array('day' => 1,
+ 'month' => 1,
+ 'year' => 2007),
+ 'easterMonday' => array('day' => 9,
+ 'month' => 4,
+ 'year' => 2007),
+ 'xmasDay' => array('day' => 25,
+ 'month' => 12,
+ 'year' => 2007),
+ 'womansDay' => array('day' => 18,
+ 'month' => 2,
+ 'year' => 2007),
+ 'independenceDay' => array('day' => 1,
+ 'month' => 12,
+ 'year' => 2006),
+ 'boxingDay' => array('day' => 26,
+ 'month' => 12,
+ 'year' => 2007)
+ );
+ }
+
+ /**
+ * test Holidays for 2007
+ *
+ * @access public
+ * @return void
+ */
+ function testHolidays2007()
+ {
+ $drv = Date_Holidays::factory('Iceland', 2007, 'en_EN');
+ $this->assertFalse(Date_Holidays::isError($drv));
+ if (Date_Holidays::isError($drv)) {
+ print_r($drv);
+ die($drv->getMessage());
+ }
+
+ 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->assertEquals($name, $day->getInternalName());
+ $date = $day->getDate();
+ $this->assertEquals($dateInfo['day'], $date->getDay(), $name);
+ $this->assertEquals($dateInfo['month'], $date->getMonth(), $name);
+ $this->assertEquals($dateInfo['year'], $date->getYear(), $name);
+ }
+ }
+
+ /**
+ * test Holidays for 2006
+ *
+ * @access public
+ * @return void
+ */
+ function testHolidays2006()
+ {
+ $drv = Date_Holidays::factory('Iceland', 2006, 'en_EN');
+ $this->assertFalse(Date_Holidays::isError($drv));
+ if (Date_Holidays::isError($drv)) {
+ print_r($drv);
+ die($drv->getMessage());
+ }
+
+ 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->assertEquals($name, $day->getInternalName());
+ $date = $day->getDate();
+ $this->assertEquals($dateInfo['day'], $date->getDay(), $name);
+ $this->assertEquals($dateInfo['month'], $date->getMonth(), $name);
+ $this->assertEquals($dateInfo['year'], $date->getYear(), $name);
+ }
+ }
+
+}
+
+?>

0 comments on commit 4cfb261

Please sign in to comment.