From d00c4d5d10b4bad1af00a83ae5a6e1ef3640d5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Michael=20O=2E=20Hegg=C3=B8?= Date: Tue, 27 Feb 2024 23:24:51 +0100 Subject: [PATCH] Fix dataproviders in tests --- tests/CollectionTest.php | 6 +++--- tests/ExamplesTest.php | 4 ++-- tests/RecordTest.php | 4 ++-- tests/TestCase.php | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/CollectionTest.php b/tests/CollectionTest.php index da44b6a..7fbd44b 100644 --- a/tests/CollectionTest.php +++ b/tests/CollectionTest.php @@ -35,7 +35,7 @@ public function testExceptionOnInvalidEncoding() * * @return array */ - public function mrcFiles() + public static function mrcFiles() { return [ ['sandburg.mrc', 1], // Single binary MARC file @@ -48,7 +48,7 @@ public function mrcFiles() * * @return array */ - public function xmlFiles() + public static function xmlFiles() { return [ ['oaipmh-bibsys.xml', 89], // Records encapsulated in OAI-PMH response @@ -86,7 +86,7 @@ public function testCollectionFromFile($filename, $expected) */ public function testInitializeFromSimpleXmlElement($filename, $expected) { - $el = simplexml_load_file($this->pathTo($filename)); + $el = simplexml_load_file(self::pathTo($filename)); $collection = Collection::fromSimpleXMLElement($el); diff --git a/tests/ExamplesTest.php b/tests/ExamplesTest.php index 48b84a3..e39c6f3 100644 --- a/tests/ExamplesTest.php +++ b/tests/ExamplesTest.php @@ -26,9 +26,9 @@ public function testExample($filename) } } - public function exampleDataProvider() + public static function exampleDataProvider() { - foreach (glob($this->pathTo('examples/*.xml')) as $filename) { + foreach (glob(self::pathTo('examples/*.xml')) as $filename) { yield [$filename]; } } diff --git a/tests/RecordTest.php b/tests/RecordTest.php index 2ae4f36..5649756 100644 --- a/tests/RecordTest.php +++ b/tests/RecordTest.php @@ -71,13 +71,13 @@ public function testExampleWithCustomPrefix() public function testBinaryMarc() { - $record = Record::fromFile($this->pathTo('binary-marc.mrc')); + $record = Record::fromFile(self::pathTo('binary-marc.mrc')); $this->assertInstanceOf(Record::class, $record); } public function testThatFieldObjectsAreReturned() { - $record = Record::fromFile($this->pathTo('binary-marc.mrc')); + $record = Record::fromFile(self::pathTo('binary-marc.mrc')); $this->assertInstanceOf(Field::class, $record->getField('020')); $this->assertInstanceOf(Field::class, $record->getFields('020')[0]); } diff --git a/tests/TestCase.php b/tests/TestCase.php index 650969c..bc74f15 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -7,14 +7,14 @@ class TestCase extends \PHPUnit\Framework\TestCase { - protected function pathTo($filename) + protected static function pathTo($filename) { return __DIR__ . '/data/' . $filename; } protected function getTestCollection($filename) { - return Collection::fromFile($this->pathTo($filename)); + return Collection::fromFile(self::pathTo($filename)); } protected function getNthrecord($filename, $n)