예제 #1
0
 public function testDisabledAddEntity()
 {
     $storage = $this->getMockBuilder('SFM\\IdentityMap\\IdentityMapStorage')->getMock();
     $storage1 = $this->getMockBuilder('SFM\\IdentityMap\\IdentityMapStorage')->getMock();
     $storage2 = $this->getMockBuilder('SFM\\IdentityMap\\IdentityMapStorage')->getMock();
     $im = new IdentityMap($storage, $storage1, $storage2);
     $im->disable();
     $entity = $this->getMockBuilder('SFM\\Entity')->disableOriginalConstructor()->setMockClassName('SampleEntity')->getMock();
     $storage->expects($this->never())->method('put');
     $im->addEntity($entity);
 }
예제 #2
0
 public function testTransactionEmptyAddAndRemove3()
 {
     $entity1 = $this->getMockBuilder('SFM\\Entity')->disableOriginalConstructor()->setMethods(['getId'])->setMockClassName('SampleEntity')->getMock();
     $entity1->expects($this->any())->method('getId')->willReturn('1');
     $im = new IdentityMap(new \SFM\IdentityMap\IdentityMapStorage(), new \SFM\IdentityMap\IdentityMapStorage(), new \SFM\IdentityMap\IdentityMapStorage());
     $im->addEntity($entity1);
     $im->beginTransaction();
     $im->deleteEntity($entity1);
     $im->rollbackTransaction();
     $entityReturned = $im->getEntity('SampleEntity', 1);
     $this->assertInstanceOf('SampleEntity', $entityReturned);
     $this->assertSame($entityReturned, $entity1);
 }