Skip to content

Commit

Permalink
Merge pull request #4 from cKlee/master
Browse files Browse the repository at this point in the history
added charLength for  offsetExists
  • Loading branch information
cKlee committed Apr 28, 2015
2 parents 1eb0d45 + 1f4e41f commit 2d570c8
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ public function offsetExists($offset)
break;
case 'charEnd': return isset($this->charEnd);
break;
case 'charLength': return !is_null($this->getCharLength());
break;
case 'indicator1': return isset($this->indicator1);
break;
case 'indicator2': return isset($this->indicator2);
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For currently supported version of **MARCspec - A common MARC record path langua

Installation can be done by using [composer](https://getcomposer.org/doc/00-intro.md)

```
```php
{
"require": {
"ck/php-marcspec": "1.*"
Expand Down
3 changes: 3 additions & 0 deletions Subfield.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,9 @@ public function offsetExists($offset)

case 'charEnd': return isset($this->charEnd);
break;

case 'charLength': return !is_null($this->getCharLength());
break;

case 'subSpecs': return (0 < count($this->subSpecs)) ? true : false;
break;
Expand Down
22 changes: 0 additions & 22 deletions Test/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,28 +196,6 @@ public function testInvalidFieldSpec34()
public function testInvalidFieldSpec35()
{
$this->fieldspec('245___');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec37()
{
$this->fieldspec('245_1+');
}
/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec38()
{
$this->fieldspec('245_123');
}
/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec39()
{
$this->fieldspec('245_$');
}

/**
Expand Down
18 changes: 18 additions & 0 deletions Test/MarcSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,24 @@ public function testIteration()


}

public function testOffsets()
{
$ms = $this->marcspec('LDR/0-3');
$this->assertTrue($ms['field']->offsetExists('charLength'));

$ms = $this->marcspec('LDR/0-#');
$this->assertFalse($ms['field']->offsetExists('charLength'));

$ms = $this->marcspec('245$a/0-3');
$this->assertTrue($ms['a'][0]->offsetExists('charLength'));

$ms = $this->marcspec('245$a/#-3');
$this->assertTrue($ms['a'][0]->offsetExists('charLength'));

$ms = $this->marcspec('245$a/0-#');
$this->assertFalse($ms['a'][0]->offsetExists('charLength'));
}


}

0 comments on commit 2d570c8

Please sign in to comment.