summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknut <>2008-07-20 16:04:35 +0000
committerknut <>2008-07-20 16:04:35 +0000
commit101e78e6dab863460d3cbc112d5d795370276fc7 (patch)
treeec2df752faec2c23878ecc708d235b142b2a8245
parent5e82afde4d98b26b36fc14980efa75393d6ef77e (diff)
fixed #886
-rw-r--r--.gitattributes4
-rw-r--r--framework/Util/TSimpleDateFormatter.php2
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket886.page8
-rw-r--r--tests/FunctionalTests/tickets/protected/pages/Ticket886.php9
-rw-r--r--tests/FunctionalTests/tickets/tests/Ticket886TestCase.php15
-rw-r--r--tests/unit/Util/TSimpleDateFormatterTest.php60
6 files changed, 97 insertions, 1 deletions
diff --git a/.gitattributes b/.gitattributes
index 9607aba5..1cddd32d 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -3085,6 +3085,8 @@ tests/FunctionalTests/tickets/protected/pages/Ticket769.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket785.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket828.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket849.page -text
+tests/FunctionalTests/tickets/protected/pages/Ticket886.page -text
+tests/FunctionalTests/tickets/protected/pages/Ticket886.php -text
tests/FunctionalTests/tickets/protected/pages/Ticket93.page -text
tests/FunctionalTests/tickets/protected/pages/Ticket93.php -text
tests/FunctionalTests/tickets/protected/pages/ToggleTest.page -text
@@ -3148,6 +3150,7 @@ tests/FunctionalTests/tickets/tests/Ticket703TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket708TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket72TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket769TestCase.php -text
+tests/FunctionalTests/tickets/tests/Ticket886TestCase.php -text
tests/FunctionalTests/tickets/tests/Ticket93TestCase.php -text
tests/FunctionalTests/validators.php -text
tests/FunctionalTests/validators/index.php -text
@@ -3551,6 +3554,7 @@ tests/unit/TComponentTest.php -text
tests/unit/Util/AllTests.php -text
tests/unit/Util/TDateTimeStampTest.php -text
tests/unit/Util/TLoggerTest.php -text
+tests/unit/Util/TSimpleDateFormatterTest.php -text
tests/unit/Web/AllTests.php -text
tests/unit/Web/TAssetManagerTest.php -text
tests/unit/Web/TCacheHttpSessionTest.php -text
diff --git a/framework/Util/TSimpleDateFormatter.php b/framework/Util/TSimpleDateFormatter.php
index 7eac630e..8da02aa6 100644
--- a/framework/Util/TSimpleDateFormatter.php
+++ b/framework/Util/TSimpleDateFormatter.php
@@ -301,12 +301,12 @@ class TSimpleDateFormatter
}
if ($i_val != $this->length($value))
throw new TInvalidDataValueException("Pattern '{$this->pattern}' mismatch", $value);
- //var_dump('month is '.$month);
if(!$defaultToCurrentTime && (is_null($month) || is_null($day) || is_null($year)))
return null;
else
{
$day = intval($day) <= 0 ? 1 : intval($day);
+ $month = intval($month) <= 0 ? 1 : intval($month);
$s = Prado::createComponent('System.Util.TDateTimeStamp');
return $s->getTimeStamp(0, 0, 0, $month, $day, $year);
}
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket886.page b/tests/FunctionalTests/tickets/protected/pages/Ticket886.page
new file mode 100644
index 00000000..ea9319fd
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket886.page
@@ -0,0 +1,8 @@
+<com:TContent ID="Content">
+
+ <com:TDatePicker ID="Year" DateFormat="yyyy" InputMode="DropDownList"/>
+ <com:TButton ID="SendButton" ButtonType="Submit" Text="Send" onClick="onButtonClicked" />
+
+ <com:TLabel ID="Output"/>
+
+</com:TContent>
diff --git a/tests/FunctionalTests/tickets/protected/pages/Ticket886.php b/tests/FunctionalTests/tickets/protected/pages/Ticket886.php
new file mode 100644
index 00000000..f14d067d
--- /dev/null
+++ b/tests/FunctionalTests/tickets/protected/pages/Ticket886.php
@@ -0,0 +1,9 @@
+<?php
+class Ticket886 extends TPage {
+
+ public function onButtonClicked($sender, $param) {
+ $this->Output->Text = date('Y-m-d', $this->Year->TimeStamp);
+ }
+
+}
+?>
diff --git a/tests/FunctionalTests/tickets/tests/Ticket886TestCase.php b/tests/FunctionalTests/tickets/tests/Ticket886TestCase.php
new file mode 100644
index 00000000..17e4295f
--- /dev/null
+++ b/tests/FunctionalTests/tickets/tests/Ticket886TestCase.php
@@ -0,0 +1,15 @@
+<?php
+
+class Ticket886TestCase extends SeleniumTestCase
+{
+ function test()
+ {
+ $this->open('tickets/index.php?page=Ticket886');
+ $this->assertTitle("Verifying Ticket 886");
+ $base = 'ctl0_Content_';
+ $this->clickAndWait($base.'SendButton');
+ $this->assertTextPresent('2008-01-01');
+ }
+}
+
+?>
diff --git a/tests/unit/Util/TSimpleDateFormatterTest.php b/tests/unit/Util/TSimpleDateFormatterTest.php
new file mode 100644
index 00000000..ca9f6809
--- /dev/null
+++ b/tests/unit/Util/TSimpleDateFormatterTest.php
@@ -0,0 +1,60 @@
+<?php
+require_once dirname(__FILE__).'/../phpunit.php';
+
+Prado::using('System.Util.TSimpleDateFormatter');
+
+/**
+ * @package System.Util
+ */
+class TSimpleDateFormatterTest extends PHPUnit_Framework_TestCase {
+
+ public function setUp() {
+ }
+
+ public function tearDown() {
+ }
+
+ public function testConstruct() {
+ throw new PHPUnit_Framework_IncompleteTestError();
+ }
+
+ public function testPattern() {
+ throw new PHPUnit_Framework_IncompleteTestError();
+ }
+
+ public function testCharset() {
+ throw new PHPUnit_Framework_IncompleteTestError();
+ }
+
+ public function testFormat() {
+ throw new PHPUnit_Framework_IncompleteTestError();
+ }
+
+ public function testMonthPattern() {
+ throw new PHPUnit_Framework_IncompleteTestError();
+ }
+
+ public function testDayPattern() {
+ throw new PHPUnit_Framework_IncompleteTestError();
+ }
+
+ public function testYearPattern() {
+ $formatter = new TSimpleDateFormatter("yyyy");
+ self::assertEquals("2008-01-01", date('Y-m-d', $formatter->parse("2008")));
+ }
+
+ public function testDayMonthYearOrdering() {
+ throw new PHPUnit_Framework_IncompleteTestError();
+ }
+
+ public function testIsValidDate() {
+ throw new PHPUnit_Framework_IncompleteTestError();
+ }
+
+ public function testParse() {
+ throw new PHPUnit_Framework_IncompleteTestError();
+ }
+
+}
+
+?>