Added zend-stragility (missing), removed some redundant code.

This commit is contained in:
kirkbushell 2015-09-28 15:59:07 +01:00
parent da4dad3bb8
commit a4c61efee2
4 changed files with 233 additions and 116 deletions

View File

@ -33,7 +33,8 @@
"dflydev/fig-cookies": "^1.0",
"symfony/console": "^2.7",
"symfony/yaml": "^2.7",
"doctrine/dbal": "^2.5"
"doctrine/dbal": "^2.5",
"zendframework/zend-stratigility": "^1.1"
},
"require-dev": {
"mockery/mockery": "^0.9.4",

View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "49ba424961939b5b7b6eea7bdcadcbda",
"content-hash": "f2e78efbbe37a6d94428a8e6985fda1f",
"hash": "555cfa89899e3b8e3df986c1edab97ad",
"content-hash": "24bf970274bf8e8ea5de56c5036d1c20",
"packages": [
{
"name": "danielstjules/stringy",
@ -642,51 +642,6 @@
],
"time": "2015-08-15 19:32:36"
},
{
"name": "hamcrest/hamcrest-php",
"version": "v1.2.2",
"source": {
"type": "git",
"url": "https://github.com/hamcrest/hamcrest-php.git",
"reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c",
"reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"replace": {
"cordoval/hamcrest-php": "*",
"davedevelopment/hamcrest-php": "*",
"kodova/hamcrest-php": "*"
},
"require-dev": {
"phpunit/php-file-iterator": "1.3.3",
"satooshi/php-coveralls": "dev-master"
},
"type": "library",
"autoload": {
"classmap": [
"hamcrest"
],
"files": [
"hamcrest/Hamcrest.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD"
],
"description": "This is the PHP port of Hamcrest Matchers",
"keywords": [
"test"
],
"time": "2015-05-11 14:41:42"
},
{
"name": "illuminate/bus",
"version": "v5.1.16",
@ -1498,71 +1453,6 @@
],
"time": "2015-09-05 12:06:41"
},
{
"name": "mockery/mockery",
"version": "0.9.4",
"source": {
"type": "git",
"url": "https://github.com/padraic/mockery.git",
"reference": "70bba85e4aabc9449626651f48b9018ede04f86b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/padraic/mockery/zipball/70bba85e4aabc9449626651f48b9018ede04f86b",
"reference": "70bba85e4aabc9449626651f48b9018ede04f86b",
"shasum": ""
},
"require": {
"hamcrest/hamcrest-php": "~1.1",
"lib-pcre": ">=7.0",
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.9.x-dev"
}
},
"autoload": {
"psr-0": {
"Mockery": "library/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Pádraic Brady",
"email": "padraic.brady@gmail.com",
"homepage": "http://blog.astrumfutura.com"
},
{
"name": "Dave Marshall",
"email": "dave.marshall@atstsolutions.co.uk",
"homepage": "http://davedevelopment.co.uk"
}
],
"description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.",
"homepage": "http://github.com/padraic/mockery",
"keywords": [
"BDD",
"TDD",
"library",
"mock",
"mock objects",
"mockery",
"stub",
"test",
"test double",
"testing"
],
"time": "2015-04-02 19:54:00"
},
{
"name": "nesbot/carbon",
"version": "1.20.0",
@ -2279,6 +2169,102 @@
"psr-7"
],
"time": "2015-08-10 20:04:20"
},
{
"name": "zendframework/zend-escaper",
"version": "2.5.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-escaper.git",
"reference": "a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-escaper/zipball/a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73",
"reference": "a4b227d8a477f4e7e9073f8e0a7ae7dbd3104a73",
"shasum": ""
},
"require": {
"php": ">=5.3.23"
},
"require-dev": {
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.5-dev",
"dev-develop": "2.6-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\Escaper\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"homepage": "https://github.com/zendframework/zend-escaper",
"keywords": [
"escaper",
"zf2"
],
"time": "2015-06-03 14:05:37"
},
{
"name": "zendframework/zend-stratigility",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-stratigility.git",
"reference": "6a3b7e601dfe7eca0652a8b7f1a469ff4b8f3c28"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zendframework/zend-stratigility/zipball/6a3b7e601dfe7eca0652a8b7f1a469ff4b8f3c28",
"reference": "6a3b7e601dfe7eca0652a8b7f1a469ff4b8f3c28",
"shasum": ""
},
"require": {
"php": ">=5.4.8",
"psr/http-message": "~1.0.0",
"zendframework/zend-escaper": "~2.3"
},
"require-dev": {
"phpunit/phpunit": "~4.7",
"squizlabs/php_codesniffer": "^2.3.1",
"zendframework/zend-diactoros": "~1.0"
},
"suggest": {
"psr/http-message-implementation": "Please install a psr/http-message-implementation to consume Stratigility; e.g., zendframework/zend-diactoros"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev",
"dev-develop": "1.1-dev"
}
},
"autoload": {
"psr-4": {
"Zend\\Stratigility\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"description": "Middleware for PHP",
"homepage": "https://github.com/zendframework/zend-stratigility",
"keywords": [
"http",
"middleware",
"psr-7"
],
"time": "2015-08-25 18:39:13"
}
],
"packages-dev": [
@ -2336,6 +2322,116 @@
],
"time": "2015-06-14 21:17:01"
},
{
"name": "hamcrest/hamcrest-php",
"version": "v1.2.2",
"source": {
"type": "git",
"url": "https://github.com/hamcrest/hamcrest-php.git",
"reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c",
"reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c",
"shasum": ""
},
"require": {
"php": ">=5.3.2"
},
"replace": {
"cordoval/hamcrest-php": "*",
"davedevelopment/hamcrest-php": "*",
"kodova/hamcrest-php": "*"
},
"require-dev": {
"phpunit/php-file-iterator": "1.3.3",
"satooshi/php-coveralls": "dev-master"
},
"type": "library",
"autoload": {
"classmap": [
"hamcrest"
],
"files": [
"hamcrest/Hamcrest.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD"
],
"description": "This is the PHP port of Hamcrest Matchers",
"keywords": [
"test"
],
"time": "2015-05-11 14:41:42"
},
{
"name": "mockery/mockery",
"version": "0.9.4",
"source": {
"type": "git",
"url": "https://github.com/padraic/mockery.git",
"reference": "70bba85e4aabc9449626651f48b9018ede04f86b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/padraic/mockery/zipball/70bba85e4aabc9449626651f48b9018ede04f86b",
"reference": "70bba85e4aabc9449626651f48b9018ede04f86b",
"shasum": ""
},
"require": {
"hamcrest/hamcrest-php": "~1.1",
"lib-pcre": ">=7.0",
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.9.x-dev"
}
},
"autoload": {
"psr-0": {
"Mockery": "library/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Pádraic Brady",
"email": "padraic.brady@gmail.com",
"homepage": "http://blog.astrumfutura.com"
},
{
"name": "Dave Marshall",
"email": "dave.marshall@atstsolutions.co.uk",
"homepage": "http://davedevelopment.co.uk"
}
],
"description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.",
"homepage": "http://github.com/padraic/mockery",
"keywords": [
"BDD",
"TDD",
"library",
"mock",
"mock objects",
"mockery",
"stub",
"test",
"test double",
"testing"
],
"time": "2015-04-02 19:54:00"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "2.0.4",

View File

@ -10,11 +10,8 @@
namespace Flarum\Admin\Middleware;
use Flarum\Api\AccessToken;
use Illuminate\Contracts\Container\Container;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Zend\Stratigility\MiddlewareInterface;
use Flarum\Forum\Middleware\LoginWithCookie;
use Flarum\Core\Exceptions\PermissionDeniedException;

View File

@ -0,0 +1,23 @@
<?php
namespace tests\Flarum\Admin\Middleware;
use Flarum\Admin\Middleware\LoginWithCookieAndCheckAdmin;
use Flarum\Core\Exceptions\PermissionDeniedException;
use Mockery as m;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use tests\Test\TestCase;
class LoginWithCookieAndCheckAdminTest extends TestCase
{
public function test_it_should_not_allow_invalid_logins()
{
$this->setExpectedException(PermissionDeniedException::class);
$request = m::mock(ServerRequestInterface::class);
$response = m::mock(ResponseInterface::class);
$middleware = new LoginWithCookieAndCheckAdmin;
$middleware->__invoke($request, $response);
}
}