[Fusionforge-commits] r6938 - in trunk: . tests tests/code tests/code/syntax tests/unit tests/unit/utils
Alain Peyrat
aljeux at libremir.placard.fr.eu.org
Wed Feb 4 23:28:45 CET 2009
Author: aljeux
Date: 2009-02-04 23:28:44 +0100 (Wed, 04 Feb 2009)
New Revision: 6938
Added:
trunk/tests/
trunk/tests/AllTests.php
trunk/tests/code/
trunk/tests/code/syntax/
trunk/tests/code/syntax/AllTests.php
trunk/tests/code/syntax/SyntaxTests.php
trunk/tests/unit/
trunk/tests/unit/AllTests.php
trunk/tests/unit/utils/
trunk/tests/unit/utils/AllTests.php
trunk/tests/unit/utils/UtilsTests.php
Log:
Initial code for tests
Added: trunk/tests/AllTests.php
===================================================================
--- trunk/tests/AllTests.php (rev 0)
+++ trunk/tests/AllTests.php 2009-02-04 22:28:44 UTC (rev 6938)
@@ -0,0 +1,64 @@
+<?php
+if (!defined('PHPUnit_MAIN_METHOD')) {
+ define('PHPUnit_MAIN_METHOD', 'AllTests::main');
+}
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+// Unit tests
+require_once 'unit/utils/AllTests.php';
+//require_once 'ACL/AllTests.php';
+
+// Code tests
+require_once 'code/syntax/AllTests.php';
+
+// Selenium based tests
+//require_once 'func/Site/AllTests.php';
+//require_once 'func/Trackers/AllTests.php';
+//require_once 'func/Tasks/AllTests.php';
+//require_once 'func/Forums/AllTests.php';
+//require_once 'func/PluginsWiki/AllTests.php';
+//require_once 'func/PluginsWebSvn/AllTests.php';
+//require_once 'func/News/AllTests.php';
+//require_once 'func/scm/AllTests.php';
+//require_once 'func/docs/AllTests.php';
+
+
+class AllTests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('PHPUnit');
+
+ // Unit tests
+ $suite->addTest(Utils_AllTests::suite());
+// $suite->addTest(ACL_AllTests::suite());
+
+ // Code tests
+ $suite->addTest(Syntax_AllTests::suite());
+
+ // Integration tests (Selenium).
+// $suite->addTest(Site_AllTests::suite());
+// $suite->addTest(Trackers_AllTests::suite());
+// $suite->addTest(Tasks_AllTests::suite());
+// $suite->addTest(Forums_AllTests::suite());
+// $suite->addTest(News_AllTests::suite());
+// $suite->addTest(PluginsWiki_AllTests::suite());
+// $suite->addTest(PluginsWebSvn_AllTests::suite());
+// $suite->addTest(Scm_AllTests::suite());
+// $suite->addTest(Docs_AllTests::suite());
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'AllTests::main') {
+ AllTests::main();
+}
+?>
Property changes on: trunk/tests/AllTests.php
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/tests/code/syntax/AllTests.php
===================================================================
--- trunk/tests/code/syntax/AllTests.php (rev 0)
+++ trunk/tests/code/syntax/AllTests.php 2009-02-04 22:28:44 UTC (rev 6938)
@@ -0,0 +1,18 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+
+require_once dirname(__FILE__).'/SyntaxTests.php';
+
+class Syntax_AllTests
+{
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
+
+ $suite->addTestSuite('Syntax_Tests');
+ // ...
+
+ return $suite;
+ }
+}
+?>
Added: trunk/tests/code/syntax/SyntaxTests.php
===================================================================
--- trunk/tests/code/syntax/SyntaxTests.php (rev 0)
+++ trunk/tests/code/syntax/SyntaxTests.php 2009-02-04 22:28:44 UTC (rev 6938)
@@ -0,0 +1,25 @@
+<?php
+
+require_once 'PHPUnit/Framework/TestCase.php';
+
+/**
+ * Simple math test class.
+ *
+ * @package Example
+ * @author Manuel Pichler <mapi at phpundercontrol.org>
+ * @copyright 2007-2008 Manuel Pichler. All rights reserved.
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 0.4.7
+ * @link http://www.phpundercontrol.org/
+ */
+class Syntax_Tests extends PHPUnit_Framework_TestCase
+{
+ /**
+ * Validate all php code with php -l.
+ */
+ public function testPhpSyntax()
+ {
+ $output = `find ../gforge -name '*.php' -type f -exec php -l {} \; | grep -v '^No syntax errors detected'`;
+ $this->assertEquals('', $output);
+ }
+}
Added: trunk/tests/unit/AllTests.php
===================================================================
--- trunk/tests/unit/AllTests.php (rev 0)
+++ trunk/tests/unit/AllTests.php 2009-02-04 22:28:44 UTC (rev 6938)
@@ -0,0 +1,33 @@
+<?php
+if (!defined('PHPUnit_MAIN_METHOD')) {
+ define('PHPUnit_MAIN_METHOD', 'AllTests::main');
+}
+
+require_once 'PHPUnit/Framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+// Unit tests
+require_once 'utils/AllTests.php';
+
+class AllTests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('PHPUnit');
+
+ // Unit tests
+ $suite->addTest(Utils_AllTests::suite());
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'AllTests::main') {
+ AllTests::main();
+}
+?>
Property changes on: trunk/tests/unit/AllTests.php
___________________________________________________________________
Added: svn:executable
+ *
Added: trunk/tests/unit/utils/AllTests.php
===================================================================
--- trunk/tests/unit/utils/AllTests.php (rev 0)
+++ trunk/tests/unit/utils/AllTests.php 2009-02-04 22:28:44 UTC (rev 6938)
@@ -0,0 +1,19 @@
+<?php
+require_once 'PHPUnit/Framework.php';
+
+require_once dirname(__FILE__).'/UtilsTests.php';
+// ...
+
+class Utils_AllTests
+{
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('PHPUnit Framework');
+
+ $suite->addTestSuite('Utils_Tests');
+ // ...
+
+ return $suite;
+ }
+}
+?>
Added: trunk/tests/unit/utils/UtilsTests.php
===================================================================
--- trunk/tests/unit/utils/UtilsTests.php (rev 0)
+++ trunk/tests/unit/utils/UtilsTests.php 2009-02-04 22:28:44 UTC (rev 6938)
@@ -0,0 +1,43 @@
+<?php
+
+require_once 'PHPUnit/Framework/TestCase.php';
+require_once dirname(__FILE__) . '/../../../gforge/common/include/utils.php';
+
+/**
+ * Simple math test class.
+ *
+ * @package Example
+ * @author Manuel Pichler <mapi at phpundercontrol.org>
+ * @copyright 2007-2008 Manuel Pichler. All rights reserved.
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
+ * @version Release: 0.4.7
+ * @link http://www.phpundercontrol.org/
+ */
+class Utils_Tests extends PHPUnit_Framework_TestCase
+{
+ /**
+ * test the validate_email function.
+ */
+ public function testEmail()
+ {
+ $this->assertTrue(validate_email('al at fx.fr'), 'al at fx.fr is a valid email address');
+
+ $this->assertFalse(validate_email('al @fx.fr'), 'al @fx.fr is not a valid email address');
+
+ $this->assertFalse(validate_email('al'), 'al is not a valid email address');
+ }
+
+ /**
+ * test the validate_hostname function.
+ */
+ public function testHostname()
+ {
+ $this->assertTrue(valid_hostname('myhost.com'), 'myhost.com is a valid hostname.');
+
+ $this->assertTrue(valid_hostname('myhost.com.'), 'myhost.com. is a valid hostname.');
+
+ $this->assertFalse(valid_hostname('my host.com'), 'my host.com is not a valid hostname');
+
+ $this->assertFalse(valid_hostname('O at O'), 'O at O is not a valid hostname');
+ }
+}
More information about the Fusionforge-commits
mailing list