Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
12732cfa
Commit
12732cfa
authored
May 06, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed rbac tests to use migration
parent
ff3a20a7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
7 deletions
+21
-7
DbManager.php
framework/rbac/DbManager.php
+1
-1
DbManagerTestCase.php
tests/unit/framework/rbac/DbManagerTestCase.php
+20
-6
No files found.
framework/rbac/DbManager.php
View file @
12732cfa
...
...
@@ -21,7 +21,7 @@ use yii\di\Instance;
* The database connection is specified by [[db]]. The database schema could be initialized by applying migration:
*
* ```
*
yii migrate --migrationPath=/vendor/yiisoft/yii2
/rbac/migrations/
*
yii migrate --migrationPath=@yii
/rbac/migrations/
* ```
*
* You may change the names of the three tables used to store the authorization data by setting [[itemTable]],
...
...
tests/unit/framework/rbac/DbManagerTestCase.php
View file @
12732cfa
<?php
namespace
yiiunit\framework\rbac
;
use
yii\console\Application
;
use
yii\console\controllers\MigrateController
;
use
yii\db\Connection
;
use
yii\rbac\DbManager
;
...
...
@@ -17,6 +19,22 @@ abstract class DbManagerTestCase extends ManagerTestCase
*/
protected
$db
;
protected
function
getMigrator
()
{
$app
=
new
Application
([
'id'
=>
'Migrator'
,
'basePath'
=>
'@yiiunit'
,
'components'
=>
[
'db'
=>
$this
->
getConnection
(),
],
]);
$migrator
=
new
MigrateController
(
'migrate'
,
$app
,
[]);
$migrator
->
migrationPath
=
'@yii/rbac/migrations/'
;
$migrator
->
interactive
=
false
;
return
$migrator
;
}
protected
function
setUp
()
{
parent
::
setUp
();
...
...
@@ -29,11 +47,13 @@ abstract class DbManagerTestCase extends ManagerTestCase
}
$this
->
auth
=
new
DbManager
([
'db'
=>
$this
->
getConnection
()]);
$this
->
getMigrator
()
->
run
(
'up'
);
}
protected
function
tearDown
()
{
parent
::
tearDown
();
$this
->
getMigrator
()
->
run
(
'down'
);
if
(
$this
->
db
)
{
$this
->
db
->
close
();
}
...
...
@@ -64,12 +84,6 @@ abstract class DbManagerTestCase extends ManagerTestCase
}
if
(
$open
)
{
$db
->
open
();
$lines
=
explode
(
';'
,
file_get_contents
(
\Yii
::
getAlias
(
'@yii/rbac/schema-'
.
$this
->
driverName
.
'.sql'
)));
foreach
(
$lines
as
$line
)
{
if
(
trim
(
$line
)
!==
''
)
{
$db
->
pdo
->
exec
(
$line
);
}
}
}
$this
->
db
=
$db
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment