Skip to content

Commit

Permalink
adding more tests for Libs plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dogmatic69 committed Jun 21, 2012
1 parent e8f0151 commit 702f301
Show file tree
Hide file tree
Showing 9 changed files with 200 additions and 192 deletions.
17 changes: 17 additions & 0 deletions Core/Libs/Test/Case/AllLibsTestsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
class AllLibsTestsTest extends PHPUnit_Framework_TestSuite {

/**
* Suite define the tests for this suite
*
* @return void
*/
public static function suite() {
$suite = new CakeTestSuite('All Libs test');

$path = CakePlugin::path('Libs') . 'Test' . DS . 'Case' . DS;
$suite->addTestDirectoryRecursive($path);

return $suite;
}
}
26 changes: 13 additions & 13 deletions Core/Libs/Test/Case/Helpers/InfiniTimeTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
App::import('lib', 'libs.test/app_helper_test.php');
App::import('helper', 'Libs.InfiniTime');
class TestInfiniTimeHelper extends AppHelperTestCase {

class TestInfiniTimeHelper extends CakeTestCase {

/**
* @brief Configuration for the test case
*
* Loading fixtures:
*
*
* List all the needed fixtures in the do part of the fixture array.
* In replace you can overwrite fixtures of other plugins by your own.
*
Expand All @@ -20,26 +20,26 @@ class TestInfiniTimeHelper extends AppHelperTestCase {
* 'Core.User' => 'SomePlugin.User
* )
* )
* @var array
* @var array
*/
public $setup = array(
'helper' => 'Libs.InfiniTime'
);

/**
* @brief Contains a list of test methods to run
*
* If it is set to false all the methods will run. Otherwise pass in an array
* with a list of tests to run.
*
* @var mixed
* @var mixed
*/
public $tests = false;

/**
* @brief Contains the backup of the system timezone
*
* @var string
* @var string
*/
private $__timeZoneBackup = null;

Expand All @@ -57,10 +57,10 @@ public function startTest($method) {

public function endTest($method) {
parent::endTest($method);

date_default_timezone_set($this->__timeZoneBackup);
}

/**
* @brief Tests fromString
*
Expand Down Expand Up @@ -107,7 +107,7 @@ public function testNiceStrings() {
* Test with UTC server timezone
*/
date_default_timezone_set('UTC');

//Test timezones in DST
$dateString = '2011-08-17 16:00:00';

Expand All @@ -117,7 +117,7 @@ public function testNiceStrings() {
$this->assertEqual('Wed, Aug 17th 2011, 18:00', $this->InfiniTime->nice($dateString));
CakeSession::write('Auth.User.time_zone', 'America/Mexico_City');
$this->assertEqual('Wed, Aug 17th 2011, 11:00', $this->InfiniTime->nice($dateString));

//Test timezones currently not in DST
$dateString = '2011-01-10 12:00:00';

Expand Down Expand Up @@ -191,7 +191,7 @@ public function testTimeAgoInWord() {

$result = $this->InfiniTime->timeAgoInWords('2010-05-10 10:00:00', array('format' => 'Y-m-d H:i:s'));
$this->assertEqual('on 2010-05-10 12:00:00', $result);

$result = $this->InfiniTime->timeAgoInWords(strtotime('1995-01-10 10:00:00'), array('format' => 'Y-m-d H:i:s'));
$this->assertEqual('on 1995-01-10 11:00:00', $result);

Expand All @@ -205,7 +205,7 @@ public function testVarious() {
CakeSession::write('Auth.User.time_zone', 'Europe/London');
$result = $this->InfiniTime->dayAsSql('2009-10-30', 'Item.created');
$this->assertEqual("(Item.created >= '2009-10-30 00:00:00') AND (Item.created <= '2009-10-30 23:59:59')", $result);

$result = $this->InfiniTime->format('Y-m-d H:i:s', '2010-10-24 14:15:10');
$this->assertEqual('2010-10-24 15:15:10', $result);

Expand Down
12 changes: 7 additions & 5 deletions Core/Libs/Test/Case/Helpers/TreeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

App::import('Helper', 'Libs.Tree');

class ScopedNumberTree extends CakeTestModel {
public $actsAs = array('Libs.InfiniTree' => array('scopeField' => 'category_id'));
if(!class_exists('ScopedNumberTree')) {
class ScopedNumberTree extends CakeTestModel {
public $actsAs = array('Libs.InfiniTree' => array('scopeField' => 'category_id'));
}
}

/**
* TreeHelperTest class
*/
class TreeHelperTest extends AppModelTestCase {
class TreeHelperTest extends CakeTestCase {

public $setup = array(
'model' => 'Libs.ScopedNumberTree',
Expand All @@ -25,7 +27,7 @@ class TreeHelperTest extends AppModelTestCase {

function startTest($method) {
parent::startTest($method);

$this->Tree = new TreeHelper();
}

Expand Down Expand Up @@ -113,7 +115,7 @@ function testFullTree() {
$expected = array('model' => 'ScopedNumberTree', 'left'=> 'lft', 'right' => 'rght', 'primaryKey' => 'id', 'parent' => 'parent_id');
$this->assertEqual($expected, $this->Tree->settings);
}

function testSubTree() {
$data = $this->ScopedNumberTree->children('cat-b-3');

Expand Down
12 changes: 6 additions & 6 deletions Core/Libs/Test/Case/Model/Behavior/CopyableTest.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
App::import('lib', 'libs.test/AppBehaviorTest');
class TestCopyableBehavior extends AppBehaviorTestCase {

class TestCopyableBehavior extends CakeTestCase {

/**
* @brief Configuration for the test case
*
* Loading fixtures:
*
*
* List all the needed fixtures in the do part of the fixture array.
* In replace you can overwrite fixtures of other plugins by your own.
*
Expand All @@ -19,7 +19,7 @@ class TestCopyableBehavior extends AppBehaviorTestCase {
* 'Core.User' => 'SomePlugin.User
* )
* )
* @var array
* @var array
*/
public $setup = array(
'behavior' => 'libs.Copyable',
Expand All @@ -36,14 +36,14 @@ class TestCopyableBehavior extends AppBehaviorTestCase {
)
)
);

/**
* @brief Contains a list of test methods to run
*
* If it is set to false all the methods will run. Otherwise pass in an array
* with a list of tests to run.
*
* @var mixed
* @var mixed
*/
public $tests = false;

Expand Down

0 comments on commit 702f301

Please sign in to comment.