Skip to content

Commit

Permalink
GitHub #82 - Add timepattern tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sqmk committed Dec 19, 2014
1 parent 71795da commit 20a2c15
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/Phue/Test/TimePattern/AbsoluteTimeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Phue: Philips Hue PHP Client
*
* @author Michael Squires <sqmk@php.net>
* @copyright Copyright (c) 2012-2014 Michael K. Squires
* @license http://github.com/sqmk/Phue/wiki/License
*/

namespace Phue\Test\TimePattern;

use Phue\TimePattern\AbsoluteTime;

/**
* Tests for Phue\TimePattern\AbsoluteTime
*/
class AbsoluteTimeTest extends \PHPUnit_Framework_TestCase
{
/**
* Test: Creating absolute time
*
* @covers \Phue\TimePattern\AbsoluteTime
*/
public function testCreateTime()
{
$this->assertRegExp(
'/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/',
(string) new AbsoluteTime('now')
);
}
}
31 changes: 31 additions & 0 deletions tests/Phue/Test/TimePattern/RandomizedTimeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Phue: Philips Hue PHP Client
*
* @author Michael Squires <sqmk@php.net>
* @copyright Copyright (c) 2012-2014 Michael K. Squires
* @license http://github.com/sqmk/Phue/wiki/License
*/

namespace Phue\Test\TimePattern;

use Phue\TimePattern\RandomizedTime;

/**
* Tests for Phue\TimePattern\RandomizedTime
*/
class RandomizedTimeTest extends \PHPUnit_Framework_TestCase
{
/**
* Test: Creating randomized time
*
* @covers \Phue\TimePattern\RandomizedTime
*/
public function testCreateTime()
{
$this->assertRegExp(
'/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}A01:01:20$/',
(string) new RandomizedTime('now', 3680)
);
}
}
33 changes: 33 additions & 0 deletions tests/Phue/Test/TimePattern/RecurringTimeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Phue: Philips Hue PHP Client
*
* @author Michael Squires <sqmk@php.net>
* @copyright Copyright (c) 2012-2014 Michael K. Squires
* @license http://github.com/sqmk/Phue/wiki/License
*/

namespace Phue\Test\TimePattern;

use Phue\TimePattern\RecurringTime;

/**
* Tests for Phue\TimePattern\RecurringTime
*/
class RecurringTimeTest extends \PHPUnit_Framework_TestCase
{
/**
* Test: Creating recurring time
*
* @covers \Phue\TimePattern\RecurringTime
*/
public function testCreateTime()
{
$this->assertRegExp(
'/^W34\/T14:02:05$/',
(string) new RecurringTime(
RecurringTime::TUESDAY | RecurringTime::SATURDAY, 14, 2, 5
)
);
}
}
31 changes: 31 additions & 0 deletions tests/Phue/Test/TimePattern/TimerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* Phue: Philips Hue PHP Client
*
* @author Michael Squires <sqmk@php.net>
* @copyright Copyright (c) 2012-2014 Michael K. Squires
* @license http://github.com/sqmk/Phue/wiki/License
*/

namespace Phue\Test\TimePattern;

use Phue\TimePattern\Timer;

/**
* Tests for Phue\TimePattern\Timer
*/
class TimerTest extends \PHPUnit_Framework_TestCase
{
/**
* Test: Creating recurring time
*
* @covers \Phue\TimePattern\Timer
*/
public function testCreateTime()
{
$this->assertRegExp(
'/^R12\/PT01:05:25$/',
(string) (new Timer(3925))->repeat(12)
);
}
}

0 comments on commit 20a2c15

Please sign in to comment.