public function testDelete() { $r = new AuthorityRecord(); $r->append(new Field('003@', 0, array(new Subfield('0', 'valid')))); $this->assertFalse($r->isEmpty()); $r->delete(Field::match('..../..')); $this->assertTrue($r->isEmpty()); }
public function testDeletePropagatesDown() { $r = new LocalRecord(); $c = new CopyRecord(array(new Field('200@', 11))); $r->addCopyRecord($c); $this->assertFalse($c->isEmpty()); $r->delete(Field::match('200@/11')); $this->assertTrue($c->isEmpty()); }
/** * Return fields of the record. * * @see Record::getFields() * * @param string $selector Body of regular expression * @return array Fields */ public function getFields($selector = null) { if ($selector === null) { return array_merge($this->_fields, Helper::flatten(Helper::mapMethod($this->_records, 'getFields'))); } else { return $this->select(Field::match($selector)); } }
/** * Return fields of the record. * * Optional argument $selector is the body of a regular expression. If set, * this function returns only fields whose shorthand is matched by the * regular expression. * * @see Field::match() * * @param string $selector Body of regular expression * @return array Fields */ public function getFields($selector = null) { if ($selector === null) { return $this->_fields; } else { return $this->select(Field::match($selector)); } }
public function testMatch() { $this->assertTrue(call_user_func(Field::match('003./..'), new Field('003@', 0))); $this->assertTrue(call_user_func(Field::match('003./..'), new Field('003Z', 0))); $this->assertTrue(call_user_func(Field::match('003./..'), new Field('003Z', 99))); }