Permalink
Browse files

updating integration tests for new Morph_Storage usage pattern

git-svn-id: http://mongodb-morph.googlecode.com/svn/trunk@60 406649b4-5d4b-11de-8abc-d1c337b90d21
  • Loading branch information...
1 parent 6f32183 commit 1d1a766b98ffd13fab3af1c2476f05bccbeb2eac XirisR committed Jan 8, 2010
@@ -11,16 +11,17 @@
class TestComposeMany extends MongoTestCase
{
- /**
- * @var Morph_Storage
- */
- private $storage;
-
public function setUp()
{
parent::setUp();
$mongo = new Mongo();
- $this->storage = new Morph_Storage($mongo->selectDB(self::TEST_DB_NAME));
+ Morph_Storage::init($mongo->selectDB(self::TEST_DB_NAME));
+ }
+
+ public function tearDown()
+ {
+ parent::tearDown();
+ Morph_Storage::deInit();
}
public function testStoresParentAndChild()
@@ -37,7 +38,7 @@ public function testStoresParentAndChild()
$parent->Children[] = $child1;
$parent->Children[] = $child2;
- $this->storage->save($parent);
+ $parent->save();
sleep(1); //MongoDB can take a sec to allocate the collection files
$this->assertCollectionExists('ComposeManyParent');
$this->assertCollectionDoesNotExist('Child');
@@ -11,16 +11,17 @@
class TestComposeOne extends MongoTestCase
{
- /**
- * @var Morph_Storage
- */
- private $storage;
-
public function setUp()
{
parent::setUp();
$mongo = new Mongo();
- $this->storage = new Morph_Storage($mongo->selectDB(self::TEST_DB_NAME));
+ Morph_Storage::init($mongo->selectDB(self::TEST_DB_NAME));
+ }
+
+ public function tearDown()
+ {
+ parent::tearDown();
+ Morph_Storage::deInit();
}
public function testStoresParentAndChild()
@@ -33,7 +34,7 @@ public function testStoresParentAndChild()
$parent->Child = $child;
- $this->storage->save($parent);
+ $parent->save();
sleep(1); //MongoDB can take a sec to allocate the collection files
$this->assertCollectionExists('ComposeOneParent');
$this->assertCollectionDoesNotExist('Child');
@@ -9,21 +9,17 @@
class TestFileProperty extends MongoTestCase
{
- /**
- * @var Morph_Storage
- */
- private $storage;
-
- public function setUp()
+ public function setUp()
{
parent::setUp();
$mongo = new Mongo();
- $this->storage = new Morph_Storage($mongo->selectDB(self::TEST_DB_NAME));
+ Morph_Storage::init($mongo->selectDB(self::TEST_DB_NAME));
}
public function tearDown()
{
parent::tearDown();
+ Morph_Storage::deInit();
unlink('test.png');
}
@@ -32,7 +28,7 @@ public function testStoresUserAndFile()
$user = new User();
$user->Username = 'a_musing_moose';
$user->Avatar = dirname(__FILE__).'/resources/flask.png';
- $this->storage->save($user);
+ $user->save();
sleep(1); //MongoDB can take a sec to allocate the collection files
$this->assertCollectionExists('User');
$this->assertDocumentExists('User', $user->id());
@@ -10,16 +10,17 @@
class TestHasMany extends MongoTestCase
{
- /**
- * @var Morph_Storage
- */
- private $storage;
-
public function setUp()
{
parent::setUp();
$mongo = new Mongo();
- $this->storage = new Morph_Storage($mongo->selectDB(self::TEST_DB_NAME));
+ Morph_Storage::init($mongo->selectDB(self::TEST_DB_NAME));
+ }
+
+ public function tearDown()
+ {
+ parent::tearDown();
+ Morph_Storage::deInit();
}
public function testStoresParentAndChildren()
@@ -37,7 +38,7 @@ public function testStoresParentAndChildren()
$parent->Children[] = $child2;
- $this->storage->save($parent);
+ $parent->save();
sleep(1); //MongoDB can take a sec to allocate the collection files
$this->assertCollectionExists('HasManyParent');
$this->assertCollectionExists('Child');
@@ -11,16 +11,17 @@
class TestHasOne extends MongoTestCase
{
- /**
- * @var Morph_Storage
- */
- private $storage;
-
public function setUp()
{
parent::setUp();
$mongo = new Mongo();
- $this->storage = new Morph_Storage($mongo->selectDB(self::TEST_DB_NAME));
+ Morph_Storage::init($mongo->selectDB(self::TEST_DB_NAME));
+ }
+
+ public function tearDown()
+ {
+ parent::tearDown();
+ Morph_Storage::deInit();
}
public function testStoresParentAndChild()
@@ -33,7 +34,7 @@ public function testStoresParentAndChild()
$parent->Child = $child;
- $this->storage->save($parent);
+ $parent->save();
sleep(1); //MongoDB can take a sec to allocate the collection files
$this->assertCollectionExists('HasOneParent');
$this->assertCollectionExists('Child');
@@ -11,23 +11,24 @@
class TestSingleObject extends MongoTestCase
{
- /**
- * @var Morph_Storage
- */
- private $storage;
-
public function setUp()
{
parent::setUp();
$mongo = new Mongo();
- $this->storage = new Morph_Storage($mongo->selectDB(self::TEST_DB_NAME));
+ Morph_Storage::init($mongo->selectDB(self::TEST_DB_NAME));
+ }
+
+ public function tearDown()
+ {
+ parent::tearDown();
+ Morph_Storage::deInit();
}
public function testStoresParentAndChild()
{
$child = new Child();
$child->Name = 'Child';
- $this->storage->save($child);
+ $child->save();
sleep(1); //MongoDB can take a sec to allocate the collection files
$this->assertCollectionExists('Child');
$this->assertDocumentExists('Child', $child->id());

0 comments on commit 1d1a766

Please sign in to comment.