Permalink
Browse files

Fixed tests for applied patches and for recent release of PHPUnit

git-svn-id: http://mongodb-morph.googlecode.com/svn/trunk@144 406649b4-5d4b-11de-8abc-d1c337b90d21
  • Loading branch information...
1 parent 8171ea1 commit 3aaf344aa4385beaaf1ebdf0b04c4f7937aadba3 Xirisr@gmail.com committed Apr 16, 2011
View
@@ -50,7 +50,7 @@
</target>
<target name="coverage-report" description="generates unit test coverage report">
- <exec command="phpunit --coverage-html doc/coverage/ unit-tests/AllTests.php" checkreturn="false" />
+ <exec command="phpunit --coverage-html doc/coverage/ unit-tests/UnitTests.php" checkreturn="false" />
</target>
<target name="integration-report" description="Runs Morph integration tests">
@@ -3,7 +3,6 @@
* @author Jonathan Moss <xirisr@gmail.com>
* @copyright Jonathan Moss 2010
*/
-require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/../Morph.phar';
require_once dirname(__FILE__).'/TestComposeMany.php';
require_once dirname(__FILE__).'/TestComposeOne.php';
@@ -5,13 +5,7 @@
* @package MongoUnit
* @subpackage Constraint
*/
-
-require_once 'PHPUnit/Framework.php';
-require_once 'PHPUnit/Util/Filter.php';
require_once 'PHPUnit/Util/Type.php';
-
-PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
-
/**
* A PHP Unit constraint that checks a collection does not exist
*
@@ -5,13 +5,7 @@
* @package MongoUnit
* @subpackage Constraint
*/
-
-require_once 'PHPUnit/Framework.php';
-require_once 'PHPUnit/Util/Filter.php';
require_once 'PHPUnit/Util/Type.php';
-
-PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
-
/**
* A PHP Unit constraint that checks if a collection exists
*
@@ -5,13 +5,7 @@
* @package MongoUnit
* @subpackage Constraint
*/
-
-require_once 'PHPUnit/Framework.php';
-require_once 'PHPUnit/Util/Filter.php';
require_once 'PHPUnit/Util/Type.php';
-
-PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
-
/**
* A PHP Unit constraint that checks to ensure a specific document exists
*
@@ -5,13 +5,7 @@
* @package MongoUnit
* @subpackage Constraint
*/
-
-require_once 'PHPUnit/Framework.php';
-require_once 'PHPUnit/Util/Filter.php';
require_once 'PHPUnit/Util/Type.php';
-
-PHPUnit_Util_Filter::addFileToFilter(__FILE__, 'PHPUNIT');
-
/**
* A PHP Unit constraint that checks to ensure a specific document property
* equals an expected value
@@ -38,6 +32,8 @@ class MongoUnit_Constraint_DocumentPropertyEquals extends PHPUnit_Framework_Cons
private $expected;
+ private $found;
+
/**
* @param integer|string $key
*/
@@ -60,7 +56,8 @@ public function evaluate($other)
{
$query = array('_id' => $other);
$data = $this->db->selectCollection($this->collection)->findOne($query);
- return ($data[$this->property] == $this->expected);
+ $this->found = $data[$this->property];
+ return ($this->found == $this->expected);
}
/**
@@ -70,7 +67,7 @@ public function evaluate($other)
*/
public function toString()
{
- return "equals: " . print_r($this->expected, true);
+ return "expected:\n" . print_r($this->expected, true);
}
/**
@@ -81,10 +78,11 @@ public function toString()
protected function customFailureDescription($other, $description, $not)
{
return sprintf(
- 'Failed asserting that the property %s in document %s %s',
+ "Failed asserting that the property %s in document \n%s %s\nactual: ",
$this->property,
$other,
- $this->toString()
+ $this->toString(),
+ print_r($this->found)
);
}
}
@@ -49,8 +49,8 @@ public function testStoresParentAndChild()
$this->assertDocumentExists('ComposeManyParent', $parent->id());
$expected = array (
- array('_ns'=>'Child', 'Name'=>'Child1'),
- array('_ns'=>'Child', 'Name'=>'Child2')
+ array('_ns'=>'Child', 'Name'=>'Child1', 'Age' => null),
+ array('_ns'=>'Child', 'Name'=>'Child2', 'Age' => null)
);
$this->assertDocumentPropertyEquals($expected, 'ComposeManyParent', 'Children', $parent->id());
@@ -44,7 +44,7 @@ public function testStoresParentAndChild()
$this->assertDocumentExists('ComposeOneParent', $parent->id());
- $this->assertDocumentPropertyEquals(array('_ns'=>'Child', 'Name'=>'Child'), 'ComposeOneParent', 'Child', $parent->id());
+ $this->assertDocumentPropertyEquals(array('_ns'=>'Child', 'Name'=>'Child', 'Age' => null), 'ComposeOneParent', 'Child', $parent->id());
}
}
@@ -110,7 +110,12 @@ public function offsetSet($offset, $object)
*
* @param $object
*/
- private function checkType($object){
+ private function checkType($object)
+ {
+ if (!is_object($object)) {
+ throw new InvalidArgumentException('value if not and object that extends Morph_Property_Generic');
+ }
+
if(!($object instanceof Morph_Property_Generic)){
throw new InvalidArgumentException('object of type' . get_class($object) . ' does not extend Morph_Property_Generic');
}
@@ -1,8 +1,5 @@
<?php
-require_once 'PHPUnit/Framework/TestCase.php';
-
require_once dirname(__FILE__).'/../src/Morph/Utils.php';
-
/**
* @package Morph
*/
@@ -22,7 +19,9 @@ public function testNamespacedCollectionName()
$this->markTestSkipped("Skipped for PHP Versions lower than 5.3.0");
return;
}
- $object = $this->getMock('Morph_Object', array(), 'user\\Profile');
+ $mockMorphObject = $this->getMock('Morph_Object');
+ require dirname(__FILE__) . '/namespaced_stub.php';
+ $object = new user\Profile();
$collectionName = Morph_Utils::collectionName($object);
$this->assertEquals('user.Profile', $collectionName);
}
@@ -45,5 +44,4 @@ public function testObjectReference()
$this->assertEquals($ref, $expectedArray);
}
-}
-?>
+}
@@ -1,5 +1,4 @@
<?php
-require_once 'PHPUnit/Framework.php';
require_once dirname(__FILE__).'/TestPropertySet.php';
require_once dirname(__FILE__).'/TestUtils.php';

0 comments on commit 3aaf344

Please sign in to comment.