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,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 AuthorityRecordTest extends PHPUnit_FrameWork_TestCase
class AuthorityRecordTest extends TestCase
{
///
......@@ -130,22 +130,18 @@ class AuthorityRecordTest extends PHPUnit_FrameWork_TestCase
///
/**
* @expectedException InvalidArgumentException
*/
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 ()
{
$this->expectException('InvalidArgumentException');
$r = new AuthorityRecord();
$r->append(new Field('101@', 0));
}
......
......@@ -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,62 +191,48 @@ 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);
......
......@@ -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,51 +132,41 @@ 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('@@@@');
}
......
......@@ -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,27 +71,22 @@ 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,
......
......@@ -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,27 +70,21 @@ 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'));
}
......
......@@ -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