diff options
author | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-02 18:40:04 +0000 |
---|---|---|
committer | brettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2009-10-02 18:40:04 +0000 |
commit | 322bb9cd2be9e51422cb2b82684692e825c2bfb7 (patch) | |
tree | 1e8e75c1ff0c47d6eda9db114a13dfa2b83adf72 /vendors/simpletest/test/dumper_test.php | |
parent | 4ffb02ad9c1b95013a0fbf97cefde827600ecc3f (diff) | |
download | elgg-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/test/dumper_test.php')
-rwxr-xr-x | vendors/simpletest/test/dumper_test.php | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/vendors/simpletest/test/dumper_test.php b/vendors/simpletest/test/dumper_test.php new file mode 100755 index 000000000..789047de9 --- /dev/null +++ b/vendors/simpletest/test/dumper_test.php @@ -0,0 +1,88 @@ +<?php +// $Id: dumper_test.php 1505 2007-04-30 23:39:59Z lastcraft $ +require_once(dirname(__FILE__) . '/../autorun.php'); + +class DumperDummy { +} + +class TestOfTextFormatting extends UnitTestCase { + + function testClipping() { + $dumper = new SimpleDumper(); + $this->assertEqual( + $dumper->clipString("Hello", 6), + "Hello", + "Hello, 6->%s"); + $this->assertEqual( + $dumper->clipString("Hello", 5), + "Hello", + "Hello, 5->%s"); + $this->assertEqual( + $dumper->clipString("Hello world", 3), + "Hel...", + "Hello world, 3->%s"); + $this->assertEqual( + $dumper->clipString("Hello world", 6, 3), + "Hello ...", + "Hello world, 6, 3->%s"); + $this->assertEqual( + $dumper->clipString("Hello world", 3, 6), + "...o w...", + "Hello world, 3, 6->%s"); + $this->assertEqual( + $dumper->clipString("Hello world", 4, 11), + "...orld", + "Hello world, 4, 11->%s"); + $this->assertEqual( + $dumper->clipString("Hello world", 4, 12), + "...orld", + "Hello world, 4, 12->%s"); + } + + function testDescribeNull() { + $dumper = new SimpleDumper(); + $this->assertPattern('/null/i', $dumper->describeValue(null)); + } + + function testDescribeBoolean() { + $dumper = new SimpleDumper(); + $this->assertPattern('/boolean/i', $dumper->describeValue(true)); + $this->assertPattern('/true/i', $dumper->describeValue(true)); + $this->assertPattern('/false/i', $dumper->describeValue(false)); + } + + function testDescribeString() { + $dumper = new SimpleDumper(); + $this->assertPattern('/string/i', $dumper->describeValue('Hello')); + $this->assertPattern('/Hello/', $dumper->describeValue('Hello')); + } + + function testDescribeInteger() { + $dumper = new SimpleDumper(); + $this->assertPattern('/integer/i', $dumper->describeValue(35)); + $this->assertPattern('/35/', $dumper->describeValue(35)); + } + + function testDescribeFloat() { + $dumper = new SimpleDumper(); + $this->assertPattern('/float/i', $dumper->describeValue(0.99)); + $this->assertPattern('/0\.99/', $dumper->describeValue(0.99)); + } + + function testDescribeArray() { + $dumper = new SimpleDumper(); + $this->assertPattern('/array/i', $dumper->describeValue(array(1, 4))); + $this->assertPattern('/2/i', $dumper->describeValue(array(1, 4))); + } + + function testDescribeObject() { + $dumper = new SimpleDumper(); + $this->assertPattern( + '/object/i', + $dumper->describeValue(new DumperDummy())); + $this->assertPattern( + '/DumperDummy/i', + $dumper->describeValue(new DumperDummy())); + } +} +?>
\ No newline at end of file |