Skip to content

Commit

Permalink
changing methods in CakeTime class to static
Browse files Browse the repository at this point in the history
  • Loading branch information
rchavik committed Feb 14, 2012
1 parent 9624c27 commit d6fd051
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 93 deletions.
5 changes: 5 additions & 0 deletions lib/Cake/Test/Case/Utility/CakeTimeTest.php
Expand Up @@ -328,6 +328,11 @@ public function testNice() {

$this->Time->niceFormat = '%Y-%d-%m';
$this->assertEquals(date('Y-d-m', $time), $this->Time->nice($time));
$this->assertEquals('%Y-%d-%m', $this->Time->niceFormat);

CakeTime::$niceFormat = '%Y-%d-%m %H:%M:%S';
$this->assertEquals(date('Y-d-m H:i:s', $time), $this->Time->nice($time));
$this->assertEquals('%Y-%d-%m %H:%M:%S', $this->Time->niceFormat);
}

/**
Expand Down
25 changes: 16 additions & 9 deletions lib/Cake/Test/Case/View/Helper/TimeHelperTest.php
Expand Up @@ -25,12 +25,18 @@
*/
class TimeHelperTestObject extends TimeHelper {

public function attach(CakeTime $cakeTime) {
public function attach(CakeTimeMock $cakeTime) {
$this->_CakeTime = $cakeTime;
}

}

/**
* CakeTimeMock class
*/
class CakeTimeMock {
}

/**
* TimeHelperTest class
*
Expand All @@ -48,10 +54,8 @@ class TimeHelperTest extends CakeTestCase {
* @return void
*/
public function setUp() {
$View = new View(null);
$this->CakeTime = $this->getMock('CakeTime');
$this->Time = new TimeHelperTestObject($View);
$this->Time->attach($this->CakeTime);
parent::setUp();
$this->View = new View(null);
}

/**
Expand All @@ -60,8 +64,8 @@ public function setUp() {
* @return void
*/
public function tearDown() {
unset($this->Time);
unset($this->CakeTime);
unset($this->View);
parent::tearDown();
}

/**
Expand All @@ -75,9 +79,12 @@ public function testTimeHelperProxyMethodCalls() {
'isTomorrow', 'toQuarter', 'toUnix', 'toAtom', 'toRSS',
'timeAgoInWords', 'wasWithinLast', 'gmt', 'format', 'i18nFormat',
);
$CakeTime = $this->getMock('CakeTimeMock', $methods);
$Time = new TimeHelperTestObject($this->View, array('engine' => 'CakeTimeMock'));
$Time->attach($CakeTime);
foreach ($methods as $method) {
$this->CakeTime->expects($this->at(0))->method($method);
$this->Time->{$method}('who', 'what', 'when', 'where', 'how');
$CakeTime->expects($this->at(0))->method($method);
$Time->{$method}('who', 'what', 'when', 'where', 'how');
}
}

Expand Down

0 comments on commit d6fd051

Please sign in to comment.