Commit ce878d6e authored by David Maus's avatar David Maus
Browse files

Update tests to use PHPUnit 8

parent 4e14d420
...@@ -17,5 +17,8 @@ ...@@ -17,5 +17,8 @@
"psr-0": { "psr-0": {
"HAB\\Pica": "src/" "HAB\\Pica": "src/"
} }
},
"require-dev": {
"phpunit/phpunit": "^8"
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<phpunit bootstrap="tests/unit-tests/bootstrap.php" strict="true"> <phpunit bootstrap="tests/unit-tests/bootstrap.php">
<testsuites> <testsuites>
<testsuite name="Unit Tests"> <testsuite name="Unit Tests">
<directory suffix="Test.php">tests</directory> <directory suffix="Test.php">tests</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter> <filter>
<blacklist>
<directory suffix=".php">vendor</directory>
<directory suffix=".php">tests</directory>
</blacklist>
<whitelist addUncoveredFilesFromWhitelist="true"> <whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".php">bin</directory> <directory suffix=".php">bin</directory>
<directory suffix=".php">src</directory> <directory suffix=".php">src</directory>
......
...@@ -20,33 +20,33 @@ ...@@ -20,33 +20,33 @@
* *
* @package PicaRecord * @package PicaRecord
* @author David Maus <maus@hab.de> * @author David Maus <maus@hab.de>
* @copyright Copyright (c) 2012, 2013 by Herzog August Bibliothek Wolfenbüttel * @copyright Copyright (c) 2012-2019 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3
*/ */
namespace HAB\Pica\Record; namespace HAB\Pica\Record;
use PHPUnit_FrameWork_TestCase; use PHPUnit\Framework\TestCase;
class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase class AuthorityRecordTest extends TestCase
{ {
/// ///
public function testIsEmpty () public function testIsEmpty ()
{ {
$r = new AuthorityRecord(); $r = new AuthorityRecord();
$this->assertTrue($r->isEmpty()); $this->assertTrue($r->isEmpty());
} }
public function testAppend () public function testAppend ()
{ {
$r = new AuthorityRecord(); $r = new AuthorityRecord();
$r->append(new Field('000@', 0, array(new Subfield('0', 'valid')))); $r->append(new Field('000@', 0, array(new Subfield('0', 'valid'))));
$this->assertFalse($r->isEmpty()); $this->assertFalse($r->isEmpty());
} }
public function testGetPPN () public function testGetPPN ()
{ {
$r = new AuthorityRecord(); $r = new AuthorityRecord();
$this->assertNull($r->getPPN()); $this->assertNull($r->getPPN());
...@@ -54,7 +54,7 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase ...@@ -54,7 +54,7 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase
$this->assertEquals('valid', $r->getPPN()); $this->assertEquals('valid', $r->getPPN());
} }
public function testDelete () public function testDelete ()
{ {
$r = new AuthorityRecord(); $r = new AuthorityRecord();
$r->append(new Field('003@', 0, array(new Subfield('0', 'valid')))); $r->append(new Field('003@', 0, array(new Subfield('0', 'valid'))));
...@@ -65,7 +65,7 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase ...@@ -65,7 +65,7 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase
/// ///
public function testSetPPN () public function testSetPPN ()
{ {
$r = new AuthorityRecord(); $r = new AuthorityRecord();
$this->assertNull($r->getPPN()); $this->assertNull($r->getPPN());
...@@ -76,7 +76,7 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase ...@@ -76,7 +76,7 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase
$this->assertEquals(1, count($r->getFields('003@/00'))); $this->assertEquals(1, count($r->getFields('003@/00')));
} }
public function testClone () public function testClone ()
{ {
$r = new AuthorityRecord(); $r = new AuthorityRecord();
$f = new Field('003@', 0); $f = new Field('003@', 0);
...@@ -87,38 +87,38 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase ...@@ -87,38 +87,38 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase
$this->assertNotSame($f, reset($fields)); $this->assertNotSame($f, reset($fields));
} }
public function testIsInvalidEmptyField () public function testIsInvalidEmptyField ()
{ {
$r = new AuthorityRecord(array(new Field('003@', 0))); $r = new AuthorityRecord(array(new Field('003@', 0)));
$this->assertFalse($r->isValid()); $this->assertFalse($r->isValid());
} }
public function testIsInvalidMissingPPN () public function testIsInvalidMissingPPN ()
{ {
$r = new AuthorityRecord(array(new Field('002@', 0, array(new Subfield('0', 'T'))))); $r = new AuthorityRecord(array(new Field('002@', 0, array(new Subfield('0', 'T')))));
$this->assertFalse($r->isValid()); $this->assertFalse($r->isValid());
} }
public function testIsInvalidMissingType () public function testIsInvalidMissingType ()
{ {
$r = new AuthorityRecord(array(new Field('003@', 0, array(new Subfield('0', 'something'))))); $r = new AuthorityRecord(array(new Field('003@', 0, array(new Subfield('0', 'something')))));
$this->assertFalse($r->isValid()); $this->assertFalse($r->isValid());
} }
public function testIsInvalidWrongType () public function testIsInvalidWrongType ()
{ {
$r = new AuthorityRecord(array(new Field('002@', 0, array(new Subfield('0', 'A'))))); $r = new AuthorityRecord(array(new Field('002@', 0, array(new Subfield('0', 'A')))));
$this->assertFalse($r->isValid()); $this->assertFalse($r->isValid());
} }
public function testIsValid () public function testIsValid ()
{ {
$r = new AuthorityRecord(array(new Field('002@', 0, array(new Subfield('0', 'T'))), $r = new AuthorityRecord(array(new Field('002@', 0, array(new Subfield('0', 'T'))),
new Field('003@', 0, array(new Subfield('0', 'valid'))))); new Field('003@', 0, array(new Subfield('0', 'valid')))));
$this->assertTrue($r->isValid()); $this->assertTrue($r->isValid());
} }
public function testSort () public function testSort ()
{ {
$r = new AuthorityRecord(array(new Field('003@', 99, array(new Subfield('0', 'valid'))), $r = new AuthorityRecord(array(new Field('003@', 99, array(new Subfield('0', 'valid'))),
new Field('003@', 0, array(new Subfield('0', 'valid'))))); new Field('003@', 0, array(new Subfield('0', 'valid')))));
...@@ -130,24 +130,20 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase ...@@ -130,24 +130,20 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase
/// ///
/** public function testAppendThrowsExceptionOnDuplicateField ()
* @expectedException InvalidArgumentException
*/
public function testAppendThrowsExceptionOnDuplicateField ()
{ {
$this->expectException('InvalidArgumentException');
$r = new AuthorityRecord(); $r = new AuthorityRecord();
$f = new Field('003@', 0); $f = new Field('003@', 0);
$r->append($f); $r->append($f);
$r->append($f); $r->append($f);
} }
/** public function testAppendThrowsExceptionOnInvalidLevel ()
* @expectedException InvalidArgumentException
*/
public function testAppendThrowsExceptionOnInvalidLevel ()
{ {
$this->expectException('InvalidArgumentException');
$r = new AuthorityRecord(); $r = new AuthorityRecord();
$r->append(new Field('101@', 0)); $r->append(new Field('101@', 0));
} }
} }
\ No newline at end of file
...@@ -20,15 +20,15 @@ ...@@ -20,15 +20,15 @@
* *
* @package PicaRecord * @package PicaRecord
* @author David Maus <maus@hab.de> * @author David Maus <maus@hab.de>
* @copyright Copyright (c) 2012, 2013 by Herzog August Bibliothek Wolfenbüttel * @copyright Copyright (c) 2012-2019 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3
*/ */
namespace HAB\Pica\Record; namespace HAB\Pica\Record;
use PHPUnit_FrameWork_TestCase; use PHPUnit\Framework\TestCase;
class CopyRecordTest extends PHPUnit_FrameWork_TestCase { class CopyRecordTest extends TestCase {
public function testGetEPN () public function testGetEPN ()
{ {
...@@ -60,20 +60,16 @@ class CopyRecordTest extends PHPUnit_FrameWork_TestCase { ...@@ -60,20 +60,16 @@ class CopyRecordTest extends PHPUnit_FrameWork_TestCase {
/// ///
/**
* @expectedException InvalidArgumentException
*/
public function testAppendThrowsExceptionOnInvalidFieldLevel () public function testAppendThrowsExceptionOnInvalidFieldLevel ()
{ {
$this->expectException('InvalidArgumentException');
$r = new CopyRecord(); $r = new CopyRecord();
$r->append(new Field('003@', 0)); $r->append(new Field('003@', 0));
} }
/**
* @expectedException InvalidArgumentException
*/
public function testAppendThrowsExceptionOnNumberMismatch () public function testAppendThrowsExceptionOnNumberMismatch ()
{ {
$this->expectException('InvalidArgumentException');
$r = new CopyRecord(); $r = new CopyRecord();
$r->append(new Field('201@', 0)); $r->append(new Field('201@', 0));
$r->append(new Field('202@', 1)); $r->append(new Field('202@', 1));
......
...@@ -20,15 +20,15 @@ ...@@ -20,15 +20,15 @@
* *
* @package PicaRecord * @package PicaRecord
* @author David Maus <maus@hab.de> * @author David Maus <maus@hab.de>
* @copyright Copyright (c) 2012, 2013 by Herzog August Bibliothek Wolfenbüttel * @copyright Copyright (c) 2012-2019 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3
*/ */
namespace HAB\Pica\Record; namespace HAB\Pica\Record;
use PHPUnit_FrameWork_TestCase; use PHPUnit\Framework\TestCase;
class FieldTest extends PHPUnit_FrameWork_TestCase class FieldTest extends TestCase
{ {
public function testValidFieldOccurrenceCastNull () { public function testValidFieldOccurrenceCastNull () {
...@@ -191,64 +191,50 @@ class FieldTest extends PHPUnit_FrameWork_TestCase ...@@ -191,64 +191,50 @@ class FieldTest extends PHPUnit_FrameWork_TestCase
/// ///
/**
* @expectedException InvalidArgumentException
*/
public function testFactoryThrowsExceptionOnMissingTagIndex () public function testFactoryThrowsExceptionOnMissingTagIndex ()
{ {
$this->expectException('InvalidArgumentException');
Field::factory(array('occurrence' => 10, 'subfields' => array())); Field::factory(array('occurrence' => 10, 'subfields' => array()));
} }
/**
* @expectedException InvalidArgumentException
*/
public function testFactoryThrowsExceptionOnMissingOccurrenceIndex () public function testFactoryThrowsExceptionOnMissingOccurrenceIndex ()
{ {
$this->expectException('InvalidArgumentException');
Field::factory(array('tag' => '003@', 'subfields' => array())); Field::factory(array('tag' => '003@', 'subfields' => array()));
} }
/**
* @expectedException InvalidArgumentException
*/
public function testFactoryThrowsExceptionOnMissingSubfieldIndex () public function testFactoryThrowsExceptionOnMissingSubfieldIndex ()
{ {
$this->expectException('InvalidArgumentException');
Field::factory(array('tag' => '003@', 'occurrence' => 10)); Field::factory(array('tag' => '003@', 'occurrence' => 10));
} }
/**
* @expectedException InvalidArgumentException
*/
public function testContructorThrowsExceptionOnInvalidTag () public function testContructorThrowsExceptionOnInvalidTag ()
{ {
$this->expectException('InvalidArgumentException');
new Field('invalid', 0); new Field('invalid', 0);
} }
/**
* @expectedException InvalidArgumentException
*/
public function testConstructorThrowsExceptionOnInvalidOccurrence () public function testConstructorThrowsExceptionOnInvalidOccurrence ()
{ {
$this->expectException('InvalidArgumentException');
new Field('003@', 1000); new Field('003@', 1000);
} }
/**
* @expectedException InvalidArgumentException
*/
public function testAddSubfieldThrowsExceptionOnDuplicateSubfield () public function testAddSubfieldThrowsExceptionOnDuplicateSubfield ()
{ {
$this->expectException('InvalidArgumentException');
$f = new Field('003@', 0); $f = new Field('003@', 0);
$s = new Subfield('a', 'valid'); $s = new Subfield('a', 'valid');
$f->addSubfield($s); $f->addSubfield($s);
$f->addSubfield($s); $f->addSubfield($s);
} }
/**
* @expectedException InvalidArgumentException
*/
public function testRemoveSubfieldThrowsExceptionOnNonExistentField () public function testRemoveSubfieldThrowsExceptionOnNonExistentField ()
{ {
$this->expectException('InvalidArgumentException');
$f = new Field('003@', 0); $f = new Field('003@', 0);
$s = new Subfield('a', 'valid'); $s = new Subfield('a', 'valid');
$f->removeSubfield($s); $f->removeSubfield($s);
} }
} }
\ No newline at end of file
...@@ -20,15 +20,15 @@ ...@@ -20,15 +20,15 @@
* *
* @package PicaRecord * @package PicaRecord
* @author David Maus <maus@hab.de> * @author David Maus <maus@hab.de>
* @copyright Copyright (c) 2012, 2013 by Herzog August Bibliothek Wolfenbüttel * @copyright Copyright (c) 2012-2019 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3
*/ */
namespace HAB\Pica\Record; namespace HAB\Pica\Record;
use PHPUnit_FrameWork_TestCase; use PHPUnit\Framework\TestCase;
class LocalRecordTest extends PHPUnit_FrameWork_TestCase class LocalRecordTest extends TestCase
{ {
public function testClone () public function testClone ()
...@@ -132,52 +132,42 @@ class LocalRecordTest extends PHPUnit_FrameWork_TestCase ...@@ -132,52 +132,42 @@ class LocalRecordTest extends PHPUnit_FrameWork_TestCase
/// ///
/**
* @expectedException InvalidArgumentException
*/
public function testAddCopyRecordThrowsExceptionOnItemNumberCollision () public function testAddCopyRecordThrowsExceptionOnItemNumberCollision ()
{ {
$this->expectException('InvalidArgumentException');
$r = new LocalRecord(); $r = new LocalRecord();
$r->addCopyRecord(new CopyRecord(array(new Field('200@', 11)))); $r->addCopyRecord(new CopyRecord(array(new Field('200@', 11))));
$r->addCopyRecord(new CopyRecord(array(new Field('200@', 11)))); $r->addCopyRecord(new CopyRecord(array(new Field('200@', 11))));
} }
/**
* @expectedException InvalidArgumentException
*/
public function testAddCopyRecordThrowsExceptionOnDuplicateCopyRecord () public function testAddCopyRecordThrowsExceptionOnDuplicateCopyRecord ()
{ {
$this->expectException('InvalidArgumentException');
$r = new LocalRecord(); $r = new LocalRecord();
$c = new CopyRecord(); $c = new CopyRecord();
$r->addCopyRecord($c); $r->addCopyRecord($c);
$r->addCopyRecord($c); $r->addCopyRecord($c);
} }
/**
* @expectedException InvalidArgumentException
*/
public function testRemoveCopyRecordThrowsExceptionOnCopyRecordNotContainedInRecord () public function testRemoveCopyRecordThrowsExceptionOnCopyRecordNotContainedInRecord ()
{ {
$this->expectException('InvalidArgumentException');
$r = new LocalRecord(); $r = new LocalRecord();
$c = new CopyRecord(); $c = new CopyRecord();
$r->removeCopyRecord($c); $r->removeCopyRecord($c);
} }
/**
* @expectedException InvalidArgumentException
*/
public function testAppendThrowsExceptionOnInvalidLevel () public function testAppendThrowsExceptionOnInvalidLevel ()
{ {
$this->expectException('InvalidArgumentException');
$r = new LocalRecord(); $r = new LocalRecord();
$r->append(new Field('003@', 0)); $r->append(new Field('003@', 0));
} }
/**
* @expectedException InvalidArgumentException
*/
public function testGetMaximumOccurrenceOfThrowsExceptionOnInvalidFieldTag () public function testGetMaximumOccurrenceOfThrowsExceptionOnInvalidFieldTag ()
{ {
$this->expectException('InvalidArgumentException');
$r = new LocalRecord(); $r = new LocalRecord();
$r->getMaximumOccurrenceOf('@@@@'); $r->getMaximumOccurrenceOf('@@@@');
} }
} }
\ No newline at end of file
...@@ -20,15 +20,15 @@ ...@@ -20,15 +20,15 @@
* *
* @package PicaRecord * @package PicaRecord
* @author David Maus <maus@hab.de> * @author David Maus <maus@hab.de>
* @copyright Copyright (c) 2012, 2013 by Herzog August Bibliothek Wolfenbüttel * @copyright Copyright (c) 2012-2019 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3
*/ */
namespace HAB\Pica\Record; namespace HAB\Pica\Record;
use PHPUnit_FrameWork_TestCase; use PHPUnit\Framework\TestCase;
class RecordTest extends PHPUnit_FrameWork_TestCase class RecordTest extends TestCase
{ {
public function testFactoryCreatesAuthorityRecord () public function testFactoryCreatesAuthorityRecord ()
...@@ -71,30 +71,25 @@ class RecordTest extends PHPUnit_FrameWork_TestCase ...@@ -71,30 +71,25 @@ class RecordTest extends PHPUnit_FrameWork_TestCase
/// ///
/**
* @expectedException InvalidArgumentException
*/
public