aboutsummaryrefslogtreecommitdiff
path: root/vendors/simpletest/extensions/testdox
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-02 18:40:04 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2009-10-02 18:40:04 +0000
commit322bb9cd2be9e51422cb2b82684692e825c2bfb7 (patch)
tree1e8e75c1ff0c47d6eda9db114a13dfa2b83adf72 /vendors/simpletest/extensions/testdox
parent4ffb02ad9c1b95013a0fbf97cefde827600ecc3f (diff)
downloadelgg-322bb9cd2be9e51422cb2b82684692e825c2bfb7.tar.gz
elgg-322bb9cd2be9e51422cb2b82684692e825c2bfb7.tar.bz2
Added simpletest and start of unit tests.
git-svn-id: http://code.elgg.org/elgg/trunk@3503 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'vendors/simpletest/extensions/testdox')
-rwxr-xr-xvendors/simpletest/extensions/testdox/test.php108
1 files changed, 108 insertions, 0 deletions
diff --git a/vendors/simpletest/extensions/testdox/test.php b/vendors/simpletest/extensions/testdox/test.php
new file mode 100755
index 000000000..82c5b7da8
--- /dev/null
+++ b/vendors/simpletest/extensions/testdox/test.php
@@ -0,0 +1,108 @@
+<?php
+// $Id: test.php 1641 2008-01-22 20:13:52Z pp11 $
+require_once dirname(__FILE__) . '/../../autorun.php';
+require_once dirname(__FILE__) . '/../testdox.php';
+
+// uncomment to see test dox in action
+//SimpleTest::prefer(new TestDoxReporter());
+
+class TestOfTestDoxReporter extends UnitTestCase
+{
+ function testIsAnInstanceOfSimpleScorerAndReporter() {
+ $dox = new TestDoxReporter();
+ $this->assertIsA($dox, 'SimpleScorer');
+ $this->assertIsA($dox, 'SimpleReporter');
+ }
+
+ function testOutputsNameOfTestCase() {
+ $dox = new TestDoxReporter();
+ ob_start();
+ $dox->paintCaseStart('TestOfTestDoxReporter');
+ $buffer = ob_get_clean();
+ $this->assertWantedPattern('/^TestDoxReporter/', $buffer);
+ }
+
+ function testOutputOfTestCaseNameFilteredByConstructParameter() {
+ $dox = new TestDoxReporter('/^(.*)Test$/');
+ ob_start();
+ $dox->paintCaseStart('SomeGreatWidgetTest');
+ $buffer = ob_get_clean();
+ $this->assertWantedPattern('/^SomeGreatWidget/', $buffer);
+ }
+
+ function testIfTest_case_patternIsEmptyAssumeEverythingMatches() {
+ $dox = new TestDoxReporter('');
+ ob_start();
+ $dox->paintCaseStart('TestOfTestDoxReporter');
+ $buffer = ob_get_clean();
+ $this->assertWantedPattern('/^TestOfTestDoxReporter/', $buffer);
+ }
+
+ function testEmptyLineInsertedWhenCaseEnds() {
+ $dox = new TestDoxReporter();
+ ob_start();
+ $dox->paintCaseEnd('TestOfTestDoxReporter');
+ $buffer = ob_get_clean();
+ $this->assertEqual("\n", $buffer);
+ }
+
+ function testPaintsTestMethodInTestDoxFormat() {
+ $dox = new TestDoxReporter();
+ ob_start();
+ $dox->paintMethodStart('testSomeGreatTestCase');
+ $buffer = ob_get_clean();
+ $this->assertEqual("- some great test case", $buffer);
+ unset($buffer);
+
+ $random = rand(100, 200);
+ ob_start();
+ $dox->paintMethodStart("testRandomNumberIs{$random}");
+ $buffer = ob_get_clean();
+ $this->assertEqual("- random number is {$random}", $buffer);
+ }
+
+ function testDoesNotOutputAnythingOnNoneTestMethods() {
+ $dox = new TestDoxReporter();
+ ob_start();
+ $dox->paintMethodStart('nonMatchingMethod');
+ $buffer = ob_get_clean();
+ $this->assertEqual('', $buffer);
+ }
+
+ function testPaintMethodAddLineBreak() {
+ $dox = new TestDoxReporter();
+ ob_start();
+ $dox->paintMethodEnd('someMethod');
+ $buffer = ob_get_clean();
+ $this->assertEqual("\n", $buffer);
+ $this->assertNoErrors();
+ }
+
+ function testProperlySpacesSingleLettersInMethodName() {
+ $dox = new TestDoxReporter();
+ ob_start();
+ $dox->paintMethodStart('testAVerySimpleAgainAVerySimpleMethod');
+ $buffer = ob_get_clean();
+ $this->assertEqual('- a very simple again a very simple method', $buffer);
+ }
+
+ function testOnFailureThisPrintsFailureNotice() {
+ $dox = new TestDoxReporter();
+ ob_start();
+ $dox->paintFail();
+ $buffer = ob_get_clean();
+ $this->assertEqual(' [FAILED]', $buffer);
+ }
+
+ function testWhenMatchingMethodNamesTestPrefixIsCaseInsensitive() {
+ $dox = new TestDoxReporter();
+ ob_start();
+ $dox->paintMethodStart('TESTSupportsAllUppercaseTestPrefixEvenThoughIDoNotKnowWhyYouWouldDoThat');
+ $buffer = ob_get_clean();
+ $this->assertEqual(
+ '- supports all uppercase test prefix even though i do not know why you would do that',
+ $buffer
+ );
+ }
+}
+