Skip to content

Commit

Permalink
Updating PHPUnit Test that should have been updated in the PHP 7.4 me…
Browse files Browse the repository at this point in the history
…rge. (ubccr#1873)

* Missed this somehow

* Update tests/unit/lib/ETL/Configuration/JsonReferenceWithFallbackTest.php

Co-authored-by: Aaron Weeden <31246768+aaronweeden@users.noreply.github.com>

* Update tests/unit/lib/ETL/Configuration/JsonReferenceWithFallbackTest.php

Co-authored-by: Aaron Weeden <31246768+aaronweeden@users.noreply.github.com>

* Update tests/unit/lib/ETL/Configuration/JsonReferenceWithFallbackTest.php

Co-authored-by: Aaron Weeden <31246768+aaronweeden@users.noreply.github.com>

---------

Co-authored-by: Aaron Weeden <31246768+aaronweeden@users.noreply.github.com>
  • Loading branch information
2 people authored and ShixinWu16 committed Jun 28, 2024
1 parent 238f61f commit b5efdf1
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions tests/unit/lib/ETL/Configuration/JsonReferenceWithFallbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
use CCR\Log;
use Configuration\Configuration;
use Configuration\JsonReferenceWithFallbackTransformer;
use Exception;
use PHPUnit\Framework\TestCase;

class JsonReferenceWithFallbackTest extends \PHPUnit_Framework_TestCase
class JsonReferenceWithFallbackTest extends TestCase
{

const TEST_ARTIFACT_INPUT_PATH = "./../artifacts/xdmod/etlv2/configuration/input";
Expand All @@ -17,7 +19,7 @@ class JsonReferenceWithFallbackTest extends \PHPUnit_Framework_TestCase
protected static $transformer = null;
protected static $config = null;

public static function setupBeforeClass()
public static function setupBeforeClass(): void
{
// Set up a logger so we can get warnings and error messages from the ETL infrastructure
$conf = array(
Expand All @@ -33,12 +35,10 @@ public static function setupBeforeClass()
self::$transformer = new JsonReferenceWithFallbackTransformer($logger);
}

/**
* @expectedException Exception
* @expectedExceptionMessage References cannot be mixed with other keys in an object: "$ref-with-fallback"
*/
public function testMixedRefs()
{
$this->expectExceptionMessage('References cannot be mixed with other keys in an object: "$ref-with-fallback"');
$this->expectException(Exception::class);
$this->runTransformTest([self::VALID_FILE], null, ['foo' => 'bar']);
}

Expand All @@ -53,11 +53,11 @@ private function runTransformTest($value, $expected = null, $additionalKeys = []

/**
* @dataProvider provideInvalidValue
* @expectedException Exception
* @expectedExceptionMessage Value of "$ref-with-fallback" must be a non-empty, non-associative array of strings
*/
public function testInvalidValue($value)
{
$this->expectExceptionMessage('Value of "$ref-with-fallback" must be a non-empty, non-associative array of strings');
$this->expectException(Exception::class);
$this->runTransformTest($value);
}

Expand All @@ -77,11 +77,11 @@ public function provideInvalidValue()

/**
* @dataProvider provideLastFileDNE
* @expectedException Exception
* @expectedExceptionMessageRegExp /Failed to open file '[^']+file_does_not_exist.txt': file_get_contents\([^)]+\): failed to open stream: No such file or directory/
*/
public function testLastFileDNE($value)
{
$this->expectExceptionMessageMatches("/Failed to open file '[^']+file_does_not_exist.txt': file_get_contents\([^)]+\): failed to open stream: No such file or directory/");
$this->expectException(Exception::class);
$this->runTransformTest($value);
}

Expand All @@ -96,11 +96,11 @@ public function provideLastFileDNE()

/**
* @dataProvider provideLastFileBadUrl
* @expectedException Exception
* @expectedExceptionMessage Unable to extract path from URL: badscheme://string
*/
public function testLastFileBadUrl($value)
{
$this->expectExceptionMessage("Unable to extract path from URL: badscheme://string");
$this->expectException(Exception::class);
$this->runTransformTest($value);
}

Expand All @@ -113,12 +113,10 @@ public function provideLastFileBadUrl()
];
}

/**
* @expectedException Exception
* @expectedExceptionMessage JSON pointer '/invalid_pointer' references a nonexistent value in file rfc6901.json
*/
public function testInvalidPointer()
{
$this->expectExceptionMessage("JSON pointer '/invalid_pointer' references a nonexistent value in file rfc6901.json");
$this->expectException(Exception::class);
$this->runTransformTest([self::VALID_FILE . '#/invalid_pointer']);
}

Expand Down Expand Up @@ -153,12 +151,10 @@ public function provideSuccess()
];
}

/**
* @expectedException Exception
* @expectedExceptionMessage Undefined macros in URL reference: FILE_EXTENSION in string 'rfc6901.${FILE_EXTENSION}#/bar'
*/
public function testUndefinedVariable()
{
$this->expectExceptionMessage("Undefined macros in URL reference: FILE_EXTENSION in string 'rfc6901.\${FILE_EXTENSION}#/bar'");
$this->expectException(Exception::class);
self::$config->getVariableStore()->FILENAME = 'rfc6901';

$this->runTransformTest(['${FILENAME}.${FILE_EXTENSION}#/bar']);
Expand Down

0 comments on commit b5efdf1

Please sign in to comment.