Example #1
0
 public function testIfWillDeleteAllPlainDocumentsByPk()
 {
     $pks = [];
     $model = new PlainWithBasicAttributes();
     $model->_id = new MongoId();
     $pks[] = $model->_id;
     $em = new EntityManager($model);
     $em->save();
     $model = new PlainWithBasicAttributes();
     $model->_id = new MongoId();
     $pks[] = $model->_id;
     $em = new EntityManager($model);
     $em->save();
     $model = new PlainWithBasicAttributes();
     $model->_id = new MongoId();
     $em = new EntityManager($model);
     $em->save();
     $finder = new Finder($model);
     $count = $finder->count();
     $this->assertSame(3, $count);
     $em->deleteAllByPk($pks);
     $found = $finder->findByPk($model->_id);
     $this->assertInstanceOf(PlainWithBasicAttributes::class, $found);
     $countAfterDelete = $finder->count();
     $this->assertSame(1, $countAfterDelete);
 }