Author: voxus
Date: 2006-01-25 04:07:19 +0300 (Wed, 25 Jan 2006)
New Revision: 1204
Added:
trunk/test/
trunk/test/config.inc.php.tpl
trunk/test/core/
trunk/test/core/AssertTest.class.php
trunk/test/core/SingletoneTest.class.php
trunk/test/core/TimestampTest.class.php
trunk/test/main/
trunk/test/runme.php
Modified:
trunk/doc/ChangeLog
Log:
+ tests, yay!
Modified: trunk/doc/ChangeLog
===================================================================
--- trunk/doc/ChangeLog 2006-01-25 00:29:02 UTC (rev 1203)
+++ trunk/doc/ChangeLog 2006-01-25 01:07:19 UTC (rev 1204)
@@ -1,5 +1,9 @@
# $Id$
+2006-01-25 Konstantin V. Arkhipov <voxusAT@ATshadanakar.org>
+
+ * test/: first SimpleTest-based tests. Baden. Baden.
+
2006-01-23 Anton E. Lebedevich <noiselistAT@ATpochta.ru>
* core/OSQL/FromTable.class.php: SQLFunction support added.
Property changes on: trunk/test
___________________________________________________________________
Name: svn:ignore
+ <?php
/* $Id$ */
define('ONPHP_TEST_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
require ONPHP_TEST_PATH.'../global.inc.php.tpl';
error_reporting(E_ALL); // & ~E_STRICT due to simpletest limitations
set_include_path(
// current path
get_include_path().PATH_SEPARATOR
.ONPHP_TEST_PATH.'core'.PATH_SEPARATOR
.ONPHP_TEST_PATH.'base'.PATH_SEPARATOR
);
define('SIMPLETEST_PATH', '/home/voxus/stuff/cvs/simpletest/');
require SIMPLETEST_PATH.'unit_tester.php';
require SIMPLETEST_PATH.'reporter.php';
?>
Added: trunk/test/config.inc.php.tpl
===================================================================
--- trunk/test/config.inc.php.tpl (rev 0)
+++ trunk/test/config.inc.php.tpl 2006-01-25 01:07:19 UTC (rev 1204)
@@ -0,0 +1,21 @@
+<?php
+ /* $Id$ */
+
+ define('ONPHP_TEST_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
+
+ require ONPHP_TEST_PATH.'../global.inc.php.tpl';
+
+ error_reporting(E_ALL); // & ~E_STRICT due to simpletest limitations
+
+ set_include_path(
+ // current path
+ get_include_path().PATH_SEPARATOR
+ .ONPHP_TEST_PATH.'core'.PATH_SEPARATOR
+ .ONPHP_TEST_PATH.'base'.PATH_SEPARATOR
+ );
+
+ define('SIMPLETEST_PATH', '/usr/share/php/simpletest/');
+
+ require SIMPLETEST_PATH.'unit_tester.php';
+ require SIMPLETEST_PATH.'reporter.php';
+?>
\ No newline at end of file
Added: trunk/test/core/AssertTest.class.php
===================================================================
--- trunk/test/core/AssertTest.class.php (rev 0)
+++ trunk/test/core/AssertTest.class.php 2006-01-25 01:07:19 UTC (rev 1204)
@@ -0,0 +1,68 @@
+<?php
+ /* $Id$ */
+
+ final class AssertTest extends UnitTestCase
+ {
+ public function testTrue()
+ {
+ Assert::isTrue(true);
+
+ try {
+ Assert::isTrue(false);
+ $this->fail();
+ } catch (WrongArgumentException $e) {
+ $this->pass();
+ }
+ }
+
+ public function testFalse()
+ {
+ Assert::isFalse(false);
+
+ try {
+ Assert::isFalse(true);
+ $this->fail();
+ } catch (WrongArgumentException $e) {
+ $this->pass();
+ }
+ }
+
+ public function testInteger()
+ {
+ Assert::isInteger(2006);
+
+ try {
+ Assert::isInteger(20.06);
+ $this->fail();
+ } catch (WrongArgumentException $e) {
+ $this->pass();
+ }
+
+ try {
+ Assert::isInteger(acos(20.06));
+ $this->fail();
+ } catch (WrongArgumentException $e) {
+ $this->pass();
+ }
+
+ try {
+ Assert::isInteger(log(0));
+ $this->fail();
+ } catch (WrongArgumentException $e) {
+ $this->pass();
+ }
+ }
+
+ public function testTernaryBase()
+ {
+ try {
+ Assert::isTernaryBase($value = true);
+ Assert::isTernaryBase($value = false);
+ Assert::isTernaryBase($value = null);
+ $this->pass();
+ } catch (WrongArgumentException $e) {
+ $this->fail();
+ }
+ }
+ }
+?>
\ No newline at end of file
Property changes on: trunk/test/core/AssertTest.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/test/core/SingletoneTest.class.php
===================================================================
--- trunk/test/core/SingletoneTest.class.php (rev 0)
+++ trunk/test/core/SingletoneTest.class.php 2006-01-25 01:07:19 UTC (rev 1204)
@@ -0,0 +1,41 @@
+<?php
+ /* $Id$ */
+
+ final class SingletoneTestInstance extends Singletone {/*_*/}
+
+ final class SingletoneTest extends UnitTestCase
+ {
+ private $childName = 'SingletoneTestInstance';
+
+ public function testFactoryLikeCall()
+ {
+ $this->assertTrue(
+ Singletone::getInstance($this->childName)
+ === Singletone::getInstance($this->childName)
+ );
+ }
+
+ public function testOverloadedCall()
+ {
+ $name = $this->childName;
+
+ $this->assertTrue(
+ Singletone::getInstance()->$name()
+ === Singletone::getInstance()->$name()
+ );
+ }
+
+ public function testCreationProhibition()
+ {
+ $child = new ReflectionClass($this->childName);
+
+ $this->assertTrue(
+ !$child->getMethod('__construct')->isPublic()
+ );
+
+ $this->assertTrue(
+ $child->getMethod('__construct')->isProtected()
+ );
+ }
+ }
+?>
\ No newline at end of file
Property changes on: trunk/test/core/SingletoneTest.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/test/core/TimestampTest.class.php
===================================================================
--- trunk/test/core/TimestampTest.class.php (rev 0)
+++ trunk/test/core/TimestampTest.class.php 2006-01-25 01:07:19 UTC (rev 1204)
@@ -0,0 +1,32 @@
+<?php
+ /* $Id$ */
+
+ final class TimestampTest extends UnitTestCase
+ {
+ public function testNonEpoch()
+ {
+ $future = '4683-03-04';
+ $after = new Timestamp($future);
+
+ $this->assertEqual($after->getDay(), '04');
+ $this->assertEqual($after->getMonth(), '03');
+ $this->assertEqual($after->getYear(), '4683');
+
+ $past = '1234-04-03';
+ $before = new Timestamp($past);
+
+ $this->assertEqual($before->getDay(), '03');
+ $this->assertEqual($before->getMonth(), '04');
+ $this->assertEqual($before->getYear(), '1234');
+
+ $this->assertFalse($after->equals($before));
+
+ $this->assertEqual($future, $after->toDate());
+ $this->assertEqual($past, $before->toDate());
+
+ $time = ' 00:00.00';
+ $this->assertEqual($future.$time, $after->toDateTime());
+ $this->assertEqual($past.$time, $before->toDateTime());
+ }
+ }
+?>
\ No newline at end of file
Property changes on: trunk/test/core/TimestampTest.class.php
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Added: trunk/test/runme.php
===================================================================
--- trunk/test/runme.php (rev 0)
+++ trunk/test/runme.php 2006-01-25 01:07:19 UTC (rev 1204)
@@ -0,0 +1,16 @@
+<?php
+ /* $Id$ */
+
+ $config = dirname(__FILE__).'/config.inc.php';
+
+ require is_readable($config) ? $config : $config.'.tpl';
+
+ $reporter = php_sapi_name() == 'cli' ? new TextReporter() : new HtmlReporter();
+
+ $test = new GroupTest('onPHP-'.ONPHP_VERSION);
+
+ foreach (glob(ONPHP_TEST_PATH.'*/*.class.php') as $file)
+ $test->addTestFile($file);
+
+ $test->run($reporter);
+?>
\ No newline at end of file
Property changes on: trunk/test/runme.php
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Received on Wed Jan 25 2006 - 04:07:20 MSK
This archive was generated by hypermail 2.2.0 : Sat Oct 27 2007 - 19:44:41 MSD