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

Update tests to use PHPUnit 8

parent 4e14d420
......@@ -17,5 +17,8 @@
"psr-0": {
"HAB\\Pica": "src/"
}
},
"require-dev": {
"phpunit/phpunit": "^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>
<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>
......
......@@ -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
}
......@@ -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));
......
......@@ -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
}
......@@ -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
}
......@@ -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
}
......@@ -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
}
......@@ -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 ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment