Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
54c3b98d
Commit
54c3b98d
authored
Oct 15, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes.
parent
071febe9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
12 deletions
+46
-12
Migration.php
lib/Doctrine/Migration.php
+6
-4
ManagerTestCase.php
tests/ManagerTestCase.php
+32
-0
MigrationTestCase.php
tests/MigrationTestCase.php
+8
-8
No files found.
lib/Doctrine/Migration.php
View file @
54c3b98d
...
@@ -145,7 +145,7 @@ class Doctrine_Migration
...
@@ -145,7 +145,7 @@ class Doctrine_Migration
$e
=
explode
(
'_'
,
$fileName
);
$e
=
explode
(
'_'
,
$fileName
);
$classMigrationNum
=
(
int
)
$e
[
0
];
$classMigrationNum
=
(
int
)
$e
[
0
];
$loadedClasses
[
$classMigrationNum
]
=
$fileName
;
$loadedClasses
[
$classMigrationNum
]
=
array
(
'className'
=>
$name
,
'fileName'
=>
$fileName
)
;
}
}
$this
->
migrationClasses
=
$loadedClasses
;
$this
->
migrationClasses
=
$loadedClasses
;
...
@@ -228,7 +228,7 @@ class Doctrine_Migration
...
@@ -228,7 +228,7 @@ class Doctrine_Migration
$this
->
loadMigrationClasses
();
$this
->
loadMigrationClasses
();
$versions
=
array
();
$versions
=
array
();
foreach
(
$this
->
migrationClasses
as
$classMigrationNum
=>
$fileName
)
{
foreach
(
array_keys
(
$this
->
migrationClasses
)
as
$classMigrationNum
)
{
$versions
[
$classMigrationNum
]
=
$classMigrationNum
;
$versions
[
$classMigrationNum
]
=
$classMigrationNum
;
}
}
...
@@ -252,8 +252,10 @@ class Doctrine_Migration
...
@@ -252,8 +252,10 @@ class Doctrine_Migration
*/
*/
protected
function
getMigrationClass
(
$num
)
protected
function
getMigrationClass
(
$num
)
{
{
foreach
(
$this
->
migrationClasses
as
$classMigrationNum
=>
$fileName
)
{
foreach
(
$this
->
migrationClasses
as
$classMigrationNum
=>
$info
)
{
if
(
$classMigrationNum
===
$num
)
{
$className
=
$info
[
'className'
];
if
(
$classMigrationNum
==
$num
)
{
return
new
$className
();
return
new
$className
();
}
}
}
}
...
...
tests/ManagerTestCase.php
View file @
54c3b98d
...
@@ -55,6 +55,38 @@ class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase {
...
@@ -55,6 +55,38 @@ class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
Doctrine
::
classify
(
Doctrine
::
tableize
(
$name
)),
$name
);
$this
->
assertEqual
(
Doctrine
::
classify
(
Doctrine
::
tableize
(
$name
)),
$name
);
}
public
function
testDsnParser
()
{
$mysql
=
'mysql://user:pass@localhost/dbname'
;
// This is what is specified in the manul
// I think it should be this for parse_url() to work
// sqlite://full/unix/path/to/file.db
// It expects only // since it thinks it is parsing a url
// The problem after that is that the dns is not valid when being passed to PDO
$sqlite
=
'sqlite:////full/unix/path/to/file.db'
;
$sqlitewin
=
'sqlite:///c:/full/windows/path/to/file.db'
;
$manager
=
Doctrine_Manager
::
getInstance
();
try
{
$manager
->
parseDsn
(
$mysql
);
}
catch
(
Exception
$e
)
{
$this
->
fail
();
}
try
{
$manager
->
parseDsn
(
$sqlite
);
}
catch
(
Exception
$e
)
{
$this
->
fail
();
}
try
{
$manager
->
parseDsn
(
$sqlitewin
);
}
catch
(
Exception
$e
)
{
$this
->
fail
();
}
}
}
public
function
prepareData
()
{
}
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
}
public
function
prepareTables
()
{
}
...
...
tests/MigrationTestCase.php
View file @
54c3b98d
...
@@ -33,17 +33,17 @@
...
@@ -33,17 +33,17 @@
class
Doctrine_Migration_TestCase
extends
Doctrine_UnitTestCase
class
Doctrine_Migration_TestCase
extends
Doctrine_UnitTestCase
{
{
public
function
testMigration
()
public
function
testMigration
()
{
{
//
Upgrade one at a time
//
New migration for the 'migration_classes' directory
$migration
=
new
Doctrine_Migration
(
'migration_classes'
);
$migration
=
new
Doctrine_Migration
(
'migration_classes'
);
$migration
->
migrate
(
0
,
1
);
$migration
->
migrate
(
1
,
2
);
// Then revert back to version 1
// migrate to version 2
$migration
->
migrate
(
2
,
1
);
$migration
->
migrate
(
2
);
$migration
->
migrate
(
1
,
0
);
// Check to make sure the current version is 0
// now migrate back to original version
$migration
->
migrate
(
0
);
// Make sure the current version is 0
$this
->
assertEqual
(
$migration
->
getCurrentVersion
(),
0
);
$this
->
assertEqual
(
$migration
->
getCurrentVersion
(),
0
);
}
}
}
}
\ 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