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
99ae59fd
Commit
99ae59fd
authored
Aug 16, 2007
by
Jonathan.Wage
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed import/export methods to importSchema() and exportSchema()
parent
b4600960
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
448 additions
and
59 deletions
+448
-59
Doctrine.php
lib/Doctrine.php
+6
-6
Export.php
lib/Doctrine/Export.php
+2
-2
Schema.php
lib/Doctrine/Export/Schema.php
+49
-1
Xml.php
lib/Doctrine/Export/Schema/Xml.php
+45
-0
Yml.php
lib/Doctrine/Export/Schema/Yml.php
+28
-0
Import.php
lib/Doctrine/Import.php
+2
-2
Schema.php
lib/Doctrine/Import/Schema.php
+24
-10
Xml.php
lib/Doctrine/Import/Schema/Xml.php
+41
-25
Yml.php
lib/Doctrine/Import/Schema/Yml.php
+27
-12
RecordTestCase.php
tests/Export/RecordTestCase.php
+1
-1
XmlTestCase.php
tests/Export/Schema/XmlTestCase.php
+35
-0
YmlTestCase.php
tests/Export/Schema/YmlTestCase.php
+35
-0
XmlTestCase.php
tests/Import/Schema/XmlTestCase.php
+52
-0
YmlTestCase.php
tests/Import/Schema/YmlTestCase.php
+52
-0
run.php
tests/run.php
+9
-0
schema.xml
tests/schema.xml
+40
-0
schema.yml
tests/schema.yml
+0
-0
No files found.
lib/Doctrine.php
View file @
99ae59fd
...
...
@@ -408,26 +408,26 @@ final class Doctrine
}
}
/**
* imp
rt
* imp
ortSchema
* method for importing existing schema to Doctrine_Record classes
*
* @param string $directory
* @param array $info
* @return boolean
*/
public
static
function
imp
rt
(
$directory
,
array
$databases
=
array
())
public
static
function
imp
ortSchema
(
$directory
,
array
$databases
=
array
())
{
return
Doctrine_Manager
::
connection
()
->
imp
rt
->
imprt
(
$directory
,
$databases
);
return
Doctrine_Manager
::
connection
()
->
imp
ort
->
importSchema
(
$directory
,
$databases
);
}
/**
* export
* export
Schema
* method for exporting Doctrine_Record classes to a schema
*
* @param string $directory
*/
public
static
function
export
(
$directory
=
null
)
public
static
function
export
Schema
(
$directory
=
null
)
{
return
Doctrine_Manager
::
connection
()
->
export
->
export
(
$directory
);
return
Doctrine_Manager
::
connection
()
->
export
->
export
Schema
(
$directory
);
}
/**
* exportSql
...
...
lib/Doctrine/Export.php
View file @
99ae59fd
...
...
@@ -958,7 +958,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
return
''
;
}
/**
* export
* export
Schema
* method for exporting Doctrine_Record classes to a schema
*
* if the directory parameter is given this method first iterates
...
...
@@ -972,7 +972,7 @@ class Doctrine_Export extends Doctrine_Connection_Module
* @param string $directory optional directory parameter
* @return void
*/
public
function
export
(
$directory
=
null
)
public
function
export
Schema
(
$directory
=
null
)
{
$sql
=
$this
->
exportSql
(
$directory
);
...
...
lib/Doctrine/Export/Schema.php
View file @
99ae59fd
...
...
@@ -36,6 +36,54 @@
* @version $Revision: 1838 $
* @author Nicolas Bérard-Nault <nicobn@gmail.com>
*/
class
Doctrine_Export_Schema
abstract
class
Doctrine_Export_Schema
{
/**
* build
*
* Build the schema string to be dumped to file
*
* @param string $array
* @return void
*/
abstract
function
build
(
$array
);
/**
* dump
*
* Dump the array to the schema file
*
* @param string $array
* @param string $schema
* @return void
*/
abstract
function
dump
(
$array
,
$schema
);
/**
* buildSchema
*
* Build schema array that can be dumped to file
*
* @param string $directory
* @return void
*/
public
function
buildSchema
(
$directory
)
{
// we need to figure out how we can build all the model information for the passed directory/directories
return
array
();
}
/**
* exportSchema
*
* @param string $schema
* @param string $directory
* @return void
*/
public
function
exportSchema
(
$schema
,
$directory
)
{
$array
=
$this
->
buildSchema
(
$directory
);
$this
->
dump
(
$arr
,
$schema
);
}
}
\ No newline at end of file
lib/Doctrine/Export/Schema/Xml.php
View file @
99ae59fd
...
...
@@ -31,4 +31,49 @@
*/
class
Doctrine_Export_Schema_Xml
extends
Doctrine_Export_Schema
{
/**
* build
*
* Build the schema xml string to be dumped to file
*
* @param string $array
* @return void
*/
public
function
build
(
$array
)
{
$xml
=
new
SimpleXMLElement
();
foreach
(
$array
as
$tableName
=>
$fields
)
{
$table
=
$xml
->
addChild
(
'table'
);
$name
=
$table
->
addChild
(
'name'
,
$tableName
);
$declaration
=
$table
->
addChild
(
'declaration'
);
foreach
(
$fields
as
$fieldName
=>
$properties
)
{
$field
=
$declaration
->
addChild
(
'field'
);
$field
->
addChild
(
'name'
,
$fieldName
);
foreach
(
$properties
as
$key
=>
$value
)
{
$field
->
addChild
(
$key
,
$value
);
}
}
}
return
$xml
->
asXml
();
}
/**
* dump
*
* Dump the array to the schema file
*
* @param string $array
* @param string $schema
* @return void
*/
public
function
dump
(
$array
,
$schema
)
{
$xml
=
$this
->
build
(
$array
);
file_put_contents
(
$schema
,
$xml
);
}
}
\ No newline at end of file
lib/Doctrine/Export/Schema/Yml.php
View file @
99ae59fd
...
...
@@ -31,4 +31,32 @@
*/
class
Doctrine_Export_Schema_Yml
extends
Doctrine_Export_Schema
{
/**
* build
*
* Build the schema yml string to be dumped to file
*
* @param string $array
* @return void
*/
public
function
build
(
$array
)
{
return
var_dump
(
$array
);
}
/**
* dump
*
* Dump the array to the schema file
*
* @param string $arr
* @param string $schema
* @return void
*/
public
function
dump
(
$arr
,
$schema
)
{
$yml
=
$this
->
build
(
$array
);
file_put_contents
(
$schema
,
$yml
);
}
}
\ No newline at end of file
lib/Doctrine/Import.php
View file @
99ae59fd
...
...
@@ -175,7 +175,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
return
$this
->
conn
->
fetchColumn
(
$this
->
sql
[
'listViews'
]);
}
/**
* imp
rt
* imp
ortSchema
*
* method for importing existing schema to Doctrine_Record classes
*
...
...
@@ -183,7 +183,7 @@ class Doctrine_Import extends Doctrine_Connection_Module
* @param array $databases
* @return array the names of the imported classes
*/
public
function
imp
rt
(
$directory
,
array
$databases
=
array
())
public
function
imp
ortSchema
(
$directory
,
array
$databases
=
array
())
{
$builder
=
new
Doctrine_Import_Builder
();
$builder
->
setTargetPath
(
$directory
);
...
...
lib/Doctrine/Import/Schema.php
View file @
99ae59fd
...
...
@@ -40,15 +40,27 @@
abstract
class
Doctrine_Import_Schema
{
/**
* Import the schema and return it in an array
* parse
*
* Function to do the actual parsing of the file
*
* @param string $schema
* @return void
* @author Jonathan H. Wage
*/
abstract
function
parse
(
$schema
);
/**
* Parse the schema and return it in an array
*
* @param string $schema
* @access public
*/
abstract
function
import
Schema
(
$schema
);
abstract
function
parse
Schema
(
$schema
);
/**
* import
* import
Schema
*
* A method to import a Schema and translate it into a Doctrine_Record object
*
...
...
@@ -57,18 +69,20 @@ abstract class Doctrine_Import_Schema
* be written
* @access public
*/
public
function
imp
rt
(
$schema
,
$directory
)
public
function
imp
ortSchema
(
$schema
,
$directory
)
{
$builder
=
new
Doctrine_Import_Builder
();
$builder
->
setTargetPath
(
$directory
);
$arr
=
$this
->
importSchema
(
$schema
);
foreach
(
$arr
as
$name
=>
$columns
)
{
$options
[
'className'
]
=
$name
;
$options
[
'fileName'
]
=
$directory
.
DIRECTORY_SEPARATOR
.
$name
.
'.class.php'
;
$array
=
$this
->
parseSchema
(
$schema
);
foreach
(
$array
as
$name
=>
$properties
)
{
$options
[
'className'
]
=
$properties
[
'class'
];
$options
[
'fileName'
]
=
$directory
.
DIRECTORY_SEPARATOR
.
$properties
[
'class'
]
.
'.class.php'
;
$columns
=
$properties
[
'columns'
];
$builder
->
buildRecord
(
$options
,
$columns
,
array
());
}
}
}
}
\ No newline at end of file
lib/Doctrine/Import/Schema/Xml.php
View file @
99ae59fd
...
...
@@ -39,16 +39,13 @@
*/
class
Doctrine_Import_Schema_Xml
extends
Doctrine_Import_Schema
{
/**
* importSchema
*
* A method to import a XML Schema and translate it into a property array.
* The function returns that property array.
*
* @param string $schema Path to the file containing the XML schema
* @return array
*/
public
function
importSchema
(
$schema
)
/**
* parse
*
* @param string $schema
* @return void
*/
public
function
parse
(
$schema
)
{
if
(
!
is_readable
(
$schema
))
{
throw
new
Doctrine_Import_Exception
(
'Could not read schema file '
.
$schema
);
...
...
@@ -58,31 +55,50 @@ class Doctrine_Import_Schema_Xml extends Doctrine_Import_Schema
throw
new
Doctrine_Import_Exception
(
'Schema file '
.
$schema
.
' is empty'
);
}
$xmlObj
=
simplexml_load_string
(
$xmlString
);
return
simplexml_load_string
(
$xmlString
);
}
/**
* parseSchema
*
* A method to parse a XML Schema and translate it into a property array.
* The function returns that property array.
*
* @param string $schema Path to the file containing the XML schema
* @return array
*/
public
function
parseSchema
(
$schema
)
{
$xmlObj
=
$this
->
parse
(
$schema
);
// Go through all tables...
foreach
(
$xmlObj
->
table
as
$table
)
{
// Go through all columns...
foreach
(
$table
->
declaration
->
column
as
$column
)
{
foreach
(
$table
->
declaration
->
field
as
$field
)
{
$colDesc
=
array
(
'name'
=>
(
string
)
$
column
->
name
,
'type'
=>
(
string
)
$
column
->
type
,
'ptype'
=>
(
string
)
$
column
->
type
,
'length'
=>
(
int
)
$
column
->
length
,
'fixed'
=>
(
int
)
$
column
->
fixed
,
'unsigned'
=>
(
bool
)
$
column
->
unsigned
,
'primary'
=>
(
bool
)
(
isset
(
$
column
->
primary
)
&&
$column
->
primary
),
'default'
=>
(
string
)
$
column
->
default
,
'notnull'
=>
(
bool
)
(
isset
(
$
column
->
notnull
)
&&
$column
->
notnull
),
'autoinc'
=>
(
bool
)
(
isset
(
$
column
->
autoincrement
)
&&
$column
->
autoincrement
),
'name'
=>
(
string
)
$
field
->
name
,
'type'
=>
(
string
)
$
field
->
type
,
'ptype'
=>
(
string
)
$
field
->
type
,
'length'
=>
(
int
)
$
field
->
length
,
'fixed'
=>
(
int
)
$
field
->
fixed
,
'unsigned'
=>
(
bool
)
$
field
->
unsigned
,
'primary'
=>
(
bool
)
(
isset
(
$
field
->
primary
)
&&
$field
->
primary
),
'default'
=>
(
string
)
$
field
->
default
,
'notnull'
=>
(
bool
)
(
isset
(
$
field
->
notnull
)
&&
$field
->
notnull
),
'autoinc'
=>
(
bool
)
(
isset
(
$
field
->
autoincrement
)
&&
$field
->
autoincrement
),
);
$columns
[(
string
)
$
column
->
name
]
=
$colDesc
;
$columns
[(
string
)
$
field
->
name
]
=
$colDesc
;
}
$tables
[(
string
)
$table
->
name
]
=
$columns
;
$class
=
$table
->
class
?
(
string
)
$table
->
class
:
(
string
)
$table
->
name
;
$tables
[(
string
)
$table
->
name
][
'name'
]
=
(
string
)
$table
->
name
;
$tables
[(
string
)
$table
->
name
][
'class'
]
=
(
string
)
$class
;
$tables
[(
string
)
$table
->
name
][
'columns'
]
=
$columns
;
}
return
$tables
;
}
}
}
\ No newline at end of file
lib/Doctrine/Import/Schema/Yml.php
View file @
99ae59fd
...
...
@@ -39,26 +39,40 @@
*/
class
Doctrine_Import_Schema_Yml
extends
Doctrine_Import_Schema
{
/**
* parse
*
* @param string $schema
* @return void
*/
public
function
parse
(
$schema
)
{
if
(
!
is_readable
(
$schema
))
{
throw
new
Doctrine_Import_Exception
(
'Could not read schema file '
.
$schema
);
}
return
array
();
}
/**
*
import
Schema
*
parse
Schema
*
* A method to
import
a Yml Schema and translate it into a property array.
* A method to
parse
a Yml Schema and translate it into a property array.
* The function returns that property array.
*
* @param string $schema Path to the file containing the XML schema
* @return array
*/
public
function
importSchema
(
$schema
)
{
if
(
!
is_readable
(
$schema
))
{
throw
new
Doctrine_Import_Exception
(
'Could not read schema file '
.
$schema
);
}
// Need to figure out best way to have yaml loading/dumping in Doctrine
// $yamlArr = YamlLoad($schema);
public
function
parseSchema
(
$schema
)
{
$array
=
$this
->
parse
(
$schema
);
$tables
=
array
();
// Not working yet
/*
// Go through all tables...
foreach
(
$
yamlArr
[
'table'
]
as
$table
)
{
foreach ($
array
['table'] as $table) {
// Go through all columns...
foreach ($table['declaration']['field'] as $field) {
$colDesc = array(
...
...
@@ -79,6 +93,7 @@ class Doctrine_Import_Schema_Yml extends Doctrine_Import_Schema
$tables[(string) $table['name']] = $columns;
}
*/
return
$tables
;
}
...
...
tests/Export/RecordTestCase.php
View file @
99ae59fd
...
...
@@ -88,7 +88,7 @@ class Doctrine_Export_Record_TestCase extends Doctrine_UnitTestCase
public
function
testExportModelFromDirectory
()
{
Doctrine
::
export
(
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
'_files2'
);
Doctrine
::
export
Schema
(
dirname
(
__FILE__
)
.
DIRECTORY_SEPARATOR
.
'_files2'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'COMMIT'
);
$this
->
assertEqual
(
$this
->
adapter
->
pop
(),
'ALTER TABLE cms__category_languages ADD CONSTRAINT FOREIGN KEY (category_id) REFERENCES cms__category(id) ON DELETE CASCADE'
);
...
...
tests/Export/Schema/XmlTestCase.php
0 → 100644
View file @
99ae59fd
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Export_Schema_Xml_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Export_Schema_Xml_TestCase
extends
Doctrine_UnitTestCase
{
}
tests/Export/Schema/YmlTestCase.php
0 → 100644
View file @
99ae59fd
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Export_Schema_Yml_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Export_Schema_Yml_TestCase
extends
Doctrine_UnitTestCase
{
}
tests/Import/Schema/XmlTestCase.php
0 → 100644
View file @
99ae59fd
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Import_Schema_Xml_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Import_Schema_Xml_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testXmlImport
()
{
$import
=
new
Doctrine_Import_Schema_Xml
();
$import
->
importSchema
(
'schema.xml'
,
'classes'
);
if
(
!
file_exists
(
'classes/User.class.php'
))
{
$this
->
fail
();
}
else
{
unlink
(
'classes/User.class.php'
);
}
if
(
!
file_exists
(
'classes/Group.class.php'
))
{
$this
->
fail
();
}
else
{
unlink
(
'classes/Group.class.php'
);
}
}
}
\ No newline at end of file
tests/Import/Schema/YmlTestCase.php
0 → 100644
View file @
99ae59fd
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
*/
/**
* Doctrine_Import_Schema_Yml_TestCase
*
* @package Doctrine
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
Doctrine_Import_Schema_Yml_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testYmlImport
()
{
$import
=
new
Doctrine_Import_Schema_Yml
();
$import
->
importSchema
(
'schema.yml'
,
'classes'
);
if
(
!
file_exists
(
'classes/User.class.php'
))
{
$this
->
fail
();
}
else
{
unlink
(
'classes/User.class.php'
);
}
if
(
!
file_exists
(
'classes/Group.class.php'
))
{
$this
->
fail
();
}
else
{
unlink
(
'classes/Group.class.php'
);
}
}
}
\ No newline at end of file
tests/run.php
View file @
99ae59fd
...
...
@@ -326,6 +326,15 @@ $test->addTestCase(new Doctrine_Query_Cache_TestCase());
$test
->
addTestCase
(
new
Doctrine_Cache_Apc_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Query_SelectExpression_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Schema_Yml_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Import_Schema_Xml_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Export_Schema_Yml_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Export_Schema_Xml_TestCase
());
/**
$test->addTestCase(new Doctrine_Cache_Memcache_TestCase());
...
...
tests/schema.xml
0 → 100755
View file @
99ae59fd
<?xml version="1.0" encoding="ISO-8859-1" ?>
<tables>
<table>
<name>
user
</name>
<class>
User
</class>
<declaration>
<field>
<name>
id
</name>
<type>
integer
</type>
<notnull>
true
</notnull>
<autoincrement>
true
</autoincrement>
</field>
<field>
<name>
username
</name>
<type>
string
</type>
<length>
20
</length>
<notnull>
true
</notnull>
</field>
</declaration>
</table>
<table>
<name>
group
</name>
<class>
Group
</class>
<declaration>
<field>
<name>
id
</name>
<type>
integer
</type>
<notnull>
true
</notnull>
<autoincrement>
true
</autoincrement>
</field>
<field>
<name>
name
</name>
<type>
string
</type>
<length>
20
</length>
<notnull>
true
</notnull>
</field>
</declaration>
</table>
</tables>
\ No newline at end of file
tests/schema.yml
0 → 100644
View file @
99ae59fd
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