Skip to content
Permalink
Browse files

add tests for policy resolution

  • Loading branch information...
taylorotwell committed Feb 18, 2019
1 parent 82816f0 commit dee4d82e0259b270413573c7792d92d49b51fe2a
@@ -550,7 +550,7 @@ public function getPolicyFor($class)
*/
protected function guessPolicyName($class)
{
return dirname(str_replace('\\', '/', $class)).'\\Policies\\'.class_basename($class).'Policy';
return str_replace('/', '\\', dirname(str_replace('\\', '/', $class)).'\\Policies\\'.class_basename($class).'Policy');
}
/**
@@ -0,0 +1,8 @@
<?php
namespace Illuminate\Tests\Integration\Auth\Fixtures\Policies;
class AuthenticationTestUserPolicy
{
//
}
@@ -0,0 +1,22 @@
<?php
namespace Illuminate\Tests\Integration\Auth;
use Orchestra\Testbench\TestCase;
use Illuminate\Support\Facades\Gate;
use Illuminate\Tests\Integration\Auth\Fixtures\AuthenticationTestUser;
use Illuminate\Tests\Integration\Auth\Fixtures\Policies\AuthenticationTestUserPolicy;
/**
* @group integration
*/
class GatePolicyResolutionTest extends TestCase
{
public function testPolicyCanBeGuessedUsingClassConventions()
{
$this->assertInstanceOf(
AuthenticationTestUserPolicy::class,
Gate::getPolicyFor(AuthenticationTestUser::class)
);
}
}

0 comments on commit dee4d82

Please sign in to comment.
You can’t perform that action at this time.