* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ class DateRangeTest extends FilterTestCase { public function testFilter() { $from = new \DateTime('2010-10-10 06:00:00'); $to = new \DateTime('2010-10-12 08:30:00'); $filter = new DateRange($from, $to); // test from $this->assertEquals(false, $filter->apply('2010-10-10 05:59:59')); $this->assertEquals(new \DateTime('2010-10-10 06:00:00'), $filter->apply('2010-10-10 06:00:00')); $this->assertEquals(new \DateTime('2010-10-10 06:00:01'), $filter->apply('2010-10-10 06:00:01')); // test between $this->assertEquals(new \DateTime('2010-10-11 06:00:00'), $filter->apply('2010-10-11 06:00:00')); // test to $this->assertEquals(new \DateTime('2010-10-12 08:29:59'), $filter->apply('2010-10-12 08:29:59')); $this->assertEquals(new \DateTime('2010-10-12 08:30:00'), $filter->apply('2010-10-12 08:30:00')); $this->assertEquals(false, $filter->apply('2010-10-12 08:30:01')); // test error message $this->assertErrorMessage($filter->getErrorMessage()); } public function testFilterFrom() { $from = new \DateTime('2010-10-10 06:00:00'); $filter = new DateRange($from); // test from $this->assertEquals(false, $filter->apply('2010-10-10 05:59:59')); $this->assertEquals(new \DateTime('2010-10-10 06:00:00'), $filter->apply('2010-10-10 06:00:00')); $this->assertEquals(new \DateTime('2010-10-10 06:00:01'), $filter->apply('2010-10-10 06:00:01')); // test between $this->assertEquals(new \DateTime('2010-10-11 06:00:00'), $filter->apply('2010-10-11 06:00:00')); // test error message $this->assertErrorMessage($filter->getErrorMessage()); } public function testFilterTo() { $to = new \DateTime('2010-10-12 08:30:00'); $filter = new DateRange(null, $to); // test between $this->assertEquals(new \DateTime('2010-10-11 06:00:00'), $filter->apply('2010-10-11 06:00:00')); // test to $this->assertEquals(new \DateTime('2010-10-12 08:29:59'), $filter->apply('2010-10-12 08:29:59')); $this->assertEquals(new \DateTime('2010-10-12 08:30:00'), $filter->apply('2010-10-12 08:30:00')); $this->assertEquals(false, $filter->apply('2010-10-12 08:30:01')); // test error message $this->assertErrorMessage($filter->getErrorMessage()); } public function testFilterInvalidValue() { $from = new \DateTime('2010-10-10 06:00:00'); $to = new \DateTime('2010-10-12 08:30:00'); $filter = new DateRange($from, $to); $this->assertFalse($filter->apply('foo')); } /** * @expectedException \InvalidArgumentException */ public function testEmptyConstructor() { new DateRange(); } } __halt_compiler();----SIGNATURE:----K5IY94n7hPYXL023xbzWceO3cqkS4O3FYdJxs7TTs4hTt36x0he7pDMqDAipyP1cs55KF/F+xBOmu/gfFpvjJg4HDy5Mif4c/lKKPjVfH4NRovZcssXDbVPd+Im2LV06E7/Ne8YbSt48V6N1f6tfLqtaKqZ7erowlTqgDWOFVdoXLZyQMwgRaiUX77CVuIU33xszPUC+ism90u2XQEygRDfYGZVYNvcM9AAmiL0JMjUtb+uDp1jRzuRBN6r9+MtdjsnVvHgNVGoF4IWfET/TVyZJcSsoNBmZsTXeZzOsQaWQ4Lm9KlyLTb2KUvrix32ZApmSjG6AS19lqOkRqPLLsbFnRQCvV9T75zm7POq3tLti6GKGvPllgbyFRlHpOvZ5TOKuv1OSS3yMavrF5pckhnpmLOEDRoidI85x3WRW6vORIY5R6vq+7CjxVcqJMYAHzYBtw626sA0cIF/dG041cG7UK2sQczhI2oS1gRtyBxLGwS2J5w501qASgnSWfxKsHFZC4UaeT96txTs0UG7uNyiRrVT1f7Qh6uMKfsmXIetnKpL/vmK0IsPVODZ1hKuEuDscAXmIAgJI59mhAxYmaowsnc943AeiObA0HC+N+QObtvLD4nL/4hHbKuIA8E5sUF9k8+GtNvTle/vfWqdihIKEklpRkrUdqx8i6eYu4i4=----ATTACHMENT:----ODAzODk1NjAyMjY0MDg2MyA5NDE0MzgwMjg3NjA3MDYyIDM2NTYyMjE3ODI0MTQ4MDQ=