Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
vendor/
composer.lock
.phpunit.result.cache
.phpunit.cache/
build/
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
language: php
php:
- 7.4
- 8.0
- 8.1
- 8.2
- 8.3
- 8.4

fast_finish: true

Expand Down
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## Fork (redcuillin)

Fork of [MARCspec/php-marc-spec](https://github.com/MARCspec/php-marc-spec) for PHP 8.4 and 8.5 support.

### Using this fork with Composer

Add the following to your `composer.json` `repositories` and `require` sections (merge with existing entries as needed):

```json
"repositories": [
{
"type": "vcs",
"url": "https://github.com/redcuillin/php-marc-spec"
}
],
"require": {
"ck/php-marcspec": "dev-master as 2.999.0"
}
```

-----

## Upstream readme:

# PHP-MARCspec

[![Build Status](https://travis-ci.org/MARCspec/php-marc-spec.svg?branch=master)](https://travis-ci.org/MARCspec/php-marc-spec)
Expand All @@ -14,7 +38,7 @@ Installation can be done by using [composer](https://getcomposer.org/doc/00-intr
composer require ck/php-marcspec
```

PHP-MARCspec requires PHP 7.4 or later.
PHP-MARCspec requires PHP 8.2 or later and is compatible with PHP 8.4.

# Usage

Expand Down
26 changes: 12 additions & 14 deletions Test/ComparisonStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@
namespace CK\MARCspec\Test;

use CK\MARCspec\ComparisonString;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class ComparisonStringTest extends TestCase
{
/**
* @dataProvider invalidFromTestSuiteProvider
*
* @expectedException Exception
*/
#[DataProvider('invalidFromTestSuiteProvider')]
public function testInvalidFromTestSuite($test)
{
$this->expectException(\Exception::class);
new ComparisonString($test);
}

public function invalidFromTestSuiteProvider()
public static function invalidFromTestSuiteProvider()
{
$invalidTests = json_decode(file_get_contents(__DIR__.'/../'.'vendor/ck/marcspec-test-suite/invalid/invalidComparisonString.json'));
$invalidTests = json_decode(file_get_contents(__DIR__ . '/../' . 'vendor/ck/marcspec-test-suite/invalid/invalidComparisonString.json'));
$data = [];
foreach ($invalidTests->{'tests'} as $test) {
$data[0][] = $test->{'data'};
Expand All @@ -36,10 +34,10 @@ public function invalidFromTestSuiteProvider()

public function testValidFromTestSuite()
{
$validTests = json_decode(file_get_contents(__DIR__.'/../'.'vendor/ck/marcspec-test-suite/valid/validComparisonString.json'));
$validTests = json_decode(file_get_contents(__DIR__ . '/../' . 'vendor/ck/marcspec-test-suite/valid/validComparisonString.json'));
foreach ($validTests->{'tests'} as $test) {
new ComparisonString($test->{'data'});
$this->assertSame(1, preg_match('/'.$validTests->{'schema'}->{'pattern'}.'/', $test->{'data'}));
$this->assertSame(1, preg_match('/' . $validTests->{'schema'}->{'pattern'} . '/', $test->{'data'}));
}
}

Expand All @@ -49,22 +47,22 @@ public function compare($arg)
}

/****
* invalid data types
***/
* invalid data types
***/

/**
* @expectedException InvalidArgumentException
*/
public function testInvalidArgument1Decode()
{
$this->expectException(\InvalidArgumentException::class);
$this->compare(['a']);
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidArgument2Decode()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->compare('.{.');
}

Expand Down Expand Up @@ -100,10 +98,10 @@ public function testValidComparisonString2()
}

/**
* @expectedException BadMethodCallException
*/
public function testOffsetUnset()
{
$this->expectException(\BadMethodCallException::class);
$escaped_string = '\\.';
$compare = $this->compare($escaped_string);
unset($compare['raw']);
Expand Down
58 changes: 27 additions & 31 deletions Test/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,21 @@
use CK\MARCspec\Field;
use CK\MARCspec\MARCspec;
use CK\MARCspec\SubSpec;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class FieldTest extends TestCase
{
/**
* @dataProvider invalidFromTestSuiteProvider
*
* @expectedException Exception
*/
#[DataProvider('invalidFromTestSuiteProvider')]
public function testInvalidFromTestSuite($test)
{
$this->expectException(\Exception::class);
new Field($test);
}

public function invalidFromTestSuiteProvider()
public static function invalidFromTestSuiteProvider()
{
$invalidTests = json_decode(file_get_contents(__DIR__.'/../'.'vendor/ck/marcspec-test-suite/invalid/invalidFieldTag.json'));
$invalidTests = json_decode(file_get_contents(__DIR__ . '/../' . 'vendor/ck/marcspec-test-suite/invalid/invalidFieldTag.json'));
$data = [];
foreach ($invalidTests->{'tests'} as $test) {
$data[0][] = $test->{'data'};
Expand All @@ -38,7 +36,7 @@ public function invalidFromTestSuiteProvider()

public function testValidFromTestSuite()
{
$validTests = json_decode(file_get_contents(__DIR__.'/../'.'vendor/ck/marcspec-test-suite/valid/validFieldTag.json'));
$validTests = json_decode(file_get_contents(__DIR__ . '/../' . 'vendor/ck/marcspec-test-suite/valid/validFieldTag.json'));
foreach ($validTests->{'tests'} as $test) {
$this->assertInstanceOf('CK\MARCspec\FieldInterface', new Field($test->{'data'}));
}
Expand All @@ -50,146 +48,146 @@ public function fieldspec($arg)
}

/**
* @expectedException InvalidArgumentException
*/
public function testInvalidArgument2Decode()
{
$this->expectException(\InvalidArgumentException::class);
$this->fieldspec(['245']);
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec13()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('007/');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec14()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('007/1-2-');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec15()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('24#');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec16()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('007/-2');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec17()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('245[-2]');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec18()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('245[1-2-]');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec19()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('245[1-2');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec110()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('007/1-X');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec111()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('007/#-');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec112()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('245[0-2a]');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec113()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('300[1-]');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec114()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$fieldSpec = $this->fieldspec('aA0');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec31()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('245^1');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec32()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('245_$');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidFieldSpec33()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('245^');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidArgument310Decode()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('245{$c=$d}$a');
}

/**
* @expectedException CK\MARCspec\Exception\InvalidMARCspecException
*/
public function testInvalidArgument311Decode()
{
$this->expectException(\CK\MARCspec\Exception\InvalidMARCspecException::class);
$this->fieldspec('245[1]/1_01');
}

Expand Down Expand Up @@ -274,9 +272,7 @@ public function testValidFieldSpec22()
}

/**
* @covers CK\MARCspec\Field::offsetSet
* @covers CK\MARCspec\Field::offsetExists
* @covers CK\MARCspec\Field::addSubSpec
* Field offset API and subspecs.
*/
public function testValidFieldSpec24()
{
Expand Down Expand Up @@ -391,7 +387,7 @@ public function testEncode()
}

/**
* @covers CK\MARCspec\Field::jsonSerialize
* JSON encoding of a field spec.
*/
public function testJson()
{
Expand All @@ -407,10 +403,10 @@ public function testJson()
}

/**
* @expectedException BadMethodCallException
*/
public function testOffsetUnset()
{
$this->expectException(\BadMethodCallException::class);
$fieldSpec = $this->fieldspec('245');
unset($fieldSpec['tag']);
}
Expand Down
Loading