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
0061bc82
Commit
0061bc82
authored
Feb 10, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new test setup refactorings
parent
45235a15
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
107 additions
and
21 deletions
+107
-21
Export.php
lib/Doctrine/Export.php
+3
-3
AllTests.php
tests/Orm/Component/AllTests.php
+1
-1
TestTest.php
tests/Orm/Component/TestTest.php
+5
-0
CmsUser.yml
tests/fixtures/cms/data/CmsUser.yml
+0
-5
dummy.php
tests/fixtures/dbal/dummy.php
+16
-0
someusers.php
tests/fixtures/orm/forum/someusers.php
+14
-0
Doctrine_DbalTestCase.php
tests/lib/Doctrine_DbalTestCase.php
+1
-1
Doctrine_DbalTestSuite.php
tests/lib/Doctrine_DbalTestSuite.php
+1
-5
Doctrine_OrmTestCase.php
tests/lib/Doctrine_OrmTestCase.php
+55
-1
Doctrine_OrmTestSuite.php
tests/lib/Doctrine_OrmTestSuite.php
+1
-4
Doctrine_TestCase.php
tests/lib/Doctrine_TestCase.php
+1
-1
CmsUser.php
tests/models/cms/CmsUser.php
+0
-0
ForumUser.php
tests/models/forum/ForumUser.php
+9
-0
No files found.
lib/Doctrine/Export.php
View file @
0061bc82
...
@@ -1277,7 +1277,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
...
@@ -1277,7 +1277,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
* @return boolean whether or not the export operation was successful
* @return boolean whether or not the export operation was successful
* false if table already existed in the database
* false if table already existed in the database
*/
*/
public
function
exportTable
(
Doctrine_
Table
$table
)
public
function
exportTable
(
Doctrine_
ClassMetadata
$metadata
)
{
{
/**
/**
TODO: maybe there should be portability option for the following check
TODO: maybe there should be portability option for the following check
...
@@ -1287,10 +1287,10 @@ class Doctrine_Export extends Doctrine_Connection_Module
...
@@ -1287,10 +1287,10 @@ class Doctrine_Export extends Doctrine_Connection_Module
*/
*/
try
{
try
{
$data
=
$
table
->
getExportableFormat
();
$data
=
$
metadata
->
getExportableFormat
();
$this
->
conn
->
export
->
createTable
(
$data
[
'tableName'
],
$data
[
'columns'
],
$data
[
'options'
]);
$this
->
conn
->
export
->
createTable
(
$data
[
'tableName'
],
$data
[
'columns'
],
$data
[
'options'
]);
}
catch
(
Doctrine_Connection_Exception
$e
)
{
}
catch
(
Doctrine_Connection_Exception
$e
)
{
// we only want to silence table already exists errors
// we only want to silence table already exists errors
if
(
$e
->
getPortableCode
()
!==
Doctrine
::
ERR_ALREADY_EXISTS
)
{
if
(
$e
->
getPortableCode
()
!==
Doctrine
::
ERR_ALREADY_EXISTS
)
{
throw
$e
;
throw
$e
;
...
...
tests/Orm/Component/AllTests.php
View file @
0061bc82
...
@@ -17,7 +17,7 @@ class Orm_Component_AllTests
...
@@ -17,7 +17,7 @@ class Orm_Component_AllTests
public
static
function
suite
()
public
static
function
suite
()
{
{
$suite
=
new
Doctrine_TestSuite
(
'Doctrine
Dbal
Component'
);
$suite
=
new
Doctrine_TestSuite
(
'Doctrine
Orm
Component'
);
$suite
->
addTestSuite
(
'Orm_Component_TestTest'
);
$suite
->
addTestSuite
(
'Orm_Component_TestTest'
);
...
...
tests/Orm/Component/TestTest.php
View file @
0061bc82
...
@@ -3,6 +3,11 @@ require_once 'lib/DoctrineTestInit.php';
...
@@ -3,6 +3,11 @@ require_once 'lib/DoctrineTestInit.php';
class
Orm_Component_TestTest
extends
Doctrine_OrmTestCase
class
Orm_Component_TestTest
extends
Doctrine_OrmTestCase
{
{
protected
function
setUp
()
{
$this
->
loadFixture
(
'forum'
,
'someusers'
);
}
public
function
testTest
()
public
function
testTest
()
{
{
$this
->
assertEquals
(
0
,
0
);
$this
->
assertEquals
(
0
,
0
);
...
...
tests/fixtures/cms/data/CmsUser.yml
deleted
100644 → 0
View file @
45235a15
---
CmsUser
:
CmsUser_1
:
username
:
jwage
password
:
changeme
\ No newline at end of file
tests/fixtures/dbal/dummy.php
0 → 100644
View file @
0061bc82
<?php
$fixture
=
array
(
'tableName'
=>
'dummy'
,
'rows'
=>
array
(
array
(
'column1'
=>
'value1'
,
'column2'
=>
'value2'
,
'column3'
=>
'value3'
),
array
(
'column1'
=>
'value4'
,
'column2'
=>
'value5'
,
'column3'
=>
'value6'
)
)
);
\ No newline at end of file
tests/fixtures/orm/forum/someusers.php
0 → 100644
View file @
0061bc82
<?php
$fixture
=
array
(
'model'
=>
'ForumUser'
,
'rows'
=>
array
(
array
(
'id'
=>
1
,
'username'
=>
'romanb'
),
array
(
'id'
=>
2
,
'username'
=>
'jwage'
)
)
);
\ No newline at end of file
tests/lib/Doctrine_DbalTestCase.php
View file @
0061bc82
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
/**
/**
* Base testcase class for all dbal testcases.
* Base testcase class for all dbal testcases.
*/
*/
class
Doctrine_DbalTestCase
extends
PHPUnit_Framework
_TestCase
class
Doctrine_DbalTestCase
extends
Doctrine
_TestCase
{
{
}
}
\ No newline at end of file
tests/lib/Doctrine_DbalTestSuite.php
View file @
0061bc82
...
@@ -21,9 +21,5 @@ class Doctrine_DbalTestSuite extends Doctrine_TestSuite
...
@@ -21,9 +21,5 @@ class Doctrine_DbalTestSuite extends Doctrine_TestSuite
}
}
protected
function
tearDown
()
protected
function
tearDown
()
{
{}
Doctrine_Manager
::
getInstance
()
->
getConnection
(
'sqlite_memory'
)
->
close
();
$this
->
sharedFixture
=
NULL
;
}
}
}
\ No newline at end of file
tests/lib/Doctrine_OrmTestCase.php
View file @
0061bc82
...
@@ -2,10 +2,63 @@
...
@@ -2,10 +2,63 @@
/**
/**
* Base testcase class for all orm testcases.
* Base testcase class for all orm testcases.
*
*
* Provides the testcases with fixture support and other orm related capabilities.
*/
*/
class
Doctrine_OrmTestCase
extends
Doctrine_TestCase
class
Doctrine_OrmTestCase
extends
Doctrine_TestCase
{
{
private
$_loadedFixtures
=
array
();
private
static
$_fixtures
=
array
();
private
static
$_exportedTables
=
array
();
protected
function
loadFixture
(
$package
,
$name
)
{
$uniqueName
=
$package
.
'/'
.
$name
;
if
(
!
isset
(
self
::
$_fixtures
[
$uniqueName
]))
{
// load fixture file
$fixtureFile
=
'fixtures'
.
DIRECTORY_SEPARATOR
.
'orm'
.
DIRECTORY_SEPARATOR
.
$package
.
DIRECTORY_SEPARATOR
.
$name
.
'.php'
;
require
$fixtureFile
;
self
::
$_fixtures
[
$uniqueName
]
=
$fixture
;
// load model file
$modelFile
=
'models'
.
DIRECTORY_SEPARATOR
.
$package
.
DIRECTORY_SEPARATOR
.
$fixture
[
'model'
]
.
'.php'
;
require
$modelFile
;
}
$fixture
=
self
::
$_fixtures
[
$uniqueName
];
$this
->
_loadedFixtures
[]
=
$fixture
[
'model'
];
$conn
=
$this
->
sharedFixture
[
'connection'
];
$classMetadata
=
$conn
->
getClassMetadata
(
$fixture
[
'model'
]);
$tableName
=
$classMetadata
->
getTableName
();
if
(
!
in_array
(
$tableName
,
self
::
$_exportedTables
))
{
$conn
->
export
->
exportClasses
(
array
(
$fixture
[
'model'
]));
self
::
$_exportedTables
[]
=
$tableName
;
}
foreach
(
$fixture
[
'rows'
]
as
$row
)
{
$conn
->
insert
(
$classMetadata
,
$row
);
}
}
protected
function
loadFixtures
(
$package
,
array
$names
)
{
foreach
(
$names
as
$name
)
{
$this
->
loadFixture
(
$package
,
$name
);
}
}
protected
function
tearDown
()
{
$conn
=
$this
->
sharedFixture
[
'connection'
];
foreach
(
array_reverse
(
$this
->
_loadedFixtures
)
as
$model
)
{
$conn
->
exec
(
"DELETE FROM "
.
$conn
->
getClassMetadata
(
$model
)
->
getTableName
());
}
}
/*
public function loadFixturesPackage($package, $models = array())
public function loadFixturesPackage($package, $models = array())
{
{
$packagePath = 'fixtures' . DIRECTORY_SEPARATOR . $package;
$packagePath = 'fixtures' . DIRECTORY_SEPARATOR . $package;
...
@@ -23,4 +76,5 @@ class Doctrine_OrmTestCase extends Doctrine_TestCase
...
@@ -23,4 +76,5 @@ class Doctrine_OrmTestCase extends Doctrine_TestCase
$data = new Doctrine_Data();
$data = new Doctrine_Data();
$data->importData($dataPath, 'yml', $models);
$data->importData($dataPath, 'yml', $models);
}
}
*/
}
}
\ No newline at end of file
tests/lib/Doctrine_OrmTestSuite.php
View file @
0061bc82
...
@@ -20,8 +20,5 @@ class Doctrine_OrmTestSuite extends Doctrine_TestSuite
...
@@ -20,8 +20,5 @@ class Doctrine_OrmTestSuite extends Doctrine_TestSuite
}
}
protected
function
tearDown
()
protected
function
tearDown
()
{
{}
Doctrine_Manager
::
getInstance
()
->
getConnection
(
'sqlite_memory'
)
->
close
();
$this
->
sharedFixture
=
NULL
;
}
}
}
\ No newline at end of file
tests/lib/Doctrine_TestCase.php
View file @
0061bc82
...
@@ -4,5 +4,5 @@
...
@@ -4,5 +4,5 @@
*/
*/
class
Doctrine_TestCase
extends
PHPUnit_Framework_TestCase
class
Doctrine_TestCase
extends
PHPUnit_Framework_TestCase
{
{
}
}
\ No newline at end of file
tests/
fixtures/cms/model
s/CmsUser.php
→
tests/
models/cm
s/CmsUser.php
View file @
0061bc82
File moved
tests/models/forum/ForumUser.php
0 → 100644
View file @
0061bc82
<?php
class
ForumUser
extends
Doctrine_Record
{
public
static
function
initMetadata
(
$class
)
{
$class
->
setColumn
(
'id'
,
'integer'
,
4
,
array
(
'primary'
=>
true
,
'autoincrement'
=>
true
));
$class
->
setColumn
(
'username'
,
'string'
,
255
);
}
}
\ 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