public function testGenerateNoIdNoName() { $id = ''; $generator = new ParentIdGenerator(); $cm = new ParentClassMetadataProxy(new ParentDummy(), '', ''); $dm = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\DocumentManager')->disableOriginalConstructor()->getMock(); try { $generator->generate(null, $cm, $dm); } catch (\Exception $expected) { return; } $this->fail('Expected \\Exception not thrown'); }
/** * @expectedException \Doctrine\ODM\PHPCR\Id\IdException */ public function testGenerateNoParentId() { $generator = new ParentIdGenerator(); $parent = new ParentDummy(); $cm = new ParentClassMetadataProxy($parent, 'name', '', new MockField($parent, '/miau')); $uow = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\UnitOfWork')->disableOriginalConstructor()->getMock(); $uow->expects($this->once())->method('getDocumentId')->with($this->equalTo($parent))->will($this->returnValue('')); $dm = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\DocumentManager')->disableOriginalConstructor()->getMock(); $dm->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow)); $generator->generate(null, $cm, $dm); }