/** * Add a copy record. * * @throws InvalidArgumentException Record already contains the copy record * @throws InvalidArgumentException Record already contains a copy record with the same item number * * @param CopyRecord $record Copy record to add * @return void */ public function addCopyRecord(CopyRecord $record) { if ($this->getCopyRecordByItemNumber($record->getItemNumber())) { throw new InvalidArgumentException("Cannot add copy record: Copy record with item number {$record->getItemNumber()} already present"); } $this->addRecord($record); $record->setLocalRecord($this); }
/** * @expectedException InvalidArgumentException */ public function testAppendThrowsExceptionOnNumberMismatch() { $r = new CopyRecord(); $r->append(new Field('201@', 0)); $r->append(new Field('202@', 1)); }