Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.4] All tests have been namespaced #17148

Merged
merged 34 commits into from
Jan 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7f2b756
Basic Composer File
alexbowers Jan 4, 2017
2a9f95a
View Tests
alexbowers Jan 4, 2017
4d9f508
Validation Tests
alexbowers Jan 4, 2017
1eb0903
Translation Tests
alexbowers Jan 4, 2017
cac93ce
Support Tests
alexbowers Jan 4, 2017
e04ee05
Session Tests
alexbowers Jan 4, 2017
cd29dd1
Routing Tests
alexbowers Jan 4, 2017
937dfe6
Redis Tests
alexbowers Jan 4, 2017
82d6e13
Queue Tests
alexbowers Jan 4, 2017
b974a11
Pipeline Tests
alexbowers Jan 4, 2017
09a9f3b
Pagination Tests
alexbowers Jan 4, 2017
5d76eec
Notification Tests
alexbowers Jan 4, 2017
a7a4771
Mail Tests
alexbowers Jan 4, 2017
a824309
Log Tests
alexbowers Jan 4, 2017
6c894e5
Http Tests
alexbowers Jan 4, 2017
53a106c
Hashing Tests
alexbowers Jan 4, 2017
a87a915
Foundation Tests
alexbowers Jan 4, 2017
5480fcd
Filesystem Tests
alexbowers Jan 4, 2017
745c751
Events Tests
alexbowers Jan 4, 2017
5af0298
Encryption Tests
alexbowers Jan 4, 2017
70cf961
Database Tests
alexbowers Jan 4, 2017
c53b24b
Cookie Tests
alexbowers Jan 4, 2017
84dd71a
Container Tests
alexbowers Jan 4, 2017
327b7f2
Console Tests
alexbowers Jan 4, 2017
f8aaebb
Config Tests
alexbowers Jan 4, 2017
d0e68b1
Cache Tests
alexbowers Jan 4, 2017
1ad7c79
Bus Tests
alexbowers Jan 4, 2017
132ce78
Broadcasting Tests
alexbowers Jan 4, 2017
f339294
Blade Tests
alexbowers Jan 4, 2017
62ea74a
Auth Tests
alexbowers Jan 4, 2017
efc761d
Http Tests
alexbowers Jan 4, 2017
8d94a01
Merge branch '5.4' into refactor/namespace-tests
alexbowers Jan 13, 2017
22abbf4
Fixed tests
alexbowers Jan 13, 2017
d0948e4
Merge branch '5.4' into refactor/namespace-tests
alexbowers Jan 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,11 @@
},
"autoload-dev": {
"files": [
"tests/Redis/InteractsWithRedis.php"
]
"tests/Database/stubs/MigrationCreatorFakeMigration.php"
],
"psr-4": {
"Illuminate\\Tests\\": "tests/"
}
},
"extra": {
"branch-alias": {
Expand Down
8 changes: 6 additions & 2 deletions tests/Auth/AuthAccessGateTest.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
<?php

namespace Illuminate\Tests\Auth;

use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use Illuminate\Auth\Access\Gate;
use Illuminate\Container\Container;
use Illuminate\Auth\Access\Response;
use Illuminate\Auth\Access\HandlesAuthorization;
use StdClass;

class GateTest extends TestCase
{
/**
* @expectedException \InvalidArgumentException
* @expectedException InvalidArgumentException
*/
public function test_gate_throws_exception_on_invalid_callback_type()
{
Expand Down Expand Up @@ -133,7 +137,7 @@ public function test_classes_can_be_defined_as_callbacks_using_at_notation()
{
$gate = $this->getBasicGate();

$gate->define('foo', 'AccessGateTestClass@foo');
$gate->define('foo', '\Illuminate\Tests\Auth\AccessGateTestClass@foo');

$this->assertTrue($gate->check('foo'));
}
Expand Down
5 changes: 4 additions & 1 deletion tests/Auth/AuthDatabaseTokenRepositoryTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Illuminate\Tests\Auth;

use Illuminate\Auth\Passwords\DatabaseTokenRepository;
use Mockery as m;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -103,7 +106,7 @@ public function testDeleteExpiredMethodDeletesExpiredTokens()

protected function getRepo()
{
return new Illuminate\Auth\Passwords\DatabaseTokenRepository(
return new DatabaseTokenRepository(
m::mock('Illuminate\Database\Connection'),
m::mock('Illuminate\Contracts\Hashing\Hasher'),
'table', 'key');
Expand Down
13 changes: 8 additions & 5 deletions tests/Auth/AuthDatabaseUserProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Illuminate\Tests\Auth;

use Illuminate\Auth\DatabaseUserProvider;
use Mockery as m;
use PHPUnit\Framework\TestCase;

Expand All @@ -16,7 +19,7 @@ public function testRetrieveByIDReturnsUserWhenUserIsFound()
$conn->shouldReceive('table')->once()->with('foo')->andReturn($conn);
$conn->shouldReceive('find')->once()->with(1)->andReturn(['id' => 1, 'name' => 'Dayle']);
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$provider = new Illuminate\Auth\DatabaseUserProvider($conn, $hasher, 'foo');
$provider = new DatabaseUserProvider($conn, $hasher, 'foo');
$user = $provider->retrieveById(1);

$this->assertInstanceOf('Illuminate\Auth\GenericUser', $user);
Expand All @@ -30,7 +33,7 @@ public function testRetrieveByIDReturnsNullWhenUserIsNotFound()
$conn->shouldReceive('table')->once()->with('foo')->andReturn($conn);
$conn->shouldReceive('find')->once()->with(1)->andReturn(null);
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$provider = new Illuminate\Auth\DatabaseUserProvider($conn, $hasher, 'foo');
$provider = new DatabaseUserProvider($conn, $hasher, 'foo');
$user = $provider->retrieveById(1);

$this->assertNull($user);
Expand All @@ -43,7 +46,7 @@ public function testRetrieveByCredentialsReturnsUserWhenUserIsFound()
$conn->shouldReceive('where')->once()->with('username', 'dayle');
$conn->shouldReceive('first')->once()->andReturn(['id' => 1, 'name' => 'taylor']);
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$provider = new Illuminate\Auth\DatabaseUserProvider($conn, $hasher, 'foo');
$provider = new DatabaseUserProvider($conn, $hasher, 'foo');
$user = $provider->retrieveByCredentials(['username' => 'dayle', 'password' => 'foo']);

$this->assertInstanceOf('Illuminate\Auth\GenericUser', $user);
Expand All @@ -58,7 +61,7 @@ public function testRetrieveByCredentialsReturnsNullWhenUserIsFound()
$conn->shouldReceive('where')->once()->with('username', 'dayle');
$conn->shouldReceive('first')->once()->andReturn(null);
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$provider = new Illuminate\Auth\DatabaseUserProvider($conn, $hasher, 'foo');
$provider = new DatabaseUserProvider($conn, $hasher, 'foo');
$user = $provider->retrieveByCredentials(['username' => 'dayle']);

$this->assertNull($user);
Expand All @@ -69,7 +72,7 @@ public function testCredentialValidation()
$conn = m::mock('Illuminate\Database\Connection');
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$hasher->shouldReceive('check')->once()->with('plain', 'hash')->andReturn(true);
$provider = new Illuminate\Auth\DatabaseUserProvider($conn, $hasher, 'foo');
$provider = new DatabaseUserProvider($conn, $hasher, 'foo');
$user = m::mock('Illuminate\Contracts\Auth\Authenticatable');
$user->shouldReceive('getAuthPassword')->once()->andReturn('hash');
$result = $provider->validateCredentials($user, ['password' => 'plain']);
Expand Down
9 changes: 6 additions & 3 deletions tests/Auth/AuthEloquentUserProviderTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

namespace Illuminate\Tests\Auth;

use Mockery as m;
use PHPUnit\Framework\TestCase;
use Illuminate\Auth\EloquentUserProvider;

class AuthEloquentUserProviderTest extends TestCase
{
Expand Down Expand Up @@ -40,7 +43,7 @@ public function testCredentialValidation()
$conn = m::mock('Illuminate\Database\Connection');
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$hasher->shouldReceive('check')->once()->with('plain', 'hash')->andReturn(true);
$provider = new Illuminate\Auth\EloquentUserProvider($hasher, 'foo');
$provider = new EloquentUserProvider($hasher, 'foo');
$user = m::mock('Illuminate\Contracts\Auth\Authenticatable');
$user->shouldReceive('getAuthPassword')->once()->andReturn('hash');
$result = $provider->validateCredentials($user, ['password' => 'plain']);
Expand All @@ -51,10 +54,10 @@ public function testCredentialValidation()
public function testModelsCanBeCreated()
{
$hasher = m::mock('Illuminate\Contracts\Hashing\Hasher');
$provider = new Illuminate\Auth\EloquentUserProvider($hasher, 'EloquentProviderUserStub');
$provider = new EloquentUserProvider($hasher, 'Illuminate\Tests\Auth\EloquentProviderUserStub');
$model = $provider->createModel();

$this->assertInstanceOf('EloquentProviderUserStub', $model);
$this->assertInstanceOf('Illuminate\Tests\Auth\EloquentProviderUserStub', $model);
}

protected function getProviderMock()
Expand Down
28 changes: 15 additions & 13 deletions tests/Auth/AuthGuardTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Illuminate\Tests\Auth;

use Mockery as m;
use PHPUnit\Framework\TestCase;
use Illuminate\Auth\Events\Failed;
Expand All @@ -20,7 +22,7 @@ public function testBasicReturnsNullOnValidAttempt()
$guard = m::mock('Illuminate\Auth\SessionGuard[check,attempt]', ['default', $provider, $session]);
$guard->shouldReceive('check')->once()->andReturn(false);
$guard->shouldReceive('attempt')->once()->with(['email' => 'foo@bar.com', 'password' => 'secret'])->andReturn(true);
$request = Symfony\Component\HttpFoundation\Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret']);
$request = Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret']);
$guard->setRequest($request);

$guard->basic('email');
Expand All @@ -32,7 +34,7 @@ public function testBasicReturnsNullWhenAlreadyLoggedIn()
$guard = m::mock('Illuminate\Auth\SessionGuard[check]', ['default', $provider, $session]);
$guard->shouldReceive('check')->once()->andReturn(true);
$guard->shouldReceive('attempt')->never();
$request = Symfony\Component\HttpFoundation\Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret']);
$request = Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret']);
$guard->setRequest($request);

$guard->basic('email');
Expand All @@ -44,7 +46,7 @@ public function testBasicReturnsResponseOnFailure()
$guard = m::mock('Illuminate\Auth\SessionGuard[check,attempt]', ['default', $provider, $session]);
$guard->shouldReceive('check')->once()->andReturn(false);
$guard->shouldReceive('attempt')->once()->with(['email' => 'foo@bar.com', 'password' => 'secret'])->andReturn(false);
$request = Symfony\Component\HttpFoundation\Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret']);
$request = \Symfony\Component\HttpFoundation\Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret']);
$guard->setRequest($request);
$response = $guard->basic('email');

Expand All @@ -58,7 +60,7 @@ public function testBasicWithExtraConditions()
$guard = m::mock('Illuminate\Auth\SessionGuard[check,attempt]', ['default', $provider, $session]);
$guard->shouldReceive('check')->once()->andReturn(false);
$guard->shouldReceive('attempt')->once()->with(['email' => 'foo@bar.com', 'password' => 'secret', 'active' => 1])->andReturn(true);
$request = Symfony\Component\HttpFoundation\Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret']);
$request = \Symfony\Component\HttpFoundation\Request::create('/', 'GET', [], [], [], ['PHP_AUTH_USER' => 'foo@bar.com', 'PHP_AUTH_PW' => 'secret']);
$guard->setRequest($request);

$guard->basic('email', ['active' => 1]);
Expand Down Expand Up @@ -261,9 +263,9 @@ public function testLogoutFiresLogoutEvent()
public function testLoginMethodQueuesCookieWhenRemembering()
{
list($session, $provider, $request, $cookie) = $this->getMocks();
$guard = new Illuminate\Auth\SessionGuard('default', $provider, $session, $request);
$guard = new \Illuminate\Auth\SessionGuard('default', $provider, $session, $request);
$guard->setCookieJar($cookie);
$foreverCookie = new Symfony\Component\HttpFoundation\Cookie($guard->getRecallerName(), 'foo');
$foreverCookie = new \Symfony\Component\HttpFoundation\Cookie($guard->getRecallerName(), 'foo');
$cookie->shouldReceive('forever')->once()->with($guard->getRecallerName(), 'foo|recaller')->andReturn($foreverCookie);
$cookie->shouldReceive('queue')->once()->with($foreverCookie);
$guard->getSession()->shouldReceive('put')->once()->with($guard->getName(), 'foo');
Expand All @@ -279,9 +281,9 @@ public function testLoginMethodQueuesCookieWhenRemembering()
public function testLoginMethodCreatesRememberTokenIfOneDoesntExist()
{
list($session, $provider, $request, $cookie) = $this->getMocks();
$guard = new Illuminate\Auth\SessionGuard('default', $provider, $session, $request);
$guard = new \Illuminate\Auth\SessionGuard('default', $provider, $session, $request);
$guard->setCookieJar($cookie);
$foreverCookie = new Symfony\Component\HttpFoundation\Cookie($guard->getRecallerName(), 'foo');
$foreverCookie = new \Symfony\Component\HttpFoundation\Cookie($guard->getRecallerName(), 'foo');
$cookie->shouldReceive('forever')->once()->andReturn($foreverCookie);
$cookie->shouldReceive('queue')->once()->with($foreverCookie);
$guard->getSession()->shouldReceive('put')->once()->with($guard->getName(), 'foo');
Expand Down Expand Up @@ -345,8 +347,8 @@ public function testUserUsesRememberCookieIfItExists()
{
$guard = $this->getGuard();
list($session, $provider, $request, $cookie) = $this->getMocks();
$request = Symfony\Component\HttpFoundation\Request::create('/', 'GET', [], [$guard->getRecallerName() => 'id|recaller']);
$guard = new Illuminate\Auth\SessionGuard('default', $provider, $session, $request);
$request = \Symfony\Component\HttpFoundation\Request::create('/', 'GET', [], [$guard->getRecallerName() => 'id|recaller']);
$guard = new \Illuminate\Auth\SessionGuard('default', $provider, $session, $request);
$guard->getSession()->shouldReceive('get')->once()->with($guard->getName())->andReturn(null);
$user = m::mock('Illuminate\Contracts\Auth\Authenticatable');
$guard->getProvider()->shouldReceive('retrieveByToken')->once()->with('id', 'recaller')->andReturn($user);
Expand All @@ -361,21 +363,21 @@ protected function getGuard()
{
list($session, $provider, $request, $cookie) = $this->getMocks();

return new Illuminate\Auth\SessionGuard('default', $provider, $session, $request);
return new \Illuminate\Auth\SessionGuard('default', $provider, $session, $request);
}

protected function getMocks()
{
return [
m::mock('Illuminate\Contracts\Session\Session'),
m::mock('Illuminate\Contracts\Auth\UserProvider'),
Symfony\Component\HttpFoundation\Request::create('/', 'GET'),
\Symfony\Component\HttpFoundation\Request::create('/', 'GET'),
m::mock('Illuminate\Cookie\CookieJar'),
];
}

protected function getCookieJar()
{
return new Illuminate\Cookie\CookieJar(Request::create('/foo', 'GET'), m::mock('Illuminate\Contracts\Encryption\Encrypter'), ['domain' => 'foo.com', 'path' => '/', 'secure' => false, 'httpOnly' => false]);
return new \Illuminate\Cookie\CookieJar(Request::create('/foo', 'GET'), m::mock('Illuminate\Contracts\Encryption\Encrypter'), ['domain' => 'foo.com', 'path' => '/', 'secure' => false, 'httpOnly' => false]);
}
}
4 changes: 3 additions & 1 deletion tests/Auth/AuthPasswordBrokerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Illuminate\Tests\Auth;

use Mockery as m;
use PHPUnit\Framework\TestCase;
use Illuminate\Contracts\Auth\PasswordBroker;
Expand Down Expand Up @@ -134,7 +136,7 @@ public function testResetRemovesRecordOnReminderTableAndCallsCallback()

protected function getBroker($mocks)
{
return new Illuminate\Auth\Passwords\PasswordBroker($mocks['tokens'], $mocks['users'], $mocks['mailer'], $mocks['view']);
return new \Illuminate\Auth\Passwords\PasswordBroker($mocks['tokens'], $mocks['users'], $mocks['mailer'], $mocks['view']);
}

protected function getMocks()
Expand Down
3 changes: 3 additions & 0 deletions tests/Auth/AuthTokenGuardTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php

namespace Illuminate\Tests\Auth;

use Illuminate\Http\Request;
use Illuminate\Auth\TokenGuard;
use Mockery;
use PHPUnit\Framework\TestCase;
use Illuminate\Contracts\Auth\UserProvider;

Expand Down
9 changes: 6 additions & 3 deletions tests/Auth/AuthenticateMiddlewareTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Illuminate\Tests\Auth;

use stdClass;
use Mockery as m;
use Illuminate\Http\Request;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -31,7 +34,7 @@ public function setUp()
}

/**
* @expectedException Illuminate\Auth\AuthenticationException
* @expectedException \Illuminate\Auth\AuthenticationException
*/
public function testDefaultUnauthenticatedThrows()
{
Expand Down Expand Up @@ -76,7 +79,7 @@ public function testSecondaryAuthenticatedUpdatesDefaultDriver()
}

/**
* @expectedException Illuminate\Auth\AuthenticationException
* @expectedException \Illuminate\Auth\AuthenticationException
*/
public function testMultipleDriversUnauthenticatedThrows()
{
Expand Down Expand Up @@ -172,7 +175,7 @@ protected function createAuthDriver($authenticated)
* @param string ...$guards
* @return void
*
* @throws \Illuminate\Auth\AuthenticationException
* @throws AuthenticationException
*/
protected function authenticate(...$guards)
{
Expand Down
9 changes: 6 additions & 3 deletions tests/Auth/AuthorizeMiddlewareTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Illuminate\Tests\Auth;

use Mockery as m;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
Expand All @@ -12,6 +14,7 @@
use Illuminate\Contracts\Auth\Factory as Auth;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Contracts\Auth\Access\Gate as GateContract;
use stdClass;

class AuthorizeMiddlewareTest extends TestCase
{
Expand Down Expand Up @@ -52,7 +55,7 @@ public function setUp()
}

/**
* @expectedException Illuminate\Auth\Access\AuthorizationException
* @expectedException \Illuminate\Auth\Access\AuthorizationException
*/
public function testSimpleAbilityUnauthorized()
{
Expand Down Expand Up @@ -91,7 +94,7 @@ public function testSimpleAbilityAuthorized()
}

/**
* @expectedException Illuminate\Auth\Access\AuthorizationException
* @expectedException \Illuminate\Auth\Access\AuthorizationException
*/
public function testModelTypeUnauthorized()
{
Expand Down Expand Up @@ -132,7 +135,7 @@ public function testModelTypeAuthorized()
}

/**
* @expectedException Illuminate\Auth\Access\AuthorizationException
* @expectedException \Illuminate\Auth\Access\AuthorizationException
*/
public function testModelUnauthorized()
{
Expand Down
9 changes: 6 additions & 3 deletions tests/Auth/AuthorizesResourcesTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

namespace Illuminate\Tests\Auth;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Routing\Router;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -60,10 +63,10 @@ public function testDestroyMethod()
*/
protected function assertHasMiddleware($controller, $method, $middleware)
{
$router = new Router(new Illuminate\Events\Dispatcher);
$router = new Router(new \Illuminate\Events\Dispatcher);

$router->aliasMiddleware('can', 'AuthorizesResourcesMiddleware');
$router->get($method)->uses('AuthorizesResourcesController@'.$method);
$router->aliasMiddleware('can', '\Illuminate\Tests\Auth\AuthorizesResourcesMiddleware');
$router->get($method)->uses('\Illuminate\Tests\Auth\AuthorizesResourcesController@'.$method);

$this->assertEquals(
'caught '.$middleware,
Expand Down
Loading