From ce878d6e4c5e9793c489547fbe2251608809145e Mon Sep 17 00:00:00 2001 From: David Maus <dmaus@dmaus.name> Date: Tue, 16 Apr 2019 08:23:52 +0200 Subject: [PATCH] Update tests to use PHPUnit 8 --- composer.json | 3 ++ phpunit.xml | 6 +-- .../HAB/Pica/Record/AuthorityRecordTest.php | 44 +++++++++---------- .../src/HAB/Pica/Record/CopyRecordTest.php | 14 +++--- .../src/HAB/Pica/Record/FieldTest.php | 36 +++++---------- .../src/HAB/Pica/Record/LocalRecordTest.php | 28 ++++-------- .../src/HAB/Pica/Record/RecordTest.php | 21 ++++----- .../src/HAB/Pica/Record/SubfieldTest.php | 20 +++------ .../src/HAB/Pica/Record/TitleRecordTest.php | 6 +-- 9 files changed, 67 insertions(+), 111 deletions(-) diff --git a/composer.json b/composer.json index 8e4fa7a..05c3a2b 100644 --- a/composer.json +++ b/composer.json @@ -17,5 +17,8 @@ "psr-0": { "HAB\\Pica": "src/" } + }, + "require-dev": { + "phpunit/phpunit": "^8" } } diff --git a/phpunit.xml b/phpunit.xml index 50449de..af648d8 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,15 +1,11 @@ <?xml version="1.0" encoding="utf-8"?> -<phpunit bootstrap="tests/unit-tests/bootstrap.php" strict="true"> +<phpunit bootstrap="tests/unit-tests/bootstrap.php"> <testsuites> <testsuite name="Unit Tests"> <directory suffix="Test.php">tests</directory> </testsuite> </testsuites> <filter> - <blacklist> - <directory suffix=".php">vendor</directory> - <directory suffix=".php">tests</directory> - </blacklist> <whitelist addUncoveredFilesFromWhitelist="true"> <directory suffix=".php">bin</directory> <directory suffix=".php">src</directory> diff --git a/tests/unit-tests/src/HAB/Pica/Record/AuthorityRecordTest.php b/tests/unit-tests/src/HAB/Pica/Record/AuthorityRecordTest.php index 4d1f732..57f52a0 100644 --- a/tests/unit-tests/src/HAB/Pica/Record/AuthorityRecordTest.php +++ b/tests/unit-tests/src/HAB/Pica/Record/AuthorityRecordTest.php @@ -20,33 +20,33 @@ * * @package PicaRecord * @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 */ 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(); $this->assertTrue($r->isEmpty()); } - public function testAppend () + public function testAppend () { $r = new AuthorityRecord(); $r->append(new Field('000@', 0, array(new Subfield('0', 'valid')))); $this->assertFalse($r->isEmpty()); } - public function testGetPPN () + public function testGetPPN () { $r = new AuthorityRecord(); $this->assertNull($r->getPPN()); @@ -54,7 +54,7 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase $this->assertEquals('valid', $r->getPPN()); } - public function testDelete () + public function testDelete () { $r = new AuthorityRecord(); $r->append(new Field('003@', 0, array(new Subfield('0', 'valid')))); @@ -65,7 +65,7 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase /// - public function testSetPPN () + public function testSetPPN () { $r = new AuthorityRecord(); $this->assertNull($r->getPPN()); @@ -76,7 +76,7 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase $this->assertEquals(1, count($r->getFields('003@/00'))); } - public function testClone () + public function testClone () { $r = new AuthorityRecord(); $f = new Field('003@', 0); @@ -87,38 +87,38 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase $this->assertNotSame($f, reset($fields)); } - public function testIsInvalidEmptyField () + public function testIsInvalidEmptyField () { $r = new AuthorityRecord(array(new Field('003@', 0))); $this->assertFalse($r->isValid()); } - public function testIsInvalidMissingPPN () + public function testIsInvalidMissingPPN () { $r = new AuthorityRecord(array(new Field('002@', 0, array(new Subfield('0', 'T'))))); $this->assertFalse($r->isValid()); } - public function testIsInvalidMissingType () + public function testIsInvalidMissingType () { $r = new AuthorityRecord(array(new Field('003@', 0, array(new Subfield('0', 'something'))))); $this->assertFalse($r->isValid()); } - public function testIsInvalidWrongType () + public function testIsInvalidWrongType () { $r = new AuthorityRecord(array(new Field('002@', 0, array(new Subfield('0', 'A'))))); $this->assertFalse($r->isValid()); } - public function testIsValid () + public function testIsValid () { $r = new AuthorityRecord(array(new Field('002@', 0, array(new Subfield('0', 'T'))), new Field('003@', 0, array(new Subfield('0', 'valid'))))); $this->assertTrue($r->isValid()); } - public function testSort () + public function testSort () { $r = new AuthorityRecord(array(new Field('003@', 99, array(new Subfield('0', 'valid'))), new Field('003@', 0, array(new Subfield('0', 'valid'))))); @@ -130,24 +130,20 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase /// - /** - * @expectedException InvalidArgumentException - */ - public function testAppendThrowsExceptionOnDuplicateField () + public function testAppendThrowsExceptionOnDuplicateField () { + $this->expectException('InvalidArgumentException'); $r = new AuthorityRecord(); $f = new Field('003@', 0); $r->append($f); $r->append($f); } - /** - * @expectedException InvalidArgumentException - */ - public function testAppendThrowsExceptionOnInvalidLevel () + public function testAppendThrowsExceptionOnInvalidLevel () { + $this->expectException('InvalidArgumentException'); $r = new AuthorityRecord(); $r->append(new Field('101@', 0)); } -} \ No newline at end of file +} diff --git a/tests/unit-tests/src/HAB/Pica/Record/CopyRecordTest.php b/tests/unit-tests/src/HAB/Pica/Record/CopyRecordTest.php index 7f2ad1e..d4f1407 100644 --- a/tests/unit-tests/src/HAB/Pica/Record/CopyRecordTest.php +++ b/tests/unit-tests/src/HAB/Pica/Record/CopyRecordTest.php @@ -20,15 +20,15 @@ * * @package PicaRecord * @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 */ 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 () { @@ -60,20 +60,16 @@ class CopyRecordTest extends PHPUnit_FrameWork_TestCase { /// - /** - * @expectedException InvalidArgumentException - */ public function testAppendThrowsExceptionOnInvalidFieldLevel () { + $this->expectException('InvalidArgumentException'); $r = new CopyRecord(); $r->append(new Field('003@', 0)); } - /** - * @expectedException InvalidArgumentException - */ public function testAppendThrowsExceptionOnNumberMismatch () { + $this->expectException('InvalidArgumentException'); $r = new CopyRecord(); $r->append(new Field('201@', 0)); $r->append(new Field('202@', 1)); diff --git a/tests/unit-tests/src/HAB/Pica/Record/FieldTest.php b/tests/unit-tests/src/HAB/Pica/Record/FieldTest.php index 6fc57c7..773530f 100644 --- a/tests/unit-tests/src/HAB/Pica/Record/FieldTest.php +++ b/tests/unit-tests/src/HAB/Pica/Record/FieldTest.php @@ -20,15 +20,15 @@ * * @package PicaRecord * @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 */ 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 () { @@ -191,64 +191,50 @@ class FieldTest extends PHPUnit_FrameWork_TestCase /// - /** - * @expectedException InvalidArgumentException - */ public function testFactoryThrowsExceptionOnMissingTagIndex () { + $this->expectException('InvalidArgumentException'); Field::factory(array('occurrence' => 10, 'subfields' => array())); } - /** - * @expectedException InvalidArgumentException - */ public function testFactoryThrowsExceptionOnMissingOccurrenceIndex () { + $this->expectException('InvalidArgumentException'); Field::factory(array('tag' => '003@', 'subfields' => array())); } - /** - * @expectedException InvalidArgumentException - */ public function testFactoryThrowsExceptionOnMissingSubfieldIndex () { + $this->expectException('InvalidArgumentException'); Field::factory(array('tag' => '003@', 'occurrence' => 10)); } - /** - * @expectedException InvalidArgumentException - */ public function testContructorThrowsExceptionOnInvalidTag () { + $this->expectException('InvalidArgumentException'); new Field('invalid', 0); } - /** - * @expectedException InvalidArgumentException - */ public function testConstructorThrowsExceptionOnInvalidOccurrence () { + $this->expectException('InvalidArgumentException'); new Field('003@', 1000); } - /** - * @expectedException InvalidArgumentException - */ public function testAddSubfieldThrowsExceptionOnDuplicateSubfield () { + $this->expectException('InvalidArgumentException'); $f = new Field('003@', 0); $s = new Subfield('a', 'valid'); $f->addSubfield($s); $f->addSubfield($s); } - /** - * @expectedException InvalidArgumentException - */ public function testRemoveSubfieldThrowsExceptionOnNonExistentField () { + $this->expectException('InvalidArgumentException'); $f = new Field('003@', 0); $s = new Subfield('a', 'valid'); $f->removeSubfield($s); } -} \ No newline at end of file +} diff --git a/tests/unit-tests/src/HAB/Pica/Record/LocalRecordTest.php b/tests/unit-tests/src/HAB/Pica/Record/LocalRecordTest.php index c26199a..d2882b0 100644 --- a/tests/unit-tests/src/HAB/Pica/Record/LocalRecordTest.php +++ b/tests/unit-tests/src/HAB/Pica/Record/LocalRecordTest.php @@ -20,15 +20,15 @@ * * @package PicaRecord * @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 */ 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 () @@ -132,52 +132,42 @@ class LocalRecordTest extends PHPUnit_FrameWork_TestCase /// - /** - * @expectedException InvalidArgumentException - */ public function testAddCopyRecordThrowsExceptionOnItemNumberCollision () { + $this->expectException('InvalidArgumentException'); $r = new LocalRecord(); $r->addCopyRecord(new CopyRecord(array(new Field('200@', 11)))); $r->addCopyRecord(new CopyRecord(array(new Field('200@', 11)))); } - /** - * @expectedException InvalidArgumentException - */ public function testAddCopyRecordThrowsExceptionOnDuplicateCopyRecord () { + $this->expectException('InvalidArgumentException'); $r = new LocalRecord(); $c = new CopyRecord(); $r->addCopyRecord($c); $r->addCopyRecord($c); } - /** - * @expectedException InvalidArgumentException - */ public function testRemoveCopyRecordThrowsExceptionOnCopyRecordNotContainedInRecord () { + $this->expectException('InvalidArgumentException'); $r = new LocalRecord(); $c = new CopyRecord(); $r->removeCopyRecord($c); } - /** - * @expectedException InvalidArgumentException - */ public function testAppendThrowsExceptionOnInvalidLevel () { + $this->expectException('InvalidArgumentException'); $r = new LocalRecord(); $r->append(new Field('003@', 0)); } - /** - * @expectedException InvalidArgumentException - */ public function testGetMaximumOccurrenceOfThrowsExceptionOnInvalidFieldTag () { + $this->expectException('InvalidArgumentException'); $r = new LocalRecord(); $r->getMaximumOccurrenceOf('@@@@'); } -} \ No newline at end of file +} diff --git a/tests/unit-tests/src/HAB/Pica/Record/RecordTest.php b/tests/unit-tests/src/HAB/Pica/Record/RecordTest.php index f6f2b33..954733c 100644 --- a/tests/unit-tests/src/HAB/Pica/Record/RecordTest.php +++ b/tests/unit-tests/src/HAB/Pica/Record/RecordTest.php @@ -20,15 +20,15 @@ * * @package PicaRecord * @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 */ 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 () @@ -71,30 +71,25 @@ class RecordTest extends PHPUnit_FrameWork_TestCase /// - /** - * @expectedException InvalidArgumentException - */ + public function testFactoryThrowsExceptionOnMissingFieldsIndex () { + $this->expectException('InvalidArgumentException'); Record::factory(array()); } - /** - * @expectedException InvalidArgumentException - */ public function testFactoryThrowsExceptionOnMissingTypeField () { + $this->expectException('InvalidArgumentException'); $record = Record::factory(array('fields' => array())); } - /** - * @expectedException InvalidArgumentException - */ public function testFactoryThrowsExceptionOnMissingTypeSubfield () { + $this->expectException('InvalidArgumentException'); $record = Record::factory(array('fields' => array( array('tag' => '002@', 'occurrence' => 0, 'subfields' => array())))); } -} \ No newline at end of file +} diff --git a/tests/unit-tests/src/HAB/Pica/Record/SubfieldTest.php b/tests/unit-tests/src/HAB/Pica/Record/SubfieldTest.php index d398b39..d7ba59b 100644 --- a/tests/unit-tests/src/HAB/Pica/Record/SubfieldTest.php +++ b/tests/unit-tests/src/HAB/Pica/Record/SubfieldTest.php @@ -20,15 +20,15 @@ * * @package PicaRecord * @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 */ namespace HAB\Pica\Record; -use PHPUnit_FrameWork_TestCase; +use PHPUnit\Framework\TestCase; -class SubfieldTest extends PHPUnit_FrameWork_TestCase +class SubfieldTest extends TestCase { public function testValidSubfieldCodeZero () @@ -70,28 +70,22 @@ class SubfieldTest extends PHPUnit_FrameWork_TestCase /// - /** - * @expectedException InvalidArgumentException - */ public function testConstructorThrowsExceptionOnInvalidCode () { + $this->expectException('InvalidArgumentException'); new Subfield(null, 'valid'); } - /** - * @expectedException InvalidArgumentException - */ public function testFactoryThrowsExceptionOnMissingCodeIndex () { + $this->expectException('InvalidArgumentException'); Subfield::factory(array('value' => 'valid')); } - /** - * @expectedException InvalidArgumentException - */ public function testFactoryThrowsExceptionOnMissingValueIndex () { + $this->expectException('InvalidArgumentException'); Subfield::factory(array('code' => 'a')); } -} \ No newline at end of file +} diff --git a/tests/unit-tests/src/HAB/Pica/Record/TitleRecordTest.php b/tests/unit-tests/src/HAB/Pica/Record/TitleRecordTest.php index 8a06fcb..5cb798a 100644 --- a/tests/unit-tests/src/HAB/Pica/Record/TitleRecordTest.php +++ b/tests/unit-tests/src/HAB/Pica/Record/TitleRecordTest.php @@ -20,15 +20,15 @@ * * @package PicaRecord * @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 */ namespace HAB\Pica\Record; -use PHPUnit_FrameWork_TestCase; +use PHPUnit\Framework\TestCase; -class TitleRecordTest extends PHPUnit_FrameWork_TestCase +class TitleRecordTest extends TestCase { public function testAppend () -- GitLab