/** * @expectedException \Exception * @expectedExceptionMessage Attribute "_id" was not defined. */ public function testLoad() { $id = new MongoId(); $model = new TestSchema(['_id' => $id, 'title' => 'TitleLoad']); $model->save(); $model = new TestSchema(['_id' => $id]); $this->assertTrue($model->load()); $this->assertEquals('TitleLoad', $model->title); TestSchema::getCollection()->clearIdentityMap(); $model = new TestSchema(['_id' => $id]); $this->assertTrue($model->load()); $this->assertEquals('TitleLoad', $model->title); $model = new TestSchema(['_id' => new MongoId()]); $this->assertFalse($model->load()); // To test exception $model = new TestSchema(); $model->load(); }