Skip to content

Commit

Permalink
test: Remove file_get_contents override and incorrect/invaluable tests
Browse files Browse the repository at this point in the history
Overriding file_get_contents introduces different behaviour from the native function, such as the $http_response_headers missing. Removing the override revealed two test (testing a specific return path of the file_get_contents method rather then testing the behaviour or result of the subject under test) which had different behaviour between the test and runtime, therefor these tests have been removed.
  • Loading branch information
DannyvdSluijs committed May 26, 2024
1 parent b7475c0 commit e6ea522
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions tests/Uri/Retrievers/FileGetContentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,6 @@ public function testFetchFile()
$this->assertNotEmpty($result);
}

public function testFalseReturn()
{
$res = new FileGetContents();

$this->setExpectedException(
'\JsonSchema\Exception\ResourceNotFoundException',
'JSON schema not found at http://example.com/false'
);
$res->retrieve('http://example.com/false');
}

public function testFetchDirectory()
{
$res = new FileGetContents();

$this->setExpectedException(
'\JsonSchema\Exception\ResourceNotFoundException',
'JSON schema not found at file:///this/is/a/directory/'
);
$res->retrieve('file:///this/is/a/directory/');
}

public function testContentType()
{
$res = new FileGetContents();
Expand All @@ -70,15 +48,3 @@ public function testCanHandleHttp301PermanentRedirect()
}
}
}

namespace JsonSchema\Uri\Retrievers
{
function file_get_contents($uri)
{
switch ($uri) {
case 'http://example.com/false': return false;
case 'file:///this/is/a/directory/': return '';
default: return \file_get_contents($uri);
}
}
}

0 comments on commit e6ea522

Please sign in to comment.