Skip to content

Commit

Permalink
style: Correct code style violations
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyvdSluijs committed May 26, 2024
1 parent 4479f6e commit 4f0e8f2
Showing 1 changed file with 41 additions and 42 deletions.
83 changes: 41 additions & 42 deletions tests/Uri/Retrievers/FileGetContentsTest.php
Original file line number Diff line number Diff line change
@@ -1,50 +1,49 @@
<?php

namespace JsonSchema\Tests\Uri\Retrievers
{
use JsonSchema\Uri\Retrievers\FileGetContents;
use PHPUnit\Framework\TestCase;
namespace JsonSchema\Tests\Uri\Retrievers;

use JsonSchema\Uri\Retrievers\FileGetContents;
use PHPUnit\Framework\TestCase;

/**
* @group FileGetContents
*/
class FileGetContentsTest extends TestCase
{
/**
* @group FileGetContents
* @expectedException \JsonSchema\Exception\ResourceNotFoundException
*/
class FileGetContentsTest extends TestCase
public function testFetchMissingFile()
{
$res = new FileGetContents();
$res->retrieve(__DIR__ . '/Fixture/missing.json');
}

public function testFetchFile()
{
$res = new FileGetContents();
$result = $res->retrieve(__DIR__ . '/../Fixture/child.json');
$this->assertNotEmpty($result);
}

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

$reflector = new \ReflectionObject($res);
$fetchContentType = $reflector->getMethod('fetchContentType');
$fetchContentType->setAccessible(true);

$this->assertTrue($fetchContentType->invoke($res, array('Content-Type: application/json')));
$this->assertFalse($fetchContentType->invoke($res, array('X-Some-Header: whateverValue')));
}

public function testCanHandleHttp301PermanentRedirect()
{
/**
* @expectedException \JsonSchema\Exception\ResourceNotFoundException
*/
public function testFetchMissingFile()
{
$res = new FileGetContents();
$res->retrieve(__DIR__ . '/Fixture/missing.json');
}

public function testFetchFile()
{
$res = new FileGetContents();
$result = $res->retrieve(__DIR__ . '/../Fixture/child.json');
$this->assertNotEmpty($result);
}

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

$reflector = new \ReflectionObject($res);
$fetchContentType = $reflector->getMethod('fetchContentType');
$fetchContentType->setAccessible(true);

$this->assertTrue($fetchContentType->invoke($res, array('Content-Type: application/json')));
$this->assertFalse($fetchContentType->invoke($res, array('X-Some-Header: whateverValue')));
}

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

$res->retrieve('http://asyncapi.com/definitions/2.0.0/asyncapi.json');

$this->assertSame('application/schema+json', $res->getContentType());
}
$res = new FileGetContents();

$res->retrieve('http://asyncapi.com/definitions/2.0.0/asyncapi.json');

$this->assertSame('application/schema+json', $res->getContentType());
}
}

0 comments on commit 4f0e8f2

Please sign in to comment.