From 65f7247f25414ab31f5785bcc4d050ead9fd9105 Mon Sep 17 00:00:00 2001 From: oussaka Date: Thu, 12 Jan 2017 22:40:39 +0000 Subject: [PATCH] misc fix --- 01StackTest.php | 78 +- 02DependencyTest.php | 118 +-- 03DependencyFailureTest.php | 102 +-- 04DataProvider.php | 90 +- 05CSVDataProvidor.php | 82 +- 06ExceptionTest.php | 50 +- 07ExceptionWithMsgAndCode.php | 92 +- 08AnotherWayOfExceptionTesting.php | 108 +-- 09TestPhpErrors.php | 84 +- 10OutoutBuffering.php | 78 +- 11ArrayHasKey.php | 42 +- 12ClassHasAttribute.php | 74 +- 13ClassHasStaticAttribute.php | 60 +- 14Contains.php | 170 ++-- 15ContainsOnly.php | 158 ++-- 16ContainsOnlyInstancesOf.php | 66 +- 17Count.php | 42 +- 18Empty.php | 44 +- 19EqualXMLStructure.php | 166 ++-- 20Equals1.php | 86 +- 21Equals2.php | 50 +- 22Equals3.php | 58 +- 23Equals4.php | 62 +- 24Equals5.php | 50 +- 25False.php | 34 +- 26FileEquals.php | 72 +- 27FileExists.php | 54 +- 28GreaterThan.php | 60 +- 29GreaterThanOrEqual.php | 92 +- 30InstanceOf.php | 44 +- 31InternalType.php | 42 +- 32JsonFileEqualsJsonFile.php | 70 +- 33JsonStringEqualsJsonFile.php | 78 +- 34JsonStringEqualsJsonString.php | 48 +- 35LessThan.php | 42 +- 36LessThanOrEqual.php | 44 +- 37Null.php | 34 +- 38ObjectHasAttribute.php | 42 +- 39RegExp.php | 36 +- 40StringMatchesFormat.php | 100 +-- 41StringMatchesFormatFile.php | 54 +- 42Same1.php | 42 +- 43Same2.php | 42 +- 44SelectCount.php | 100 +-- 45SelectEquals.php | 98 +- 46SelectRegExp.php | 100 +-- 47StringEndsWith.php | 36 +- 48StringEqualsFile.php | 46 +- 49StringStartsWith.php | 40 +- 50Tag.php | 240 ++--- 51That.php | 304 +++---- 52True.php | 24 +- 53XmlFileEqualsXmlFile.php | 46 +- 54XmlStringEqualsXmlFile.php | 48 +- 55XmlStringEqualsXmlString.php | 46 +- 56TemplateMethod.php | 168 ++-- 57DBTest.php | 405 ++++----- LICENSE | 1348 ++++++++++++++-------------- README.md | 37 +- data/data.csv | 10 +- fixtures/address.csv | 2 +- fixtures/class.csv | 6 +- fixtures/myDataSet.yml | 50 +- fixtures/myFlatXml1.xml | 10 +- fixtures/myFlatXmlFixture.xml | 24 +- fixtures/mySqldumpXmlDataset.xml | 62 +- fixtures/myXmlDataset.xml | 68 +- fixtures/user.csv | 6 +- lib/ArrayDataset.php | 86 +- lib/CsvFileIterator.php | 84 +- misc/PDOTest.php | 200 ++--- phpunit.xml.dist | 48 + sql/test_pdo.sql | 72 +- 73 files changed, 3459 insertions(+), 3395 deletions(-) create mode 100644 phpunit.xml.dist diff --git a/01StackTest.php b/01StackTest.php index 05432ac..c2930a9 100644 --- a/01StackTest.php +++ b/01StackTest.php @@ -1,40 +1,40 @@ -assertEquals(0, count($stack)); - - array_push($stack, 'foo'); - - $this->assertEquals('foo', $stack[count($stack)-1]); - $this->assertEquals(1, count($stack)); - - $this->assertEquals('foo', array_pop($stack)); - $this->assertEquals(0, count($stack)); - } -} +assertEquals(0, count($stack)); + + array_push($stack, 'foo'); + + $this->assertEquals('foo', $stack[count($stack)-1]); + $this->assertEquals(1, count($stack)); + + $this->assertEquals('foo', array_pop($stack)); + $this->assertEquals(0, count($stack)); + } +} ?> \ No newline at end of file diff --git a/02DependencyTest.php b/02DependencyTest.php index 14a57e3..ec3c868 100644 --- a/02DependencyTest.php +++ b/02DependencyTest.php @@ -1,60 +1,60 @@ -assertEmpty($stack); - - return $stack; - } - - /** - * This method is also a test method but its execution depends upon - * the value returned by testEmpty method. If testEmpty method report - * any error this test will never be fired - * - * @param array $stack This is an array return by testEmpty method - * @depends testEmpty - */ - public function testPush(array $stack) - { - array_push($stack, 'foo'); - $this->assertEquals('foo', $stack[count($stack)-1]); - $this->assertNotEmpty($stack); - - return $stack; - } - - /** - * This method is also a test method but its execution depends upon - * the value returned by testEmpty method. If testEmpty method report - * any error this test will never be fired - * - * @param array $stack This is an array return by testEmpty method - * @depends testPush - */ - public function testPop(array $stack) - { - $this->assertEquals('foo', array_pop($stack)); - $this->assertEmpty($stack); - } -} +assertEmpty($stack); + + return $stack; + } + + /** + * This method is also a test method but its execution depends upon + * the value returned by testEmpty method. If testEmpty method report + * any error this test will never be fired + * + * @param array $stack This is an array return by testEmpty method + * @depends testEmpty + */ + public function testPush(array $stack) + { + array_push($stack, 'foo'); + $this->assertEquals('foo', $stack[count($stack)-1]); + $this->assertNotEmpty($stack); + + return $stack; + } + + /** + * This method is also a test method but its execution depends upon + * the value returned by testEmpty method. If testEmpty method report + * any error this test will never be fired + * + * @param array $stack This is an array return by testEmpty method + * @depends testPush + */ + public function testPop(array $stack) + { + $this->assertEquals('foo', array_pop($stack)); + $this->assertEmpty($stack); + } +} ?> \ No newline at end of file diff --git a/03DependencyFailureTest.php b/03DependencyFailureTest.php index 6dff5bd..4571b22 100644 --- a/03DependencyFailureTest.php +++ b/03DependencyFailureTest.php @@ -1,52 +1,52 @@ -assertTrue(FALSE); - return array(); - } - - /** - * This test will never get executed because the function - * it depends will not get passed - * - * @depends testOne - */ - public function testTwo($arr) - { - - } - - /** - * This test will also never get executed because the function - * it depends will not get passed - * - * @depends testOne - */ - public function testThree($arr) - { - - } -} +assertTrue(FALSE); + return array(); + } + + /** + * This test will never get executed because the function + * it depends will not get passed + * + * @depends testOne + */ + public function testTwo($arr) + { + + } + + /** + * This test will also never get executed because the function + * it depends will not get passed + * + * @depends testOne + */ + public function testThree($arr) + { + + } +} ?> \ No newline at end of file diff --git a/04DataProvider.php b/04DataProvider.php index 2e728e4..f547877 100644 --- a/04DataProvider.php +++ b/04DataProvider.php @@ -1,46 +1,46 @@ -assertEquals($c, $a + $b); - } - - public function provider() - { - $return1 = array( - array(0, 0, 0), - array(0, 1, 1), - array(1, 0, 1), - array(1, 1, 3) - ); - - $return2 = array( - array(0, 0, 0), - array(0, 1, 1), - array(1, 0, 1), - array(1, 1, 2) - ); - - $return = $return1; - //$return = $return2; - //Uncommenting this line will pass this test - return $return; - } -} +assertEquals($c, $a + $b); + } + + public function provider() + { + $return1 = array( + array(0, 0, 0), + array(0, 1, 1), + array(1, 0, 1), + array(1, 1, 3) + ); + + $return2 = array( + array(0, 0, 0), + array(0, 1, 1), + array(1, 0, 1), + array(1, 1, 2) + ); + + $return = $return1; + //$return = $return2; + //Uncommenting this line will pass this test + return $return; + } +} ?> \ No newline at end of file diff --git a/05CSVDataProvidor.php b/05CSVDataProvidor.php index dcc7b01..1e4d133 100644 --- a/05CSVDataProvidor.php +++ b/05CSVDataProvidor.php @@ -1,42 +1,42 @@ -assertEquals($c, $a + $b); - } - - /** - * This again is a providor function which return an object - * and that object has implemented Iterator interface and - * design pattern and its 'current' attribute return an array - * which has 3 elements to fed into the testAdd function. - * CSV file is located in ./data/ folder - * - * @return \CsvFileIterator - */ - public function provider() - { - return new CsvFileIterator(dirname(__FILE__) . DS . data . DS . 'data.csv'); - } -} +assertEquals($c, $a + $b); + } + + /** + * This again is a providor function which return an object + * and that object has implemented Iterator interface and + * design pattern and its 'current' attribute return an array + * which has 3 elements to fed into the testAdd function. + * CSV file is located in ./data/ folder + * + * @return \CsvFileIterator + */ + public function provider() + { + return new CsvFileIterator(dirname(__FILE__) . DS . "data" . DS . 'data.csv'); + } +} ?> \ No newline at end of file diff --git a/06ExceptionTest.php b/06ExceptionTest.php index 1224918..61a5812 100644 --- a/06ExceptionTest.php +++ b/06ExceptionTest.php @@ -1,26 +1,26 @@ - \ No newline at end of file diff --git a/07ExceptionWithMsgAndCode.php b/07ExceptionWithMsgAndCode.php index 7ecc665..8554f88 100644 --- a/07ExceptionWithMsgAndCode.php +++ b/07ExceptionWithMsgAndCode.php @@ -1,47 +1,47 @@ - \ No newline at end of file diff --git a/08AnotherWayOfExceptionTesting.php b/08AnotherWayOfExceptionTesting.php index f6044bc..a4a9e4f 100644 --- a/08AnotherWayOfExceptionTesting.php +++ b/08AnotherWayOfExceptionTesting.php @@ -1,55 +1,55 @@ -setExpectedException('InvalidArgumentException'); - - #throw new InvalidArgumentException(); - #Uncommenting above line will pass this test. - } - - /** - * This method again now shows how to declare the exception though - * explicit functions but also with a specific message. - */ - public function testExceptionHasRightMessage() { - $this->setExpectedException( - 'InvalidArgumentException', 'Right Message' - ); - - #throw new InvalidArgumentException('Right Message'); - #Uncommenting above line will pass this test. - - throw new InvalidArgumentException('Some Message', 10); - } - - /** - * This method again now shows how to declare the exception though - * explicit functions but also with a specific message and specific - * error code. - */ - - public function testExceptionHasRightCode() { - $this->setExpectedException( - 'InvalidArgumentException', 'Right Message', 20 - ); - - #throw new InvalidArgumentException('Right Message',20); - #Uncommenting above line will pass this test. - - throw new InvalidArgumentException('The Right Message', 10); - } - -} - +setExpectedException('InvalidArgumentException'); + + #throw new InvalidArgumentException(); + #Uncommenting above line will pass this test. + } + + /** + * This method again now shows how to declare the exception though + * explicit functions but also with a specific message. + */ + public function testExceptionHasRightMessage() { + $this->setExpectedException( + 'InvalidArgumentException', 'Right Message' + ); + + #throw new InvalidArgumentException('Right Message'); + #Uncommenting above line will pass this test. + + throw new InvalidArgumentException('Some Message', 10); + } + + /** + * This method again now shows how to declare the exception though + * explicit functions but also with a specific message and specific + * error code. + */ + + public function testExceptionHasRightCode() { + $this->setExpectedException( + 'InvalidArgumentException', 'Right Message', 20 + ); + + #throw new InvalidArgumentException('Right Message',20); + #Uncommenting above line will pass this test. + + throw new InvalidArgumentException('The Right Message', 10); + } + +} + ?> \ No newline at end of file diff --git a/09TestPhpErrors.php b/09TestPhpErrors.php index f8ed081..def979e 100644 --- a/09TestPhpErrors.php +++ b/09TestPhpErrors.php @@ -1,43 +1,43 @@ -bar(); - - # Code execution will never reach this point - $this->assertTrue(true); - } -} - -/** - * Class to create a Php warning - */ -class Foo{ - /** - * This function will create a php warning - */ - public function bar(){ - # This line will give a php warning because $hello - # variable is not integer and its being incremented - $hello++ ; - } -} +bar(); + + # Code execution will never reach this point + $this->assertTrue(true); + } +} + +/** + * Class to create a Php warning + */ +class Foo{ + /** + * This function will create a php warning + */ + public function bar(){ + # This line will give a php warning because $hello + # variable is not integer and its being incremented + $hello++ ; + } +} ?> \ No newline at end of file diff --git a/10OutoutBuffering.php b/10OutoutBuffering.php index 7405f18..8ce8582 100644 --- a/10OutoutBuffering.php +++ b/10OutoutBuffering.php @@ -1,37 +1,43 @@ -expectOutputString('foo'); - - - $echo_str1 = "foo"; - $echo_str2 = "baar"; - - $actual_echo_str = $echo_str2; - #$actual_echo_str = $echo_str1; - #Uncommenting line above will pass this test; - - print $actual_echo_str; - } - } - -/** - * Similar functions which test the output buffer but - * with different functionalities are below - * - * void expectOutputRegex(string $regularExpression) - * Set up the expectation that the output matches a $regularExpression. - * - * bool setOutputCallback(callable $callback) - * Sets up a callback that is used to check further that the output was expected or not - * - */ +expectOutputString('foo'); + + + $echo_str1 = "foo"; + $echo_str2 = "baar"; + + $actual_echo_str = $echo_str2; + #$actual_echo_str = $echo_str1; + #Uncommenting line above will pass this test; + + print $actual_echo_str; + } + + public function testSkipped() + { + $this->markTestSkipped('must be revisited.'); + } + } + + +/** + * Similar functions which test the output buffer but + * with different functionalities are below + * + * void expectOutputRegex(string $regularExpression) + * Set up the expectation that the output matches a $regularExpression. + * + * bool setOutputCallback(callable $callback) + * Sets up a callback that is used to check further that the output was expected or not + * + */ ?> \ No newline at end of file diff --git a/11ArrayHasKey.php b/11ArrayHasKey.php index 40d2fef..9f5cdcc 100644 --- a/11ArrayHasKey.php +++ b/11ArrayHasKey.php @@ -1,22 +1,22 @@ - 'baz'); - - #$test_arr['foo'] = 'foox'; - #Uncommenting line above will pass the test - - $this->assertArrayHasKey('foo', $test_arr); - } -} + 'baz'); + + #$test_arr['foo'] = 'foox'; + #Uncommenting line above will pass the test + + $this->assertArrayHasKey('foo', $test_arr); + } +} ?> \ No newline at end of file diff --git a/12ClassHasAttribute.php b/12ClassHasAttribute.php index bbd16bc..b9fa99e 100644 --- a/12ClassHasAttribute.php +++ b/12ClassHasAttribute.php @@ -1,38 +1,38 @@ -assertClassHasAttribute('foo', 'Bar'); - } -} - -class Bar{ - public $bar; - #private $foo; - #Uncommenting above line will pass the test -} - - +assertClassHasAttribute('foo', 'Bar'); + } +} + +class Bar{ + public $bar; + #private $foo; + #Uncommenting above line will pass the test +} + + ?> \ No newline at end of file diff --git a/13ClassHasStaticAttribute.php b/13ClassHasStaticAttribute.php index d00af2d..61cc848 100644 --- a/13ClassHasStaticAttribute.php +++ b/13ClassHasStaticAttribute.php @@ -1,31 +1,31 @@ -assertClassHasStaticAttribute('foo', 'BarStatic'); - } -} - -class BarStatic{ - public static $bar; - - public static $foo; - #Uncommenting above line will pass this test -} +assertClassHasStaticAttribute('foo', 'BarStatic'); + } +} + +class BarStatic{ + public static $bar; + + public static $foo; + #Uncommenting above line will pass this test +} ?> \ No newline at end of file diff --git a/14Contains.php b/14Contains.php index 8434232..2c86afa 100644 --- a/14Contains.php +++ b/14Contains.php @@ -1,86 +1,86 @@ -assertContains(4, $arr); - } - - /** - * This test will use assertContains() function on a - * string and see how it works - */ - - public function testStringSearch() - { - $str = 'bar'; - - #$str = 'foobar'; - #Uncommenting line above will pass the test - - $this->assertContains('foo',$str); - } - - /** - * This function will test assertAttributeContains for - * objects and public, private and protected variables - */ - public function testContainAttribute(){ - $obj = new ContainClass(); - - $needle = 4; - - #$needle = 3; - #Uncommenting line above will pass the test - - $this->assertAttributeContains($needle, 'arr2' , $obj); - } - - /** - * This function will test assertAttributeContains for - * objects and public, private and protected variables - */ - public function testContainStaticVar(){ - - $needle = 4; - - #$needle = 3; - #Uncommenting line above will pass the test - - $this->assertAttributeContains($needle, 'arr1' , 'ContainClass' ); - } -} - -class ContainClass{ - public static $arr1 = array(1, 2, 3); - public $arr2 = array(1, 2, 3); -} +assertContains(4, $arr); + } + + /** + * This test will use assertContains() function on a + * string and see how it works + */ + + public function testStringSearch() + { + $str = 'bar'; + + #$str = 'foobar'; + #Uncommenting line above will pass the test + + $this->assertContains('foo',$str); + } + + /** + * This function will test assertAttributeContains for + * objects and public, private and protected variables + */ + public function testContainAttribute(){ + $obj = new ContainClass(); + + $needle = 4; + + #$needle = 3; + #Uncommenting line above will pass the test + + $this->assertAttributeContains($needle, 'arr2' , $obj); + } + + /** + * This function will test assertAttributeContains for + * objects and public, private and protected variables + */ + public function testContainStaticVar(){ + + $needle = 4; + + #$needle = 3; + #Uncommenting line above will pass the test + + $this->assertAttributeContains($needle, 'arr1' , 'ContainClass' ); + } +} + +class ContainClass{ + public static $arr1 = array(1, 2, 3); + public $arr2 = array(1, 2, 3); +} ?> \ No newline at end of file diff --git a/15ContainsOnly.php b/15ContainsOnly.php index a448500..5f693c7 100644 --- a/15ContainsOnly.php +++ b/15ContainsOnly.php @@ -1,80 +1,80 @@ -assertContainsOnly('string', $heystack); - } - - /** - * I have no idea how this $is_native_type flag is getting used - * @todo Need to figure out how $isNativeType flag is getting used - */ - public function testContainsOnlyForNativeTypeOnly() - { - $heystack = array(new NotNativeType(), new NotNativeType(), new NotNativeType()); - - $is_native_type = true; - #$is_native_type = false; - #Uncommenting line above should pass this test; - - $this->assertContainsOnly('NotNativeType', $heystack, $is_native_type); - #This test is getting passed anyway with - #any value in $is_native_type variables :( . I dont - #know where I am getting wrong. Will fix it after some - #time. - } - - public function testAssertAttributeContainsOnlyStatic(){ - /** - * This test will pass - */ - $this->assertAttributeContainsOnly('string','arr2', 'NotNativeType'); - } - - public function testAssertAttributeContainsOnly(){ - /** - * This test will pass - */ - $this->assertAttributeContainsOnly('string','arr1', new NotNativeType); - } -} - -/** - * Class to check non native type variables - */ -class NotNativeType{ - public $arr1 = array('1', '2', '3'); - public static $arr2 = array('1', '2', '3'); -} +assertContainsOnly('string', $heystack); + } + + /** + * I have no idea how this $is_native_type flag is getting used + * @todo Need to figure out how $isNativeType flag is getting used + */ + public function testContainsOnlyForNativeTypeOnly() + { + $heystack = array(new NotNativeType(), new NotNativeType(), new NotNativeType()); + + $is_native_type = true; + #$is_native_type = false; + #Uncommenting line above should pass this test; + + $this->assertContainsOnly('NotNativeType', $heystack, $is_native_type); + #This test is getting passed anyway with + #any value in $is_native_type variables :( . I dont + #know where I am getting wrong. Will fix it after some + #time. + } + + public function testAssertAttributeContainsOnlyStatic(){ + /** + * This test will pass + */ + $this->assertAttributeContainsOnly('string','arr2', 'NotNativeType'); + } + + public function testAssertAttributeContainsOnly(){ + /** + * This test will pass + */ + $this->assertAttributeContainsOnly('string','arr1', new NotNativeType); + } +} + +/** + * Class to check non native type variables + */ +class NotNativeType{ + public $arr1 = array('1', '2', '3'); + public static $arr2 = array('1', '2', '3'); +} ?> \ No newline at end of file diff --git a/16ContainsOnlyInstancesOf.php b/16ContainsOnlyInstancesOf.php index f8dd6b7..a346d3c 100644 --- a/16ContainsOnlyInstancesOf.php +++ b/16ContainsOnlyInstancesOf.php @@ -1,31 +1,37 @@ -assertContainsOnlyInstancesOf('Foo', $arr); - } -} - -class Foo{ - -} -class Bar{ - -} +assertContainsOnlyInstancesOf('Foo', $arr); + } +} + +if (!class_exists('Foo', FALSE)) { + class Foo{ + + } +} + +if (!class_exists('Bar', FALSE)) { + class Bar{ + + } +} + ?> \ No newline at end of file diff --git a/17Count.php b/17Count.php index b5261f5..56a06af 100644 --- a/17Count.php +++ b/17Count.php @@ -1,22 +1,22 @@ -assertCount(0, $arr); - } -} +assertCount(0, $arr); + } +} ?> \ No newline at end of file diff --git a/18Empty.php b/18Empty.php index 68f8bf3..e767d80 100644 --- a/18Empty.php +++ b/18Empty.php @@ -1,23 +1,23 @@ -assertEmpty($arr); - } -} +assertEmpty($arr); + } +} ?> \ No newline at end of file diff --git a/19EqualXMLStructure.php b/19EqualXMLStructure.php index 064352d..f03e9d1 100644 --- a/19EqualXMLStructure.php +++ b/19EqualXMLStructure.php @@ -1,84 +1,84 @@ -assertEqualXMLStructure($expected, $actual); - } - - /** - * This function is to test same element but with different - * attributes. Third parameter in the function assertEqualXMLStructure - * is just used to test that. - */ - public function testFailureWithDifferentNodeAttributes() - { - $expected = new DOMDocument; - $expected->loadXML(''); - - $actual = new DOMDocument; - $actual->loadXML(''); - - $this->assertEqualXMLStructure( - $expected->firstChild, $actual->firstChild, TRUE - ); - } - - /** - * This function is to test the same node in the xml - * but with different count of child nodes. - */ - public function testFailureWithDifferentChildrenCount() - { - $expected = new DOMDocument; - $expected->loadXML(''); - - $actual = new DOMDocument; - $actual->loadXML(''); - - $this->assertEqualXMLStructure( - $expected->firstChild, $actual->firstChild - ); - } - - /** - * This function is used to test the same xml node - * but different child nodes - */ - public function testFailureWithDifferentChildren() - { - $expected = new DOMDocument; - $expected->loadXML(''); - - $actual = new DOMDocument; - $actual->loadXML(''); - - $this->assertEqualXMLStructure( - $expected->firstChild, $actual->firstChild - ); - } -} +assertEqualXMLStructure($expected, $actual); + } + + /** + * This function is to test same element but with different + * attributes. Third parameter in the function assertEqualXMLStructure + * is just used to test that. + */ + public function testFailureWithDifferentNodeAttributes() + { + $expected = new DOMDocument; + $expected->loadXML(''); + + $actual = new DOMDocument; + $actual->loadXML(''); + + $this->assertEqualXMLStructure( + $expected->firstChild, $actual->firstChild, TRUE + ); + } + + /** + * This function is to test the same node in the xml + * but with different count of child nodes. + */ + public function testFailureWithDifferentChildrenCount() + { + $expected = new DOMDocument; + $expected->loadXML(''); + + $actual = new DOMDocument; + $actual->loadXML(''); + + $this->assertEqualXMLStructure( + $expected->firstChild, $actual->firstChild + ); + } + + /** + * This function is used to test the same xml node + * but different child nodes + */ + public function testFailureWithDifferentChildren() + { + $expected = new DOMDocument; + $expected->loadXML(''); + + $actual = new DOMDocument; + $actual->loadXML(''); + + $this->assertEqualXMLStructure( + $expected->firstChild, $actual->firstChild + ); + } +} ?> \ No newline at end of file diff --git a/20Equals1.php b/20Equals1.php index 91768b2..9600402 100644 --- a/20Equals1.php +++ b/20Equals1.php @@ -1,43 +1,43 @@ -assertEquals(1, 0); - } - - /** - * Testing strings - */ - public function testString() - { - $this->assertEquals('bar', 'baz'); - } - - public function testStringAnother() - { - $this->assertEquals("foo\nbar\nbaz\n", "foo\nbah\nbaz\n"); - } -} -?> +assertEquals(1, 0); + } + + /** + * Testing strings + */ + public function testString() + { + $this->assertEquals('bar', 'baz'); + } + + public function testStringAnother() + { + $this->assertEquals("foo\nbar\nbaz\n", "foo\nbah\nbaz\n"); + } +} +?> diff --git a/21Equals2.php b/21Equals2.php index c8136cd..2fa6489 100644 --- a/21Equals2.php +++ b/21Equals2.php @@ -1,26 +1,26 @@ -assertEquals(1.0, 1.1, '', 0.2); - } - - public function testFailure() - { - $this->assertEquals(1.0, 1.1); - } -} - +assertEquals(1.0, 1.1, '', 0.2); + } + + public function testFailure() + { + $this->assertEquals(1.0, 1.1); + } +} + ?> \ No newline at end of file diff --git a/22Equals3.php b/22Equals3.php index 713e2c4..2f4d927 100644 --- a/22Equals3.php +++ b/22Equals3.php @@ -1,30 +1,30 @@ -loadXML(''); - - $actual = new DOMDocument; - $actual->loadXML(''); - - $this->assertEquals($expected, $actual); - } -} +loadXML(''); + + $actual = new DOMDocument; + $actual->loadXML(''); + + $this->assertEquals($expected, $actual); + } +} ?> \ No newline at end of file diff --git a/23Equals4.php b/23Equals4.php index b3c5251..23cc822 100644 --- a/23Equals4.php +++ b/23Equals4.php @@ -1,32 +1,32 @@ -foo = 'foo'; - $expected->bar = 'bar'; - - $actual = new stdClass; - $actual->foo = 'bar'; - $actual->baz = 'bar'; - - $this->assertEquals($expected, $actual); - } -} +foo = 'foo'; + $expected->bar = 'bar'; + + $actual = new stdClass; + $actual->foo = 'bar'; + $actual->baz = 'bar'; + + $this->assertEquals($expected, $actual); + } +} ?> \ No newline at end of file diff --git a/24Equals5.php b/24Equals5.php index 25bfc5e..0549043 100644 --- a/24Equals5.php +++ b/24Equals5.php @@ -1,26 +1,26 @@ -assertEquals(array('a', 'b', 'c'), array('a', 'c', 'd')); - } -} +assertEquals(array('a', 'b', 'c'), array('a', 'c', 'd')); + } +} ?> \ No newline at end of file diff --git a/25False.php b/25False.php index 5f7be45..28f6ff0 100644 --- a/25False.php +++ b/25False.php @@ -1,18 +1,18 @@ -assertFalse(false); - } -} +assertFalse(false); + } +} ?> \ No newline at end of file diff --git a/26FileEquals.php b/26FileEquals.php index 0846e38..4f7640c 100644 --- a/26FileEquals.php +++ b/26FileEquals.php @@ -1,37 +1,37 @@ -assertFileEquals(D_DIR . 'file2.txt', D_DIR. 'file2-1.txt'); - } - - /** - * In this function the content of files are same but there are few white - * spaces at the end. This test will fail because white spaces are also - * considered as content of the file. - */ - public function testFailure() - { - $this->assertFileEquals(D_DIR . 'file2.txt', D_DIR. 'file1.txt'); - } -} +assertFileEquals(D_DIR . 'file2.txt', D_DIR. 'file2-1.txt'); + } + + /** + * In this function the content of files are same but there are few white + * spaces at the end. This test will fail because white spaces are also + * considered as content of the file. + */ + public function testFailure() + { + $this->assertFileEquals(D_DIR . 'file2.txt', D_DIR. 'file1.txt'); + } +} ?> \ No newline at end of file diff --git a/27FileExists.php b/27FileExists.php index 385e5f0..1fa759b 100644 --- a/27FileExists.php +++ b/27FileExists.php @@ -1,28 +1,28 @@ -assertFileExists(D_DIR . 'empty.txt'); - } -} +assertFileExists(D_DIR . 'empty.txt'); + } +} ?> \ No newline at end of file diff --git a/28GreaterThan.php b/28GreaterThan.php index 161b10a..86435b3 100644 --- a/28GreaterThan.php +++ b/28GreaterThan.php @@ -1,31 +1,31 @@ -assertGreaterThan(2, 1); - } - - public function testAttributeStatic(){ - $this->assertAttributeGreaterThan(2, 'foo', 'BarGreater'); - } - - public function testAttributeObject(){ - $this->assertAttributeGreaterThan(2, 'foo1', new BarGreater()); - } -} - -class BarGreater{ - public static $foo = 1; - public $foo1 = 1; -} +assertGreaterThan(2, 1); + } + + public function testAttributeStatic(){ + $this->assertAttributeGreaterThan(2, 'foo', 'BarGreater'); + } + + public function testAttributeObject(){ + $this->assertAttributeGreaterThan(2, 'foo1', new BarGreater()); + } +} + +class BarGreater{ + public static $foo = 1; + public $foo1 = 1; +} ?> \ No newline at end of file diff --git a/29GreaterThanOrEqual.php b/29GreaterThanOrEqual.php index 4d0954a..5fd246c 100644 --- a/29GreaterThanOrEqual.php +++ b/29GreaterThanOrEqual.php @@ -1,47 +1,47 @@ -assertGreaterThanOrEqual(2, 2); - } - /** There is some problem with these two functions - * @todo fix it - */ - /* - public function testAttributeStatic() - { - $this->assertGreaterThanOrEqual(2, 'foo', 'BarGreatEqual'); - } - - public function testAttributeObject() - { - $this->assertGreaterThanOrEqual(2, 'foo1', new BarGreatEqual()); - } - */ - -} - -/** - * Helper class - */ -class BarGreatEqual{ - public static $foo = 2; - public $foo1 = 2; -} +assertGreaterThanOrEqual(2, 2); + } + /** There is some problem with these two functions + * @todo fix it + */ + /* + public function testAttributeStatic() + { + $this->assertGreaterThanOrEqual(2, 'foo', 'BarGreatEqual'); + } + + public function testAttributeObject() + { + $this->assertGreaterThanOrEqual(2, 'foo1', new BarGreatEqual()); + } + */ + +} + +/** + * Helper class + */ +class BarGreatEqual{ + public static $foo = 2; + public $foo1 = 2; +} ?> \ No newline at end of file diff --git a/30InstanceOf.php b/30InstanceOf.php index feb3d13..893907d 100644 --- a/30InstanceOf.php +++ b/30InstanceOf.php @@ -1,23 +1,23 @@ -assertInstanceOf('RuntimeException', new Exception); - } -} +assertInstanceOf('RuntimeException', new Exception); + } +} ?> \ No newline at end of file diff --git a/31InternalType.php b/31InternalType.php index 0f057dc..afa0d8e 100644 --- a/31InternalType.php +++ b/31InternalType.php @@ -1,22 +1,22 @@ -assertInternalType('string', 42); - } -} +assertInternalType('string', 42); + } +} ?> \ No newline at end of file diff --git a/32JsonFileEqualsJsonFile.php b/32JsonFileEqualsJsonFile.php index b228acb..02a1f5f 100644 --- a/32JsonFileEqualsJsonFile.php +++ b/32JsonFileEqualsJsonFile.php @@ -1,36 +1,36 @@ -assertJsonFileEqualsJsonFile( - D_DIR . 'file2.json', D_DIR . 'file3.json'); - } - - /** - * Content of file is different (white spaces added at the end). - * But the json is same so it will pass. - */ - public function testSuccess() - { - $this->assertJsonFileEqualsJsonFile( - D_DIR . 'file1.json', D_DIR . 'file2.json'); - } -} +assertJsonFileEqualsJsonFile( + D_DIR . 'file2.json', D_DIR . 'file3.json'); + } + + /** + * Content of file is different (white spaces added at the end). + * But the json is same so it will pass. + */ + public function testSuccess() + { + $this->assertJsonFileEqualsJsonFile( + D_DIR . 'file1.json', D_DIR . 'file2.json'); + } +} ?> \ No newline at end of file diff --git a/33JsonStringEqualsJsonFile.php b/33JsonStringEqualsJsonFile.php index 8d8e68a..1d2f2bc 100644 --- a/33JsonStringEqualsJsonFile.php +++ b/33JsonStringEqualsJsonFile.php @@ -1,40 +1,40 @@ -assertJsonStringEqualsJsonFile( - D_DIR . 'file2.json', "{\"a\":\"b\", \"c\":\"e\"} " - ); - } - - /** - * This will pass irrespective of the fact that content is - * different but json is same (Again there are extra white space) - */ - - public function testSuccess() - { - $this->assertJsonStringEqualsJsonFile( - D_DIR . 'file2.json', "{\"a\":\"b\", \"c\":\"d\"} " - ); - } -} +assertJsonStringEqualsJsonFile( + D_DIR . 'file2.json', "{\"a\":\"b\", \"c\":\"e\"} " + ); + } + + /** + * This will pass irrespective of the fact that content is + * different but json is same (Again there are extra white space) + */ + + public function testSuccess() + { + $this->assertJsonStringEqualsJsonFile( + D_DIR . 'file2.json', "{\"a\":\"b\", \"c\":\"d\"} " + ); + } +} ?> \ No newline at end of file diff --git a/34JsonStringEqualsJsonString.php b/34JsonStringEqualsJsonString.php index 9c55ed9..0e77893 100644 --- a/34JsonStringEqualsJsonString.php +++ b/34JsonStringEqualsJsonString.php @@ -1,25 +1,25 @@ -assertJsonStringEqualsJsonString( - json_encode(array("Mascott" => "Tux")), json_encode(array("Mascott" => "ux")) - ); - } -} +assertJsonStringEqualsJsonString( + json_encode(array("Mascott" => "Tux")), json_encode(array("Mascott" => "ux")) + ); + } +} ?> \ No newline at end of file diff --git a/35LessThan.php b/35LessThan.php index c01b837..f3cb876 100644 --- a/35LessThan.php +++ b/35LessThan.php @@ -1,22 +1,22 @@ -assertLessThan(1, 2); - } -} +assertLessThan(1, 2); + } +} ?> \ No newline at end of file diff --git a/36LessThanOrEqual.php b/36LessThanOrEqual.php index 5f637f0..f2d3c43 100644 --- a/36LessThanOrEqual.php +++ b/36LessThanOrEqual.php @@ -1,23 +1,23 @@ -assertLessThanOrEqual(1, 2); - } -} +assertLessThanOrEqual(1, 2); + } +} ?> \ No newline at end of file diff --git a/37Null.php b/37Null.php index 57e127d..86089c3 100644 --- a/37Null.php +++ b/37Null.php @@ -1,17 +1,17 @@ -assertNull('foo'); - } -} -?> +assertNull('foo'); + } +} +?> diff --git a/38ObjectHasAttribute.php b/38ObjectHasAttribute.php index ac0198c..369f67c 100644 --- a/38ObjectHasAttribute.php +++ b/38ObjectHasAttribute.php @@ -1,22 +1,22 @@ -attributeName does not exist. - * - * assertObjectNotHasAttribute() is the inverse of this assertion and takes the same arguments. - */ -class ObjectHasAttributeTest extends PHPUnit_Framework_TestCase -{ - public function testFailure() - { - $obj = new stdClass(); - //$obj->foo = 'foo'; // Uncommenting this line will pass the test - $this->assertObjectHasAttribute('foo', $obj); - } -} +attributeName does not exist. + * + * assertObjectNotHasAttribute() is the inverse of this assertion and takes the same arguments. + */ +class ObjectHasAttributeTest extends PHPUnit_Framework_TestCase +{ + public function testFailure() + { + $obj = new stdClass(); + //$obj->foo = 'foo'; // Uncommenting this line will pass the test + $this->assertObjectHasAttribute('foo', $obj); + } +} ?> \ No newline at end of file diff --git a/39RegExp.php b/39RegExp.php index e2e503f..2df47ca 100644 --- a/39RegExp.php +++ b/39RegExp.php @@ -1,19 +1,19 @@ -assertRegExp('/foo/', $par); - } -} +assertRegExp('/foo/', $par); + } +} ?> \ No newline at end of file diff --git a/40StringMatchesFormat.php b/40StringMatchesFormat.php index 5df2818..91432c6 100644 --- a/40StringMatchesFormat.php +++ b/40StringMatchesFormat.php @@ -1,51 +1,51 @@ -assertStringMatchesFormat('%i', $par); - } -} - - -/* - The format string may contain the following placeholders: - - %e: Represents a directory separator, for example / on Linux. - - %s: One or more of anything (character or white space) except the end of line character. - - %S: Zero or more of anything (character or white space) except the end of line character. - - %a: One or more of anything (character or white space) including the end of line character. - - %A: Zero or more of anything (character or white space) including the end of line character. - - %w: Zero or more white space characters. - - %i: A signed integer value, for example +3142, -3142. - - %d: An unsigned integer value, for example 123456. - - %x: One or more hexadecimal character. That is, characters in the range 0-9, a-f, A-F. - - %f: A floating point number, for example: 3.142, -3.142, 3.142E-10, 3.142e+10. - - %c: A single character of any sort. - - - */ +assertStringMatchesFormat('%i', $par); + } +} + + +/* + The format string may contain the following placeholders: + + %e: Represents a directory separator, for example / on Linux. + + %s: One or more of anything (character or white space) except the end of line character. + + %S: Zero or more of anything (character or white space) except the end of line character. + + %a: One or more of anything (character or white space) including the end of line character. + + %A: Zero or more of anything (character or white space) including the end of line character. + + %w: Zero or more white space characters. + + %i: A signed integer value, for example +3142, -3142. + + %d: An unsigned integer value, for example 123456. + + %x: One or more hexadecimal character. That is, characters in the range 0-9, a-f, A-F. + + %f: A floating point number, for example: 3.142, -3.142, 3.142E-10, 3.142e+10. + + %c: A single character of any sort. + + + */ ?> \ No newline at end of file diff --git a/41StringMatchesFormatFile.php b/41StringMatchesFormatFile.php index 913850b..d327ff6 100644 --- a/41StringMatchesFormatFile.php +++ b/41StringMatchesFormatFile.php @@ -1,28 +1,28 @@ -assertStringMatchesFormatFile(D_DIR . 'file1.json', 'json'); - } -} +assertStringMatchesFormatFile(D_DIR . 'file1.json', 'json'); + } +} ?> \ No newline at end of file diff --git a/42Same1.php b/42Same1.php index d6c47ad..b9d3349 100644 --- a/42Same1.php +++ b/42Same1.php @@ -1,22 +1,22 @@ -assertSame('2204', 2204); - } -} +assertSame('2204', 2204); + } +} ?> \ No newline at end of file diff --git a/43Same2.php b/43Same2.php index 789c274..5be399b 100644 --- a/43Same2.php +++ b/43Same2.php @@ -1,22 +1,22 @@ -assertSame($obj1, $obj2); - } -} +assertSame($obj1, $obj2); + } +} ?> \ No newline at end of file diff --git a/44SelectCount.php b/44SelectCount.php index a0ae56a..8eb40be 100644 --- a/44SelectCount.php +++ b/44SelectCount.php @@ -1,51 +1,51 @@ -, <=, and >= as keys. - * - */ -class SelectCountTest extends PHPUnit_Framework_TestCase -{ - protected function setUp() - { - $this->xml = new DomDocument; - $this->xml->loadXML(''); - } - - public function testAbsenceFailure() - { - $this->assertSelectCount('foo bar', FALSE, $this->xml); - } - - public function testPresenceFailure() - { - $this->assertSelectCount('foo baz', TRUE, $this->xml); - } - - public function testExactCountFailure() - { - $this->assertSelectCount('foo bar', 5, $this->xml); - } - - public function testRangeFailure() - { - $this->assertSelectCount('foo bar', array('>'=>6, '<'=>8), $this->xml); - } -} +, <=, and >= as keys. + * + */ +class SelectCountTest extends PHPUnit_Framework_TestCase +{ + protected function setUp() + { + $this->xml = new DomDocument; + $this->xml->loadXML(''); + } + + public function testAbsenceFailure() + { + $this->assertSelectCount('foo bar', FALSE, $this->xml); + } + + public function testPresenceFailure() + { + $this->assertSelectCount('foo baz', TRUE, $this->xml); + } + + public function testExactCountFailure() + { + $this->assertSelectCount('foo bar', 5, $this->xml); + } + + public function testRangeFailure() + { + $this->assertSelectCount('foo bar', array('>'=>6, '<'=>8), $this->xml); + } +} ?> \ No newline at end of file diff --git a/45SelectEquals.php b/45SelectEquals.php index 1cda4eb..e076320 100644 --- a/45SelectEquals.php +++ b/45SelectEquals.php @@ -1,50 +1,50 @@ -, <=, and >= as keys. - */ - -class SelectEqualsTest extends PHPUnit_Framework_TestCase -{ - protected function setUp() - { - $this->xml = new DomDocument; - $this->xml->loadXML('BazBaz'); - } - - public function testAbsenceFailure() - { - $this->assertSelectEquals('foo bar', 'Baz', FALSE, $this->xml); - } - - public function testPresenceFailure() - { - $this->assertSelectEquals('foo bar', 'Bat', TRUE, $this->xml); - } - - public function testExactCountFailure() - { - $this->assertSelectEquals('foo bar', 'Baz', 5, $this->xml); - } - - public function testRangeFailure() - { - $this->assertSelectEquals('foo bar', 'Baz', array('>'=>6, '<'=>8), $this->xml); - } -} +, <=, and >= as keys. + */ + +class SelectEqualsTest extends PHPUnit_Framework_TestCase +{ + protected function setUp() + { + $this->xml = new DomDocument; + $this->xml->loadXML('BazBaz'); + } + + public function testAbsenceFailure() + { + $this->assertSelectEquals('foo bar', 'Baz', FALSE, $this->xml); + } + + public function testPresenceFailure() + { + $this->assertSelectEquals('foo bar', 'Bat', TRUE, $this->xml); + } + + public function testExactCountFailure() + { + $this->assertSelectEquals('foo bar', 'Baz', 5, $this->xml); + } + + public function testRangeFailure() + { + $this->assertSelectEquals('foo bar', 'Baz', array('>'=>6, '<'=>8), $this->xml); + } +} ?> \ No newline at end of file diff --git a/46SelectRegExp.php b/46SelectRegExp.php index b03942b..be60c68 100644 --- a/46SelectRegExp.php +++ b/46SelectRegExp.php @@ -1,51 +1,51 @@ -, <=, and >= as keys. - * - */ - -class SelectRegExpTest extends PHPUnit_Framework_TestCase -{ - protected function setUp() - { - $this->xml = new DomDocument; - $this->xml->loadXML('BazBaz'); - } - - public function testAbsenceFailure() - { - $this->assertSelectRegExp('foo bar', '/Ba.*/', FALSE, $this->xml); - } - - public function testPresenceFailure() - { - $this->assertSelectRegExp('foo bar', '/B[oe]z]/', TRUE, $this->xml); - } - - public function testExactCountFailure() - { - $this->assertSelectRegExp('foo bar', '/Ba.*/', 5, $this->xml); - } - - public function testRangeFailure() - { - $this->assertSelectRegExp('foo bar', '/Ba.*/', array('>'=>6, '<'=>8), $this->xml); - } -} +, <=, and >= as keys. + * + */ + +class SelectRegExpTest extends PHPUnit_Framework_TestCase +{ + protected function setUp() + { + $this->xml = new DomDocument; + $this->xml->loadXML('BazBaz'); + } + + public function testAbsenceFailure() + { + $this->assertSelectRegExp('foo bar', '/Ba.*/', FALSE, $this->xml); + } + + public function testPresenceFailure() + { + $this->assertSelectRegExp('foo bar', '/B[oe]z]/', TRUE, $this->xml); + } + + public function testExactCountFailure() + { + $this->assertSelectRegExp('foo bar', '/Ba.*/', 5, $this->xml); + } + + public function testRangeFailure() + { + $this->assertSelectRegExp('foo bar', '/Ba.*/', array('>'=>6, '<'=>8), $this->xml); + } +} ?> \ No newline at end of file diff --git a/47StringEndsWith.php b/47StringEndsWith.php index 0846baf..fcffc9c 100644 --- a/47StringEndsWith.php +++ b/47StringEndsWith.php @@ -1,19 +1,19 @@ -assertStringEndsWith('suffix', $par); - } -} +assertStringEndsWith('suffix', $par); + } +} ?> \ No newline at end of file diff --git a/48StringEqualsFile.php b/48StringEqualsFile.php index 34a2927..c3d0edc 100644 --- a/48StringEqualsFile.php +++ b/48StringEqualsFile.php @@ -1,24 +1,24 @@ -assertStringEqualsFile(D_DIR . 'file1.txt', 'actual'); - } -} +assertStringEqualsFile(D_DIR . 'file1.txt', 'actual'); + } +} ?> \ No newline at end of file diff --git a/49StringStartsWith.php b/49StringStartsWith.php index 6775e1c..6a89586 100644 --- a/49StringStartsWith.php +++ b/49StringStartsWith.php @@ -1,21 +1,21 @@ -assertStringStartsWith('prefix', 'foo'); - } -} +assertStringStartsWith('prefix', 'foo'); + } +} ?> \ No newline at end of file diff --git a/50Tag.php b/50Tag.php index 6dba976..f186b33 100644 --- a/50Tag.php +++ b/50Tag.php @@ -1,120 +1,120 @@ - 'my_id'); - - // Matcher that asserts that there is a "span" tag. - $matcher = array('tag' => 'span'); - - // Matcher that asserts that there is a "span" tag with the content - // "Hello World". - $matcher = array('tag' => 'span', 'content' => 'Hello World'); - - // Matcher that asserts that there is a "span" tag with content matching the - // regular expression pattern. - $matcher = array('tag' => 'span', 'content' => 'regexp:/Try P(HP|ython)/'); - - // Matcher that asserts that there is a "span" with an "list" class attribute. - $matcher = array( - 'tag' => 'span', - 'attributes' => array('class' => 'list') - ); - - // Matcher that asserts that there is a "span" inside of a "div". - $matcher = array( - 'tag' => 'span', - 'parent' => array('tag' => 'div') - ); - - // Matcher that asserts that there is a "span" somewhere inside a "table". - $matcher = array( - 'tag' => 'span', - 'ancestor' => array('tag' => 'table') - ); - - // Matcher that asserts that there is a "span" with at least one "em" child. - $matcher = array( - 'tag' => 'span', - 'child' => array('tag' => 'em') - ); - - // Matcher that asserts that there is a "span" containing a (possibly nested) - // "strong" tag. - $matcher = array( - 'tag' => 'span', - 'descendant' => array('tag' => 'strong') - ); - - // Matcher that asserts that there is a "span" containing 5-10 "em" tags as - // immediate children. - $matcher = array( - 'tag' => 'span', - 'children' => array( - 'less_than' => 11, - 'greater_than' => 4, - 'only' => array('tag' => 'em') - ) - ); - - // Matcher that asserts that there is a "div", with an "ul" ancestor and a "li" - // parent (with class="enum"), and containing a "span" descendant that contains - // an element with id="my_test" and the text "Hello World". - $matcher = array( - 'tag' => 'div', - 'ancestor' => array('tag' => 'ul'), - 'parent' => array( - 'tag' => 'li', - 'attributes' => array('class' => 'enum') - ), - 'descendant' => array( - 'tag' => 'span', - 'child' => array( - 'id' => 'my_test', - 'content' => 'Hello World' - ) - ) - ); - - // Use assertTag() to apply a $matcher to a piece of $html. - $this->assertTag($matcher, $html); - - // Use assertTag() to apply a $matcher to a piece of $xml. - $this->assertTag($matcher, $xml, '', FALSE); - } -} - -?> + 'my_id'); + + // Matcher that asserts that there is a "span" tag. + $matcher = array('tag' => 'span'); + + // Matcher that asserts that there is a "span" tag with the content + // "Hello World". + $matcher = array('tag' => 'span', 'content' => 'Hello World'); + + // Matcher that asserts that there is a "span" tag with content matching the + // regular expression pattern. + $matcher = array('tag' => 'span', 'content' => 'regexp:/Try P(HP|ython)/'); + + // Matcher that asserts that there is a "span" with an "list" class attribute. + $matcher = array( + 'tag' => 'span', + 'attributes' => array('class' => 'list') + ); + + // Matcher that asserts that there is a "span" inside of a "div". + $matcher = array( + 'tag' => 'span', + 'parent' => array('tag' => 'div') + ); + + // Matcher that asserts that there is a "span" somewhere inside a "table". + $matcher = array( + 'tag' => 'span', + 'ancestor' => array('tag' => 'table') + ); + + // Matcher that asserts that there is a "span" with at least one "em" child. + $matcher = array( + 'tag' => 'span', + 'child' => array('tag' => 'em') + ); + + // Matcher that asserts that there is a "span" containing a (possibly nested) + // "strong" tag. + $matcher = array( + 'tag' => 'span', + 'descendant' => array('tag' => 'strong') + ); + + // Matcher that asserts that there is a "span" containing 5-10 "em" tags as + // immediate children. + $matcher = array( + 'tag' => 'span', + 'children' => array( + 'less_than' => 11, + 'greater_than' => 4, + 'only' => array('tag' => 'em') + ) + ); + + // Matcher that asserts that there is a "div", with an "ul" ancestor and a "li" + // parent (with class="enum"), and containing a "span" descendant that contains + // an element with id="my_test" and the text "Hello World". + $matcher = array( + 'tag' => 'div', + 'ancestor' => array('tag' => 'ul'), + 'parent' => array( + 'tag' => 'li', + 'attributes' => array('class' => 'enum') + ), + 'descendant' => array( + 'tag' => 'span', + 'child' => array( + 'id' => 'my_test', + 'content' => 'Hello World' + ) + ) + ); + + // Use assertTag() to apply a $matcher to a piece of $html. + $this->assertTag($matcher, $html); + + // Use assertTag() to apply a $matcher to a piece of $xml. + $this->assertTag($matcher, $xml, '', FALSE); + } +} + +?> diff --git a/51That.php b/51That.php index 50e62a5..3575ce6 100644 --- a/51That.php +++ b/51That.php @@ -1,153 +1,153 @@ - Meaning - * ---------------------- - * - * PHPUnit_Framework_Constraint_Attribute attribute( - * PHPUnit_Framework_Constraint $constraint, - * $attributeName - * ) - * ==> Constraint that applies another constraint to an attribute of a class or an object. - * - * PHPUnit_Framework_Constraint_IsAnything anything() - * ==> Constraint that accepts any input value. - * - * PHPUnit_Framework_Constraint_ArrayHasKey arrayHasKey(mixed $key) - * ==> Constraint that asserts that the array it is evaluated for has a given key. - * - * PHPUnit_Framework_Constraint_TraversableContains contains(mixed $value) - * ==> Constraint that asserts that the array or object that implements the - * Iterator interface it is evaluated for contains a given value. - * - * PHPUnit_Framework_Constraint_TraversableContainsOnly containsOnly(string $type) - * ==> Constraint that asserts that the array or object that implements the - * Iterator interface it is evaluated for contains only values of a given type. - * - * PHPUnit_Framework_Constraint_TraversableContainsOnly containsOnlyInstancesOf(string $classname) - * ==> Constraint that asserts that the array or object that implements the - * Iterator interface it is evaluated for contains only instances of a given classname. - * - * PHPUnit_Framework_Constraint_IsEqual equalTo($value, $delta = 0, $maxDepth = 10) - * ==> Constraint that checks if one value is equal to another. - * - * PHPUnit_Framework_Constraint_Attribute attributeEqualTo( - * $attributeName, - * $value, - * $delta = 0, - * $maxDepth = 10 - * ) - * ==> Constraint that checks if a value is equal to an - * attribute of a class or of an object. - * - * PHPUnit_Framework_Constraint_FileExists fileExists() - * ==> Constraint that checks if the file(name) that it is evaluated for exists. - * - * PHPUnit_Framework_Constraint_GreaterThan greaterThan(mixed $value) - * ==> Constraint that asserts that the value it is - * evaluated for is greater than a given value. - * - * PHPUnit_Framework_Constraint_Or greaterThanOrEqual(mixed $value) - * ==> Constraint that asserts that the value it is evaluated - * for is greater than or equal to a given value. - * - * PHPUnit_Framework_Constraint_ClassHasAttribute classHasAttribute(string $attributeName) - * ==> Constraint that asserts that the class it is evaluated for has a given attribute. - * - * PHPUnit_Framework_Constraint_ClassHasStaticAttribute classHasStaticAttribute( - * string $attributeName - * ) - * ==> Constraint that asserts that the class it is - * evaluated for has a given static attribute. - * - * PHPUnit_Framework_Constraint_ObjectHasAttribute hasAttribute(string $attributeName) - * ==> Constraint that asserts that the object it is evaluated for has a given attribute. - * - * PHPUnit_Framework_Constraint_IsIdentical identicalTo(mixed $value) - * ==> Constraint that asserts that one value is identical to another. - * - * PHPUnit_Framework_Constraint_IsFalse isFalse() - * ==> Constraint that asserts that the value it is evaluated is FALSE. - * - * PHPUnit_Framework_Constraint_IsInstanceOf isInstanceOf(string $className) - * ==> Constraint that asserts that the object it is evaluated for is an - * instance of a given class. - * - * PHPUnit_Framework_Constraint_IsNull isNull() - * ==> Constraint that asserts that the value it is evaluated is NULL. - * - * PHPUnit_Framework_Constraint_IsTrue isTrue() - * ==> Constraint that asserts that the value it is evaluated is TRUE. - * - * PHPUnit_Framework_Constraint_IsType isType(string $type) - * ==> Constraint that asserts that the value it is - * evaluated for is of a specified type. - * - * PHPUnit_Framework_Constraint_LessThan lessThan(mixed $value) - * ==> Constraint that asserts that the value it is - * evaluated for is smaller than a given value. - * - * PHPUnit_Framework_Constraint_Or lessThanOrEqual(mixed $value) - * ==> Constraint that asserts that the value it is evaluated - * for is smaller than or equal to a given value. - * - * logicalAnd() ==> Logical AND. - * - * logicalNot(PHPUnit_Framework_Constraint $constraint) ==> Logical NOT. - * - * logicalOr() ==> Logical OR. - * - * logicalXor() ==> Logical XOR. - * - * PHPUnit_Framework_Constraint_PCREMatch matchesRegularExpression(string $pattern) - * ==> Constraint that asserts that the string it is - * evaluated for matches a regular expression. - * - * PHPUnit_Framework_Constraint_StringContains stringContains( - * string $string, - * bool $case - * ) - * ==> Constraint that asserts that the string it is - * evaluated for contains a given string. - * - * PHPUnit_Framework_Constraint_StringEndsWith stringEndsWith(string $suffix) - * ==> Constraint that asserts that the string it - * is evaluated for ends with a given suffix. - * - * PHPUnit_Framework_Constraint_StringStartsWith stringStartsWith(string $prefix) - * ==> Constraint that asserts that the string it - * is evaluated for starts with a given prefix. - * - */ - -class BiscuitTest extends PHPUnit_Framework_TestCase -{ - public function testEquals() - { - $theBiscuit = new Biscuit('Ginger'); - $myBiscuit = new Biscuit('Ginger'); - - $this->assertThat( - $theBiscuit, - $this->logicalNot( - $this->equalTo($myBiscuit) - ) - ); - } -} -class Biscuit{ - public $type; - public function __construct($type) { - $this->type = $type; - } -} + Meaning + * ---------------------- + * + * PHPUnit_Framework_Constraint_Attribute attribute( + * PHPUnit_Framework_Constraint $constraint, + * $attributeName + * ) + * ==> Constraint that applies another constraint to an attribute of a class or an object. + * + * PHPUnit_Framework_Constraint_IsAnything anything() + * ==> Constraint that accepts any input value. + * + * PHPUnit_Framework_Constraint_ArrayHasKey arrayHasKey(mixed $key) + * ==> Constraint that asserts that the array it is evaluated for has a given key. + * + * PHPUnit_Framework_Constraint_TraversableContains contains(mixed $value) + * ==> Constraint that asserts that the array or object that implements the + * Iterator interface it is evaluated for contains a given value. + * + * PHPUnit_Framework_Constraint_TraversableContainsOnly containsOnly(string $type) + * ==> Constraint that asserts that the array or object that implements the + * Iterator interface it is evaluated for contains only values of a given type. + * + * PHPUnit_Framework_Constraint_TraversableContainsOnly containsOnlyInstancesOf(string $classname) + * ==> Constraint that asserts that the array or object that implements the + * Iterator interface it is evaluated for contains only instances of a given classname. + * + * PHPUnit_Framework_Constraint_IsEqual equalTo($value, $delta = 0, $maxDepth = 10) + * ==> Constraint that checks if one value is equal to another. + * + * PHPUnit_Framework_Constraint_Attribute attributeEqualTo( + * $attributeName, + * $value, + * $delta = 0, + * $maxDepth = 10 + * ) + * ==> Constraint that checks if a value is equal to an + * attribute of a class or of an object. + * + * PHPUnit_Framework_Constraint_FileExists fileExists() + * ==> Constraint that checks if the file(name) that it is evaluated for exists. + * + * PHPUnit_Framework_Constraint_GreaterThan greaterThan(mixed $value) + * ==> Constraint that asserts that the value it is + * evaluated for is greater than a given value. + * + * PHPUnit_Framework_Constraint_Or greaterThanOrEqual(mixed $value) + * ==> Constraint that asserts that the value it is evaluated + * for is greater than or equal to a given value. + * + * PHPUnit_Framework_Constraint_ClassHasAttribute classHasAttribute(string $attributeName) + * ==> Constraint that asserts that the class it is evaluated for has a given attribute. + * + * PHPUnit_Framework_Constraint_ClassHasStaticAttribute classHasStaticAttribute( + * string $attributeName + * ) + * ==> Constraint that asserts that the class it is + * evaluated for has a given static attribute. + * + * PHPUnit_Framework_Constraint_ObjectHasAttribute hasAttribute(string $attributeName) + * ==> Constraint that asserts that the object it is evaluated for has a given attribute. + * + * PHPUnit_Framework_Constraint_IsIdentical identicalTo(mixed $value) + * ==> Constraint that asserts that one value is identical to another. + * + * PHPUnit_Framework_Constraint_IsFalse isFalse() + * ==> Constraint that asserts that the value it is evaluated is FALSE. + * + * PHPUnit_Framework_Constraint_IsInstanceOf isInstanceOf(string $className) + * ==> Constraint that asserts that the object it is evaluated for is an + * instance of a given class. + * + * PHPUnit_Framework_Constraint_IsNull isNull() + * ==> Constraint that asserts that the value it is evaluated is NULL. + * + * PHPUnit_Framework_Constraint_IsTrue isTrue() + * ==> Constraint that asserts that the value it is evaluated is TRUE. + * + * PHPUnit_Framework_Constraint_IsType isType(string $type) + * ==> Constraint that asserts that the value it is + * evaluated for is of a specified type. + * + * PHPUnit_Framework_Constraint_LessThan lessThan(mixed $value) + * ==> Constraint that asserts that the value it is + * evaluated for is smaller than a given value. + * + * PHPUnit_Framework_Constraint_Or lessThanOrEqual(mixed $value) + * ==> Constraint that asserts that the value it is evaluated + * for is smaller than or equal to a given value. + * + * logicalAnd() ==> Logical AND. + * + * logicalNot(PHPUnit_Framework_Constraint $constraint) ==> Logical NOT. + * + * logicalOr() ==> Logical OR. + * + * logicalXor() ==> Logical XOR. + * + * PHPUnit_Framework_Constraint_PCREMatch matchesRegularExpression(string $pattern) + * ==> Constraint that asserts that the string it is + * evaluated for matches a regular expression. + * + * PHPUnit_Framework_Constraint_StringContains stringContains( + * string $string, + * bool $case + * ) + * ==> Constraint that asserts that the string it is + * evaluated for contains a given string. + * + * PHPUnit_Framework_Constraint_StringEndsWith stringEndsWith(string $suffix) + * ==> Constraint that asserts that the string it + * is evaluated for ends with a given suffix. + * + * PHPUnit_Framework_Constraint_StringStartsWith stringStartsWith(string $prefix) + * ==> Constraint that asserts that the string it + * is evaluated for starts with a given prefix. + * + */ + +class BiscuitTest extends PHPUnit_Framework_TestCase +{ + public function testEquals() + { + $theBiscuit = new Biscuit('Ginger'); + $myBiscuit = new Biscuit('Ginger'); + + $this->assertThat( + $theBiscuit, + $this->logicalNot( + $this->equalTo($myBiscuit) + ) + ); + } +} +class Biscuit{ + public $type; + public function __construct($type) { + $this->type = $type; + } +} ?> \ No newline at end of file diff --git a/52True.php b/52True.php index 6abaa2e..d5b51e5 100644 --- a/52True.php +++ b/52True.php @@ -1,13 +1,13 @@ -assertTrue(FALSE); - } -} +assertTrue(FALSE); + } +} ?> \ No newline at end of file diff --git a/53XmlFileEqualsXmlFile.php b/53XmlFileEqualsXmlFile.php index b4a509d..2eaa7f7 100644 --- a/53XmlFileEqualsXmlFile.php +++ b/53XmlFileEqualsXmlFile.php @@ -1,24 +1,24 @@ -assertXmlFileEqualsXmlFile( - D_DIR . 'file1.xml', D_DIR . 'file2.xml'); - } -} +assertXmlFileEqualsXmlFile( + D_DIR . 'file1.xml', D_DIR . 'file2.xml'); + } +} ?> \ No newline at end of file diff --git a/54XmlStringEqualsXmlFile.php b/54XmlStringEqualsXmlFile.php index 9cc211b..78c2210 100644 --- a/54XmlStringEqualsXmlFile.php +++ b/54XmlStringEqualsXmlFile.php @@ -1,25 +1,25 @@ -assertXmlStringEqualsXmlFile( - D_DIR . 'file1.xml', ''); - } -} +assertXmlStringEqualsXmlFile( + D_DIR . 'file1.xml', ''); + } +} ?> \ No newline at end of file diff --git a/55XmlStringEqualsXmlString.php b/55XmlStringEqualsXmlString.php index ce274c6..4a33a4a 100644 --- a/55XmlStringEqualsXmlString.php +++ b/55XmlStringEqualsXmlString.php @@ -1,24 +1,24 @@ -assertXmlStringEqualsXmlString( - '', ''); - } -} +assertXmlStringEqualsXmlString( + '', ''); + } +} ?> \ No newline at end of file diff --git a/56TemplateMethod.php b/56TemplateMethod.php index 0aeb6d1..3c7fc8c 100644 --- a/56TemplateMethod.php +++ b/56TemplateMethod.php @@ -1,85 +1,85 @@ -assertTrue(TRUE); - $this->assertTrue(TRUE); - } - - public function testTwo() - { - fwrite(STDOUT, __METHOD__ . "\n"); - $this->assertTrue(FALSE); - } - - public function testThree() - { - fwrite(STDOUT, __METHOD__ . "\n"); - $this->assertTrue(TRUE); - } - - protected function assertPostConditions() - { - fwrite(STDOUT, __METHOD__ . "\n"); - } - - protected function tearDown() - { - fwrite(STDOUT, __METHOD__ . "\n"); - } - - public static function tearDownAfterClass() - { - fwrite(STDOUT, __METHOD__ . "\n"); - } - - protected function onNotSuccessfulTest(Exception $e) - { - fwrite(STDOUT, __METHOD__ . "\n"); - throw $e; - } -} +assertTrue(TRUE); + $this->assertTrue(TRUE); + } + + public function testTwo() + { + fwrite(STDOUT, __METHOD__ . "\n"); + $this->assertTrue(FALSE); + } + + public function testThree() + { + fwrite(STDOUT, __METHOD__ . "\n"); + $this->assertTrue(TRUE); + } + + protected function assertPostConditions() + { + fwrite(STDOUT, __METHOD__ . "\n"); + } + + protected function tearDown() + { + fwrite(STDOUT, __METHOD__ . "\n"); + } + + public static function tearDownAfterClass() + { + fwrite(STDOUT, __METHOD__ . "\n"); + } + + protected function onNotSuccessfulTest(Exception $e) + { + fwrite(STDOUT, __METHOD__ . "\n"); + throw $e; + } +} ?> \ No newline at end of file diff --git a/57DBTest.php b/57DBTest.php index c299dfa..1fb9ebe 100644 --- a/57DBTest.php +++ b/57DBTest.php @@ -1,201 +1,204 @@ -conn == null) { - if (self::$pdo == null) { - self::$pdo = new PDO("mysql:host=localhost;dbname=test_pdo", 'root', "password"); - } - $this->conn = $this->createDefaultDBConnection(self::$pdo, 'test_pdo'); - } - return $this->conn; - } - - public function getDataSet() { - /** - * You can choose any one of the below datasets - */ - #return $this->getFlatXmlDataset(); - #return $this->getStandardXmlDataset(); - #return $this->getMysqlXmlDataset(); - #return $this->getYmlDataset(); - #return $this->getCsvDataSet(); - return $this->getArrayDataset(); - #return $this->getQueryDataset(); - #return $this->getDbDataSet(); - #return $this->getReplacementDataset(); - #return $this->getFilterDataset(); - #return $this->getCompositeDataset(); - } - - private function getFlatXmlDataset() { - return $this->createFlatXmlDataSet(D_DIR . "myFlatXmlFixture.xml"); - } - - private function getStandardXmlDataset() { - return $this->createXMLDataSet(D_DIR . "myXmlDataset.xml"); - } - - private function getMysqlXmlDataset() { - return $this->createMySQLXMLDataSet(D_DIR . "mySqldumpXmlDataset.xml"); - } - - private function getYmlDataset() { - return new PHPUnit_Extensions_Database_DataSet_YamlDataSet(D_DIR . 'myDataSet.yml'); - } - - private function getCsvDataSet() { - $dataSet = new PHPUnit_Extensions_Database_DataSet_CsvDataSet(); - - $dataSet->addTable("class", D_DIR . 'class.csv'); - $dataSet->addTable("user", D_DIR . 'user.csv'); - $dataSet->addTable("address", D_DIR . 'address.csv'); - - return $dataSet; - } - - private function getArrayDataset() { - - require_once L_DIR . 'ArrayDataset.php'; - - return new MyApp_DbUnit_ArrayDataSet(array( - 'user' => array( - array('id' => 1, 'name' => 'one'), - array('id' => 2, 'name' => 'two') - ), - 'class' => array( - array('id' => 1, 'uid' => 1, 'class' => 1, 'age' => 5), - array('id' => 2, 'uid' => 2, 'class' => 6, 'age' => 13), - ), - 'address' => array() - )); - } - - private function getQueryDataset() { - $ds = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection()); - $ds->addTable('user'); - $ds->addTable('address'); - $ds->addTable('class'); - # It could be also - # $ds->addTable('class',"Select * from class"); #This function get used further - return $ds; - } - - private function getDbDataSet(){ - $tableNames = array('user','class'); - // We can also import data from another database by this way. - return $dataSet = $this->getConnection()->createDataSet($tableNames); - } - - - - private function getReplacementDataset(){ - /* - * This dataset is used to replace some data in a current dataset, one - * of the powerfull usecase of this dataset is to implement null in flat - * XML dataset. Below is the example code. - * - $ds = $this->createFlatXmlDataSet('myFlatXmlFixture.xml'); - $rds = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($ds); - $rds->addFullReplacement('##NULL##', null); - return $rds; - */ - - # But lets replace some name here only - $arr_ds = $this->getArrayDataset(); - $rds = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($arr_ds); - $rds->addFullReplacement('two', 'two kumar'); - return $rds; - } - - private function getFilterDataset(){ - - #Example showing include block - /* - // Filtered Include dataset - $dataSet = $this->getArrayDataset(); - - $filterDataSet = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($dataSet); - $filterDataSet->addIncludeTables(array('user')); - $filterDataSet->setIncludeColumnsForTable('user', array('id')); - return $filterDataSet; - #*/ - - #Example showing exclude block - #/* - // Filtered Exclude dataset - $dataSet = $this->getArrayDataset(); - - $filterDataSet = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($dataSet); - $filterDataSet->addExcludeTables(array('user', 'address')); // only keep the guestbook table! - $filterDataSet->setExcludeColumnsForTable('class', array('uid')); - return $filterDataSet; - #*/ - } - - private function getCompositeDataset(){ - $ds1 = $this->getFilterDataset(); - $ds2 = $this->createFlatXmlDataSet(D_DIR . "myFlatXml1.xml"); - - #Combine them - /** - * It seems there is some change in the API lately - * now the contructor PHPUnit_Extensions_Database_DataSet_CompositeDataSet - * takes a array as input. - * and you cannot combine two datasets having common tables. - * This is not fair :-/ - */ - $compositeDs = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet(array()); - $compositeDs->addDataSet($ds1); - $compositeDs->addDataSet($ds2); - - return $compositeDs; - } - - public function testUserRowCount() { - $this->assertEquals(2,$this->getConnection()->getRowCount('user'),"User count not matching"); - } - - public function testUserEntry(){ - // This is coming right from the live databases - $queryTable = $this->getConnection()->createQueryTable('user', "Select * from user"); - // Create a data set from the files/array to compare - $expectedTable = $this->getArrayDataset()->getTable('user'); - - //Earth is going to shake now - $this->assertTablesEqual($expectedTable,$queryTable); - //And it worked.. - } - - public function testWithDatasetOnly(){ - // Create a dataset from live table through sql dataset - // This is also a kind of live data only - - $ds1 = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection()); - $ds1->addTable('user'); - - $ds2 = $this->getArrayDataset(); - $filterDataSet = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($ds2); - $filterDataSet->addIncludeTables(array('user')); - - $this->assertDataSetsEqual($ds1,$filterDataSet); - - } - -} - -?> +conn == null) { + if (self::$pdo == null) { + self::$pdo = new PDO("mysql:host=localhost;dbname=test_pdo", 'user', "pass"); + } + $this->conn = $this->createDefaultDBConnection(self::$pdo, 'test_pdo'); + } + return $this->conn; + } + + public function getDataSet() { + /** + * You can choose any one of the below datasets + */ + #return $this->getFlatXmlDataset(); + #return $this->getStandardXmlDataset(); + #return $this->getMysqlXmlDataset(); + #return $this->getYmlDataset(); + #return $this->getCsvDataSet(); + return $this->getArrayDataset(); + #return $this->getQueryDataset(); + #return $this->getDbDataSet(); + #return $this->getReplacementDataset(); + #return $this->getFilterDataset(); + #return $this->getCompositeDataset(); + } + + private function getFlatXmlDataset() { + return $this->createFlatXmlDataSet(D_DIR . "myFlatXmlFixture.xml"); + } + + private function getStandardXmlDataset() { + return $this->createXMLDataSet(D_DIR . "myXmlDataset.xml"); + } + + private function getMysqlXmlDataset() { + return $this->createMySQLXMLDataSet(D_DIR . "mySqldumpXmlDataset.xml"); + } + + private function getYmlDataset() { + return new PHPUnit_Extensions_Database_DataSet_YamlDataSet(D_DIR . 'myDataSet.yml'); + } + + private function getCsvDataSet() { + $dataSet = new PHPUnit_Extensions_Database_DataSet_CsvDataSet(); + + $dataSet->addTable("class", D_DIR . 'class.csv'); + $dataSet->addTable("user", D_DIR . 'user.csv'); + $dataSet->addTable("address", D_DIR . 'address.csv'); + + return $dataSet; + } + + private function getArrayDataset() { + + require_once L_DIR . 'ArrayDataset.php'; + + return new MyApp_DbUnit_ArrayDataSet(array( + 'user' => array( + array('id' => 1, 'name' => 'one'), + array('id' => 2, 'name' => 'two') + ), + 'class' => array( + array('id' => 1, 'uid' => 1, 'class' => 1, 'age' => 5), + array('id' => 2, 'uid' => 2, 'class' => 6, 'age' => 13), + ), + 'address' => array() + )); + } + + private function getQueryDataset() { + $ds = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection()); + $ds->addTable('user'); + $ds->addTable('address'); + $ds->addTable('class'); + # It could be also + # $ds->addTable('class',"Select * from class"); #This function get used further + return $ds; + } + + private function getDbDataSet(){ + $tableNames = array('user','class'); + // We can also import data from another database by this way. + return $dataSet = $this->getConnection()->createDataSet($tableNames); + } + + + + private function getReplacementDataset(){ + /* + * This dataset is used to replace some data in a current dataset, one + * of the powerfull usecase of this dataset is to implement null in flat + * XML dataset. Below is the example code. + * + $ds = $this->createFlatXmlDataSet('myFlatXmlFixture.xml'); + $rds = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($ds); + $rds->addFullReplacement('##NULL##', null); + return $rds; + */ + + # But lets replace some name here only + $arr_ds = $this->getArrayDataset(); + $rds = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($arr_ds); + $rds->addFullReplacement('two', 'two kumar'); + return $rds; + } + + private function getFilterDataset(){ + + #Example showing include block + /* + // Filtered Include dataset + $dataSet = $this->getArrayDataset(); + + $filterDataSet = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($dataSet); + $filterDataSet->addIncludeTables(array('user')); + $filterDataSet->setIncludeColumnsForTable('user', array('id')); + return $filterDataSet; + #*/ + + #Example showing exclude block + #/* + // Filtered Exclude dataset + $dataSet = $this->getArrayDataset(); + + $filterDataSet = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($dataSet); + $filterDataSet->addExcludeTables(array('user', 'address')); // only keep the guestbook table! + $filterDataSet->setExcludeColumnsForTable('class', array('uid')); + return $filterDataSet; + #*/ + } + + private function getCompositeDataset(){ + $ds1 = $this->getFilterDataset(); + $ds2 = $this->createFlatXmlDataSet(D_DIR . "myFlatXml1.xml"); + + #Combine them + /** + * It seems there is some change in the API lately + * now the contructor PHPUnit_Extensions_Database_DataSet_CompositeDataSet + * takes a array as input. + * and you cannot combine two datasets having common tables. + * This is not fair :-/ + */ + $compositeDs = new PHPUnit_Extensions_Database_DataSet_CompositeDataSet(array()); + $compositeDs->addDataSet($ds1); + $compositeDs->addDataSet($ds2); + + return $compositeDs; + } + + public function testUserRowCount() { + $this->assertEquals(2,$this->getConnection()->getRowCount('user'),"User count not matching"); + } + + public function testUserEntry(){ + // This is coming right from the live databases + $queryTable = $this->getConnection()->createQueryTable('user', "Select * from user"); + // Create a data set from the files/array to compare + $expectedTable = $this->getArrayDataset()->getTable('user'); + + //Earth is going to shake now + $this->assertTablesEqual($expectedTable,$queryTable); + //And it worked.. + } + + public function testWithDatasetOnly(){ + // Create a dataset from live table through sql dataset + // This is also a kind of live data only + + $ds1 = new PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection()); + $ds1->addTable('user'); + + $ds2 = $this->getArrayDataset(); + $filterDataSet = new PHPUnit_Extensions_Database_DataSet_DataSetFilter($ds2); + $filterDataSet->addIncludeTables(array('user')); + + $this->assertDataSetsEqual($ds1,$filterDataSet); + + } + +} + +?> diff --git a/LICENSE b/LICENSE index 77a94d0..60fc4d3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +1,674 @@ -GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/} - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - {one line to give the program's name and a brief idea of what it does.} - Copyright (C) {year} {name of author} - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see {http://www.gnu.org/licenses/}. - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - phpunit-examples Copyright (C) 2013 The Crucible - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -{http://www.gnu.org/licenses/}. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -{http://www.gnu.org/philosophy/why-not-lgpl.html}. +GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/} + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see {http://www.gnu.org/licenses/}. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + phpunit-examples Copyright (C) 2013 The Crucible + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +{http://www.gnu.org/licenses/}. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +{http://www.gnu.org/philosophy/why-not-lgpl.html}. diff --git a/README.md b/README.md index 23adf01..c3bd847 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,19 @@ -phpunit-examples -================ - -Hi guys, I have scraped all(not all till now, but going to be :) ) the examples from the Phpunit documentation website -(http://phpunit.de/manual/3.8/en/index.html) and put it into a executable php tests. The idea is that you learn fast -when you see something working. I will keep on improving this. Have fun - -Instructions to use it ----------------------- - -1. cd to project folder -2. Give executable permission to phpunit eg $ chmod aug+x ./bin/phpunit -3. Run the test by $ ./bin/phpunit --color -4. For example $ ./bin/phpunit --color 01StackTest.php - -Also do fork the project and improve it in any way you want. - -If you see any mistake please file the issue here https://github.com/the-crucible/phpunit-examples/issues +phpunit-examples +================ + +Hi guys, I have scraped all(not all till now, but going to be :) ) the examples from the Phpunit documentation website +(http://phpunit.de/manual/3.8/en/index.html) and put it into a executable php tests. The idea is that you learn fast +when you see something working. I will keep on improving this. Have fun + +Instructions to use it +---------------------- + +1. cd to project folder +2. Give executable permission to phpunit eg $ chmod aug+x ./bin/phpunit +3. Run the test by $ ./bin/phpunit --color +4. For example $ ./bin/phpunit --color 01StackTest.php +5. For run all tests $ ./bin/phpunit . + +Also do fork the project and improve it in any way you want. + +If you see any mistake please file the issue here https://github.com/the-crucible/phpunit-examples/issues diff --git a/data/data.csv b/data/data.csv index 7c192a8..d0495f4 100644 --- a/data/data.csv +++ b/data/data.csv @@ -1,5 +1,5 @@ -0 , 0 , 0 -0 , 1 , 1 -1 , 0 , 1 -1 , 1 , 3 - +0 , 0 , 0 +0 , 1 , 1 +1 , 0 , 1 +1 , 1 , 3 + diff --git a/fixtures/address.csv b/fixtures/address.csv index 9c49ef9..9fd0d87 100644 --- a/fixtures/address.csv +++ b/fixtures/address.csv @@ -1 +1 @@ -id,uid,street1,stree2,city.state,pin +id,uid,street1,stree2,city.state,pin diff --git a/fixtures/class.csv b/fixtures/class.csv index 29d0673..cfb34a2 100644 --- a/fixtures/class.csv +++ b/fixtures/class.csv @@ -1,3 +1,3 @@ -id,uid,class,age -1,1,1,5 -2,2,6,13 +id,uid,class,age +1,1,1,5 +2,2,6,13 diff --git a/fixtures/myDataSet.yml b/fixtures/myDataSet.yml index 683afcc..c5534ec 100644 --- a/fixtures/myDataSet.yml +++ b/fixtures/myDataSet.yml @@ -1,25 +1,25 @@ -## YAML Template. ---- -address: - -user: - - - id: 1 - name: "one" - - - id: 2 - name: "two" - -class: - - - id: 1 - uid: 1 - class: 1 - age: 5 - - - id: 2 - uid: 2 - class: 6 - age: 13 - - +## YAML Template. +--- +address: + +user: + - + id: 1 + name: "one" + - + id: 2 + name: "two" + +class: + - + id: 1 + uid: 1 + class: 1 + age: 5 + - + id: 2 + uid: 2 + class: 6 + age: 13 + + diff --git a/fixtures/myFlatXml1.xml b/fixtures/myFlatXml1.xml index 674782a..8a01ab6 100644 --- a/fixtures/myFlatXml1.xml +++ b/fixtures/myFlatXml1.xml @@ -1,6 +1,6 @@ - - - - - + + + + + \ No newline at end of file diff --git a/fixtures/myFlatXmlFixture.xml b/fixtures/myFlatXmlFixture.xml index ff0ac9e..73f8fca 100644 --- a/fixtures/myFlatXmlFixture.xml +++ b/fixtures/myFlatXmlFixture.xml @@ -1,13 +1,13 @@ - - - - - - - - - - - -
+ + + + + + + + + + + +
\ No newline at end of file diff --git a/fixtures/mySqldumpXmlDataset.xml b/fixtures/mySqldumpXmlDataset.xml index d8176d3..3a86b94 100644 --- a/fixtures/mySqldumpXmlDataset.xml +++ b/fixtures/mySqldumpXmlDataset.xml @@ -1,31 +1,31 @@ - - - - - - - - 1 - 1 - 5 - 1 - - - 2 - 2 - 13 - 6 - - - - - 1 - one - - - 2 - two kumar - - - - + + + + + + + + 1 + 1 + 5 + 1 + + + 2 + 2 + 13 + 6 + + + + + 1 + one + + + 2 + two kumar + + + + diff --git a/fixtures/myXmlDataset.xml b/fixtures/myXmlDataset.xml index e8dd494..1812409 100644 --- a/fixtures/myXmlDataset.xml +++ b/fixtures/myXmlDataset.xml @@ -1,35 +1,35 @@ - - - - idname - 1one - 2two kumar -
- - id - uid - class - age - - 1 - 1 - 1 - 5 - - - 2 - 2 - 6 - 13 - -
- - id - uid - street1 - street2 - city - state - pin -
+ + + + idname + 1one + 2two kumar +
+ + id + uid + class + age + + 1 + 1 + 1 + 5 + + + 2 + 2 + 6 + 13 + +
+ + id + uid + street1 + street2 + city + state + pin +
\ No newline at end of file diff --git a/fixtures/user.csv b/fixtures/user.csv index 3ec5e5e..d354c7b 100644 --- a/fixtures/user.csv +++ b/fixtures/user.csv @@ -1,3 +1,3 @@ -id,name -1,'one' -2,'two' +id,name +1,'one' +2,'two' diff --git a/lib/ArrayDataset.php b/lib/ArrayDataset.php index 4969ec6..56b60db 100644 --- a/lib/ArrayDataset.php +++ b/lib/ArrayDataset.php @@ -1,44 +1,44 @@ - $rows) { - $columns = array(); - if (isset($rows[0])) { - $columns = array_keys($rows[0]); - } - - $metaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns); - $table = new PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData); - - foreach ($rows AS $row) { - $table->addRow($row); - } - $this->tables[$tableName] = $table; - } - } - - protected function createIterator($reverse = FALSE) - { - return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($this->tables, $reverse); - } - - public function getTable($tableName) - { - if (!isset($this->tables[$tableName])) { - throw new InvalidArgumentException("$tableName is not a table in the current database."); - } - - return $this->tables[$tableName]; - } -} + $rows) { + $columns = array(); + if (isset($rows[0])) { + $columns = array_keys($rows[0]); + } + + $metaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($tableName, $columns); + $table = new PHPUnit_Extensions_Database_DataSet_DefaultTable($metaData); + + foreach ($rows AS $row) { + $table->addRow($row); + } + $this->tables[$tableName] = $table; + } + } + + protected function createIterator($reverse = FALSE) + { + return new PHPUnit_Extensions_Database_DataSet_DefaultTableIterator($this->tables, $reverse); + } + + public function getTable($tableName) + { + if (!isset($this->tables[$tableName])) { + throw new InvalidArgumentException("$tableName is not a table in the current database."); + } + + return $this->tables[$tableName]; + } +} ?> \ No newline at end of file diff --git a/lib/CsvFileIterator.php b/lib/CsvFileIterator.php index f4ff6f1..a94dea8 100644 --- a/lib/CsvFileIterator.php +++ b/lib/CsvFileIterator.php @@ -1,43 +1,43 @@ -file = fopen($file, 'r'); - } - - public function __destruct() { - fclose($this->file); - } - - public function rewind() { - rewind($this->file); - $this->current = fgetcsv($this->file); - $this->key = 0; - } - - public function valid() { - return !feof($this->file); - } - - public function key() { - return $this->key; - } - - public function current() { - return $this->current; - } - - public function next() { - $this->current = fgetcsv($this->file); - $this->key++; - } -} +file = fopen($file, 'r'); + } + + public function __destruct() { + fclose($this->file); + } + + public function rewind() { + rewind($this->file); + $this->current = fgetcsv($this->file); + $this->key = 0; + } + + public function valid() { + return !feof($this->file); + } + + public function key() { + return $this->key; + } + + public function current() { + return $this->current; + } + + public function next() { + $this->current = fgetcsv($this->file); + $this->key++; + } +} ?> \ No newline at end of file diff --git a/misc/PDOTest.php b/misc/PDOTest.php index 1159eb3..ac02765 100644 --- a/misc/PDOTest.php +++ b/misc/PDOTest.php @@ -1,100 +1,100 @@ - true - #)); - # - # Attributes could also be set by PDO::setAttribute(). But after the connection - # is made, it will have no effect there forward. - -} catch (Exception $e) { - die($e->getMessage()); -} - - -/** - * The most old form of quering and getting the data - * Isn't it resemble the - */ -echo "Using PDO for query operation\n"; -$rows = $pdo->query("Select * from tab1 order by id desc limit 1"); -foreach ($rows as $row) { - print_r($row); -} - -echo "\n\n\n"; -/** - * Transaction and commit - */ - -try { - $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); - $pdo->beginTransaction(); - $pdo->exec("insert into tab1 (name) values ('name1')"); // This will pass but it will also be rollbacked - $pdo->exec("insert into tab2 (name) values ('name2')"); // This will fail - echo "Am I executed"; // No, this will not be executed - $pdo->commit(); - -} catch (Exception $e) { - $pdo->rollBack(); - echo "Trying to execute 2 queries, one get execute and one dont. Rolling back the whole thing\n"; - echo "Failed: " . $e->getMessage() . "\n\n"; -} -echo "\n\n\n"; -/** - * Prepared statement examples - * - * Prepared statements are also called cached queries, so do use them - * as much as you can. - */ - -/** - * Inserting data using prepared statement - */ -echo "Doing insert though prepared statement\n"; - -$stmt = $pdo->prepare("INSERT INTO tab1 (name) VALUES (?)"); -//bindParam() function will bind the first(1) variable going into this -//query with the name variable -$stmt->bindParam(1, $name); - -// insert one row -$name = 'one'; -$stmt->execute(); -echo "First name one\n"; - -// insert another row with different values -$name = 'two'; -$stmt->execute(); -echo "Second name gone\n"; - -echo "\n\n\n"; -/** - * Selecting data using prepared statement - */ - -$stmt = $pdo->prepare("select count(*) as one_count from tab1 where name =?"); - -$stmt->bindColumn(1, $par1); - -$stmt->execute(array('one')); // Another way -$rows = $stmt->fetchAll(PDO::FETCH_OBJ); - -echo "Used select query using prepared statement and got the result below\n"; -print_r($rows); - -?> + true + #)); + # + # Attributes could also be set by PDO::setAttribute(). But after the connection + # is made, it will have no effect there forward. + +} catch (Exception $e) { + die($e->getMessage()); +} + + +/** + * The most old form of quering and getting the data + * Isn't it resemble the + */ +echo "Using PDO for query operation\n"; +$rows = $pdo->query("Select * from tab1 order by id desc limit 1"); +foreach ($rows as $row) { + print_r($row); +} + +echo "\n\n\n"; +/** + * Transaction and commit + */ + +try { + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $pdo->beginTransaction(); + $pdo->exec("insert into tab1 (name) values ('name1')"); // This will pass but it will also be rollbacked + $pdo->exec("insert into tab2 (name) values ('name2')"); // This will fail + echo "Am I executed"; // No, this will not be executed + $pdo->commit(); + +} catch (Exception $e) { + $pdo->rollBack(); + echo "Trying to execute 2 queries, one get execute and one dont. Rolling back the whole thing\n"; + echo "Failed: " . $e->getMessage() . "\n\n"; +} +echo "\n\n\n"; +/** + * Prepared statement examples + * + * Prepared statements are also called cached queries, so do use them + * as much as you can. + */ + +/** + * Inserting data using prepared statement + */ +echo "Doing insert though prepared statement\n"; + +$stmt = $pdo->prepare("INSERT INTO tab1 (name) VALUES (?)"); +//bindParam() function will bind the first(1) variable going into this +//query with the name variable +$stmt->bindParam(1, $name); + +// insert one row +$name = 'one'; +$stmt->execute(); +echo "First name one\n"; + +// insert another row with different values +$name = 'two'; +$stmt->execute(); +echo "Second name gone\n"; + +echo "\n\n\n"; +/** + * Selecting data using prepared statement + */ + +$stmt = $pdo->prepare("select count(*) as one_count from tab1 where name =?"); + +$stmt->bindColumn(1, $par1); + +$stmt->execute(array('one')); // Another way +$rows = $stmt->fetchAll(PDO::FETCH_OBJ); + +echo "Used select query using prepared statement and got the result below\n"; +print_r($rows); + +?> diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..83e51a7 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,48 @@ + + + + + + ./ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sql/test_pdo.sql b/sql/test_pdo.sql index 0585d58..7087ba4 100644 --- a/sql/test_pdo.sql +++ b/sql/test_pdo.sql @@ -1,36 +1,36 @@ --- phpMyAdmin SQL Dump --- version 3.4.1 --- http://www.phpmyadmin.net --- --- Host: localhost --- Generation Time: Aug 08, 2013 at 04:25 PM --- Server version: 5.5.28 --- PHP Version: 5.3.18 - -SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -SET time_zone = "+00:00"; - --- --- Database: `test_pdo` --- - --- -------------------------------------------------------- - --- --- Table structure for table `user` --- - -CREATE TABLE IF NOT EXISTS `user` ( - `id` tinyint(4) NOT NULL AUTO_INCREMENT, - `name` varchar(20) NOT NULL, - PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; - --- --- Dumping data for table `user` --- - -INSERT INTO `user` (`id`, `name`) VALUES -(1, 'one'), -(2, 'two kumar'); - +-- phpMyAdmin SQL Dump +-- version 3.4.1 +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Generation Time: Aug 08, 2013 at 04:25 PM +-- Server version: 5.5.28 +-- PHP Version: 5.3.18 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + +-- +-- Database: `test_pdo` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user` +-- + +CREATE TABLE IF NOT EXISTS `user` ( + `id` tinyint(4) NOT NULL AUTO_INCREMENT, + `name` varchar(20) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ; + +-- +-- Dumping data for table `user` +-- + +INSERT INTO `user` (`id`, `name`) VALUES +(1, 'one'), +(2, 'two kumar'); +