Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Commit

Permalink
fixes #66 (#293)
Browse files Browse the repository at this point in the history
* fixes #66

* rename and added some classes

* added displayer | changed make to create

* Added config trait | added uuid | added tests | refator handler

* update to http-status v2

* added test for ExceptionInfo

* fixed contract and class

* adding handler tests

* remove shouldReport

* Added more tests

* Scrutinizer Auto-Fixes (#295)

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com

* added more tests

* Added filter

* Scrutinizer Auto-Fixes (#296)

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com

* added more test | add CommandLineTransformer

* rename test to tests

* Scrutinizer Auto-Fixes (#297)

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com

* update tests

* added more tests

* update phpdoc | changed classes
  • Loading branch information
prisis authored Jun 23, 2016
1 parent 65e4621 commit bf9938e
Show file tree
Hide file tree
Showing 86 changed files with 2,450 additions and 1,186 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@
"league/flysystem" : "^1.0",
"monolog/monolog" : "^1.17",
"narrowspark/arr" : "^1.0",
"narrowspark/http-status" : "^1.1",
"narrowspark/http-status" : "^2.0",
"php-di/invoker" : "^1.3",
"mpoiriert/invoker" : "^1.1",
"nesbot/carbon" : "^1.21",
"nikic/fast-route" : "^0.6",
"ramsey/uuid" : "^3.4",
"paragonie/constant_time_encoding" : "^2.0",
"paragonie/password_lock" : "^3.0",
"psr/cache" : "^1.0",
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
<testsuite name="Narrowspark Events Component Test Suite">
<directory>./src/Viserio/Events/Tests</directory>
</testsuite>
<!-- <testsuite name="Narrowspark Exception Component Test Suite">
<testsuite name="Narrowspark Exception Component Test Suite">
<directory>./src/Viserio/Exception/Tests</directory>
</testsuite> -->
</testsuite>
<testsuite name="Narrowspark Filesystem Component Test Suite">
<directory>./src/Viserio/Filesystem/Tests</directory>
</testsuite>
Expand Down
2 changes: 1 addition & 1 deletion src/Viserio/Config/Tests/ConfigManagerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Viserio\Config\Test;
namespace Viserio\Config\Tests;

use org\bovigo\vfs\vfsStream;
use Viserio\Config\Manager as ConfigManager;
Expand Down
2 changes: 1 addition & 1 deletion src/Viserio/Config/Tests/RepositoryTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Viserio\Config\Test;
namespace Viserio\Config\Tests;

use Viserio\Config\Repository;

Expand Down
18 changes: 18 additions & 0 deletions src/Viserio/Config/Tests/Traits/ConfigAwareTraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
namespace Viserio\Config\Tests\Traits;

use Viserio\Config\Manager as ConfigManager;
use Viserio\Config\Repository;
use Viserio\Config\Traits\ConfigAwareTrait;

class ConfigAwareTraitTest extends \PHPUnit_Framework_TestCase
{
use ConfigAwareTrait;

public function testSetAndGetConfig()
{
$this->setConfig(new ConfigManager(new Repository()));

$this->assertInstanceOf(ConfigManager::class, $this->getConfig());
}
}
45 changes: 45 additions & 0 deletions src/Viserio/Config/Traits/ConfigAwareTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
namespace Viserio\Config\Traits;

use RuntimeException;
use Viserio\Contracts\Config\Manager as ConfigManagerContract;

trait ConfigAwareTrait
{
/**
* The config instance.
*
* @var \Viserio\Contracts\Config\Manager
*/
protected $config;

/**
* Set a config instance.
*
* @param \Viserio\Contracts\Config\Manager $config
*
* @return self
*/
public function setConfig(ConfigManagerContract $config): self
{
$this->config = $config;

return $this;
}

/**
* Get the config.
*
* @throws \RuntimeException
*
* @return \Viserio\Contracts\Config\Manager
*/
public function getConfig(): ConfigManagerContract
{
if (! $this->config) {
throw new RuntimeException('Config is not set up.');
}

return $this->config;
}
}
2 changes: 1 addition & 1 deletion src/Viserio/Container/Tests/ContainerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Viserio\Container\Test;
namespace Viserio\Container\Tests;

use Viserio\Container\Container;

Expand Down
54 changes: 27 additions & 27 deletions src/Viserio/Container/Tests/DefinitionTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Viserio\Container\Test;
namespace Viserio\Container\Tests;

use Viserio\Container\Container;
use Viserio\Container\Definition;
Expand Down Expand Up @@ -31,15 +31,15 @@ public function setUp()
*/
public function testConstruct()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Qux');
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Qux');
$this->assertAttributeInstanceOf(
'Viserio\\Container\\Container',
'container',
$definition,
'The passed container name should be assigned to the $container property.'
);
$this->assertAttributeEquals(
'Viserio\\Test\\Container\\Qux',
'Viserio\\Tests\\Container\\Qux',
'class',
$definition,
'The passed class name should be assigned to the $class property.'
Expand All @@ -51,10 +51,10 @@ public function testConstruct()
*/
public function testInvokeNoArgsOrMethodCalls()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Qux');
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Qux');
$instance = $definition();
$this->assertInstanceOf(
'Viserio\\Test\\Container\\Qux',
'Viserio\\Tests\\Container\\Qux',
$instance,
'Invoking the Definition class should return an instance of the class $class.'
);
Expand All @@ -65,22 +65,22 @@ public function testInvokeNoArgsOrMethodCalls()
*/
public function testInvokeWithArgs()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Foo');
$definition->withArgument('Viserio\\Test\\Container\\Bar')->withArgument('Viserio\\Test\\Container\\Baz');
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Foo');
$definition->withArgument('Viserio\\Tests\\Container\\Bar')->withArgument('Viserio\\Tests\\Container\\Baz');
$instance = $definition();
$this->assertInstanceOf(
'Viserio\\Test\\Container\\Foo',
'Viserio\\Tests\\Container\\Foo',
$instance,
'Invoking a Definition should return an instance of the class defined in the $class property.'
);
$this->assertAttributeInstanceOf(
'Viserio\\Test\\Container\\Bar',
'Viserio\\Tests\\Container\\Bar',
'bar',
$instance,
'Invoking a Definition with arguments assigned should pass those args to the method.'
);
$this->assertAttributeInstanceOf(
'Viserio\\Test\\Container\\Baz',
'Viserio\\Tests\\Container\\Baz',
'baz',
$instance,
'Invoking a Definition with arguments assigned should pass those args to the method.'
Expand All @@ -93,8 +93,8 @@ public function testInvokeWithArgs()
public function testInvokeWithInheritedArgs()
{
$int = rand(1, 5000);
$this->container->bind('Viserio\\Test\\Container\\CorgeInterface')->withArgument($int);
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Corge');
$this->container->bind('Viserio\\Tests\\Container\\CorgeInterface')->withArgument($int);
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Corge');
$instance = $definition();
$this->assertAttributeEquals(
$int,
Expand All @@ -109,11 +109,11 @@ public function testInvokeWithInheritedArgs()
*/
public function testInvokeWithIntegerAsArg()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Corge');
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Corge');
$definition->withArgument(1);
$instance = $definition();
$this->assertInstanceOf(
'Viserio\\Test\\Container\\Corge',
'Viserio\\Tests\\Container\\Corge',
$instance,
'Invoking a Definition should return an instance of the class defined in the $class property.'
);
Expand All @@ -130,16 +130,16 @@ public function testInvokeWithIntegerAsArg()
*/
public function testInvokeWithMethodCall()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Qux');
$definition->withMethodCall('setBar', ['Viserio\\Test\\Container\\Bar']);
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Qux');
$definition->withMethodCall('setBar', ['Viserio\\Tests\\Container\\Bar']);
$instance = $definition();
$this->assertInstanceOf(
'Viserio\\Test\\Container\\Qux',
'Viserio\\Tests\\Container\\Qux',
$instance,
'Invoking a Definition should return an instance of the class defined in the $class property.'
);
$this->assertAttributeInstanceOf(
'Viserio\\Test\\Container\\Bar',
'Viserio\\Tests\\Container\\Bar',
'bar',
$instance,
'Invoking a Definition with a defined method call pass the defined args to the method.'
Expand All @@ -152,9 +152,9 @@ public function testInvokeWithMethodCall()
public function testInvokeWithInheritedMethodCall()
{
$int = rand(1, 5000);
$this->container->bind('Viserio\\Test\\Container\\CorgeInterface')
$this->container->bind('Viserio\\Tests\\Container\\CorgeInterface')
->withMethodCall('setInt', [$int]);
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Corge');
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Corge');
$instance = $definition();
$this->assertAttributeEquals(
$int,
Expand All @@ -169,7 +169,7 @@ public function testInvokeWithInheritedMethodCall()
*/
public function testWithArgument()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Foo');
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Foo');
$definition->withArgument('foo');
$this->assertAttributeContains(
'foo',
Expand All @@ -184,7 +184,7 @@ public function testWithArgument()
*/
public function testAddIntegerArg()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Foo');
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Foo');
$definition->withArgument(1);
$args = $this->readAttribute($definition, 'arguments');
$this->assertEquals(
Expand All @@ -199,7 +199,7 @@ public function testAddIntegerArg()
*/
public function testWithArguments()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Foo');
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Foo');
$definition->withArguments(['foo', 'bar']);
$this->assertAttributeEquals(
['foo', 'bar'],
Expand All @@ -214,7 +214,7 @@ public function testWithArguments()
*/
public function testCleanArgs()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Foo');
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Foo');
$definition->withArguments(['foo', 'bar']);
$definition->cleanArgument();
$this->assertAttributeEquals(
Expand All @@ -227,8 +227,8 @@ public function testCleanArgs()

public function testWithMethod()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Qux');
$definition->withMethodCall('setBar', ['Viserio\\Test\\Container\\Bar']);
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Qux');
$definition->withMethodCall('setBar', ['Viserio\\Tests\\Container\\Bar']);
$methods = $this->readAttribute($definition, 'methods');
$this->assertArrayHasKey(
'setBar',
Expand All @@ -239,7 +239,7 @@ public function testWithMethod()

public function testCallMethod()
{
$definition = new Definition($this->container, 'Viserio\\Test\\Container\\Corge');
$definition = new Definition($this->container, 'Viserio\\Tests\\Container\\Corge');
$definition->withMethodCall('setInt', [1]);
$reflection = new \ReflectionMethod($definition, 'callMethods');
$reflection->setAccessible(true);
Expand Down
2 changes: 1 addition & 1 deletion src/Viserio/Container/Tests/MockerContainerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Viserio\Container\Test;
namespace Viserio\Container\Tests;

use Viserio\Container\Container;

Expand Down
15 changes: 0 additions & 15 deletions src/Viserio/Contracts/Exception/Adapter.php

This file was deleted.

45 changes: 45 additions & 0 deletions src/Viserio/Contracts/Exception/Displayer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
namespace Viserio\Contracts\Exception;

use Psr\Http\Message\ResponseInterface;
use Throwable;

interface Displayer
{
/**
* Display the given exception.
*
* @param \Throwable $exception
* @param string $id
* @param int $code
* @param string[] $headers
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function display(Throwable $exception, string $id, int $code, array $headers): ResponseInterface;

/**
* Get the supported content type.
*
* @return string
*/
public function contentType(): string;

/**
* Can we display the exception?
*
* @param \Throwable $original
* @param \Throwable $transformed
* @param int $code
*
* @return bool
*/
public function canDisplay(Throwable $original, Throwable $transformed, int $code): bool;

/**
* Do we provide verbose information about the exception?
*
* @return bool
*/
public function isVerbose(): bool;
}
Loading

0 comments on commit bf9938e

Please sign in to comment.