/** * Test method for the <tt>getSendDate</tt> and <tt>setSendDate($sendDate)</tt> functions. */ public function testGetSetSendDate() { $notification = new Notification(); // Test with an invalid send date string try { $notification->setSendDate('aaa'); $this->fail('Must have thrown a PushwooshException !'); } catch (PushwooshException $pe) { // Expected } // Test with a send date which is neither a \DateTime neither a string try { $notification->setSendDate(654); $this->fail('Must have thrown a PushwooshException !'); } catch (PushwooshException $pe) { // Expected } // Test with 'now' $this->assertSame($notification, $notification->setSendDate('now')); $this->assertEquals('now', $notification->getSendDate()); // Test with a valid string date provided $this->assertSame($notification, $notification->setSendDate('2014-01-01 10:06')); $this->assertEquals(\DateTime::createFromFormat('Y-m-d H:i', '2014-01-01 10:06')->getTimestamp(), $notification->getSendDate()->getTimestamp()); // Test with a \DateTime $dateTime = \DateTime::createFromFormat('Y-m-d H:i', '2014-01-01 10:06'); $this->assertSame($notification, $notification->setSendDate($dateTime)); $this->assertSame($dateTime, $notification->getSendDate()); }