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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
b90f8865
Commit
b90f8865
authored
Jul 10, 2014
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unit test for MongoDB migration controller added
parent
5fb654f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
4 deletions
+59
-4
MigrateController.php
extensions/mongodb/console/controllers/MigrateController.php
+4
-4
MigrateControllerTest.php
...ons/mongodb/console/controllers/MigrateControllerTest.php
+55
-0
No files found.
extensions/mongodb/console/controllers/MigrateController.php
View file @
b90f8865
...
@@ -136,14 +136,14 @@ class MigrateController extends BaseMigrateController
...
@@ -136,14 +136,14 @@ class MigrateController extends BaseMigrateController
return
$history
;
return
$history
;
}
}
private
$baseMigrationEnsured
=
false
;
/**
/**
* Ensures migration history contains at least base migration entry.
* Ensures migration history contains at least base migration entry.
*/
*/
protected
function
ensureBaseMigrationHistory
()
protected
function
ensureBaseMigrationHistory
()
{
{
static
$ensured
=
false
;
if
(
!
$this
->
baseMigrationEnsured
)
{
if
(
!
$ensured
)
{
$query
=
new
Query
;
$query
=
new
Query
;
$row
=
$query
->
select
([
'version'
])
$row
=
$query
->
select
([
'version'
])
->
from
(
$this
->
migrationCollection
)
->
from
(
$this
->
migrationCollection
)
...
@@ -153,7 +153,7 @@ class MigrateController extends BaseMigrateController
...
@@ -153,7 +153,7 @@ class MigrateController extends BaseMigrateController
if
(
empty
(
$row
))
{
if
(
empty
(
$row
))
{
$this
->
addMigrationHistory
(
self
::
BASE_MIGRATION
);
$this
->
addMigrationHistory
(
self
::
BASE_MIGRATION
);
}
}
$
e
nsured
=
true
;
$
this
->
baseMigrationE
nsured
=
true
;
}
}
}
}
...
...
tests/unit/extensions/mongodb/console/controllers/MigrateControllerTest.php
0 → 100644
View file @
b90f8865
<?php
namespace
yiiunit\extensions\mongodb\console\controllers
;
use
yii\mongodb\Exception
;
use
yii\mongodb\Migration
;
use
yii\mongodb\Query
;
use
Yii
;
use
yiiunit\extensions\mongodb\MongoDbTestCase
;
use
yiiunit\framework\console\controllers\MigrateControllerTestTrait
;
use
yii\mongodb\console\controllers\MigrateController
;
/**
* Unit test for [[\yii\mongodb\console\controllers\MigrateController]].
* @see MigrateController
*
* @group mongodb
* @group console
*/
class
MigrateControllerTest
extends
MongoDbTestCase
{
use
MigrateControllerTestTrait
;
public
function
setUp
()
{
$this
->
migrateControllerClass
=
MigrateController
::
className
();
$this
->
migrationBaseClass
=
Migration
::
className
();
parent
::
setUp
();
$this
->
setUpMigrationPath
();
Yii
::
$app
->
setComponents
([
'mongodb'
=>
$this
->
getConnection
()]);
}
public
function
tearDown
()
{
parent
::
tearDown
();
try
{
$this
->
getConnection
()
->
getCollection
(
'migration'
)
->
drop
();
}
catch
(
Exception
$e
)
{
// shutdown exception
}
$this
->
tearDownMigrationPath
();
}
/**
* @return array applied migration entries
*/
protected
function
getMigrationHistory
()
{
$query
=
new
Query
();
return
$query
->
from
(
'migration'
)
->
all
();
}
}
\ No newline at end of file
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