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
f2812766
Commit
f2812766
authored
Jun 15, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Cleanups, build fixes.
parent
e21d8fff
Changes
30
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
251 additions
and
307 deletions
+251
-307
build.xml
build.xml
+20
-6
SqlWalker.php
lib/Doctrine/ORM/Query/SqlWalker.php
+1
-1
annotations.php
lib/vendor/addendum/annotations.php
+12
-5
annotation_parser.php
lib/vendor/addendum/annotations/annotation_parser.php
+17
-0
acceptance_test.php
lib/vendor/addendum/annotations/tests/acceptance_test.php
+56
-0
all_tests.php
lib/vendor/addendum/annotations/tests/all_tests.php
+14
-19
annotation_parser_test.php
...dor/addendum/annotations/tests/annotation_parser_test.php
+23
-1
annotation_test.php
lib/vendor/addendum/annotations/tests/annotation_test.php
+2
-2
constrained_annotation_test.php
...ddendum/annotations/tests/constrained_annotation_test.php
+1
-3
ClassLoaderTest.php
tests/Doctrine/Tests/Common/ClassLoaderTest.php
+2
-0
DoctrineExceptionTest.php
tests/Doctrine/Tests/Common/DoctrineExceptionTest.php
+2
-0
EventManagerTest.php
tests/Doctrine/Tests/Common/EventManagerTest.php
+2
-0
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+9
-3
OracleSchemaManagerTest.php
.../Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
+5
-2
PostgreSqlSchemaManagerTest.php
...ts/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
+5
-2
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+4
-13
SqliteSchemaManagerTest.php
.../Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
+46
-19
AllTests.php
tests/Doctrine/Tests/ORM/AllTests.php
+0
-1
DqlGenerationTest.php
tests/Doctrine/Tests/ORM/Criteria/DqlGenerationTest.php
+4
-0
EntityPersisterTest.php
tests/Doctrine/Tests/ORM/EntityPersisterTest.php
+0
-74
AllTests.php
tests/Doctrine/Tests/ORM/Functional/AllTests.php
+1
-0
QueryTest.php
tests/Doctrine/Tests/ORM/Functional/QueryTest.php
+3
-3
ArrayHydratorTest.php
tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php
+9
-9
HydrationTestCase.php
tests/Doctrine/Tests/ORM/Hydration/HydrationTestCase.php
+1
-1
ObjectHydratorTest.php
tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php
+9
-9
ScalarHydratorTest.php
tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php
+1
-1
SingleScalarHydratorTest.php
...Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php
+1
-1
AllTests.php
tests/Doctrine/Tests/ORM/Query/AllTests.php
+0
-1
IdentifierRecognitionTest.php
tests/Doctrine/Tests/ORM/Query/IdentifierRecognitionTest.php
+0
-130
TestInit.php
tests/Doctrine/Tests/TestInit.php
+1
-1
No files found.
build.xml
View file @
f2812766
...
...
@@ -62,26 +62,40 @@
</copy>
</target>
<target
name=
"test"
>
<mkdir
dir=
"${build.dir}/logs"
/>
<mkdir
dir=
"reports/tests"
/>
<phpunit
printsummary=
"true"
haltonfailure=
"true"
>
<formatter
todir=
"${build.dir}/logs"
type=
"xml"
/>
<batchtest
classpath=
"tests"
>
<fileset
dir=
"tests"
>
<include
name=
"**/*Test.php"
/>
</fileset>
</batchtest>
</phpunit>
<!-- <phpunitreport infile="build/logs/testsuites.xml" format="frames" todir="reports/tests" />-->
</target>
<target
name=
"dist-common"
>
<tar
destfile=
"./dist/Doctrine2-common.tar.gz"
compression=
"gzip"
>
<fileset
dir=
"
./build
/common"
>
<fileset
dir=
"
${build.dir}
/common"
>
<include
name=
"**"
/>
</fileset>
</tar>
</target>
<target
name=
"dist-dbal"
>
<tar
destfile=
"
./dist
/Doctrine2-dbal.tar.gz"
compression=
"gzip"
>
<fileset
dir=
"
./build
/dbal"
>
<tar
destfile=
"
${dist.dir}
/Doctrine2-dbal.tar.gz"
compression=
"gzip"
>
<fileset
dir=
"
${build.dir}
/dbal"
>
<include
name=
"**"
/>
</fileset>
</tar>
</target>
<target
name=
"dist-all"
depends=
"build-all, dist-common, dist-dbal"
>
<target
name=
"dist-all"
depends=
"
test,
build-all, dist-common, dist-dbal"
>
<tar
destfile=
"
./dist
/Doctrine2-all.tar.gz"
compression=
"gzip"
>
<fileset
dir=
"
./build
/all"
>
<tar
destfile=
"
${dist.dir}
/Doctrine2-all.tar.gz"
compression=
"gzip"
>
<fileset
dir=
"
${build.dir}
/all"
>
<include
name=
"**"
/>
</fileset>
</tar>
...
...
lib/Doctrine/ORM/Query/SqlWalker.php
View file @
f2812766
...
...
@@ -41,7 +41,7 @@ class SqlWalker implements TreeWalker
private
$_aliasCounter
=
0
;
/** Counter for generating unique table aliases. */
private
$_tableAliasCounter
=
0
;
private
$_scalarResultCounter
=
0
;
private
$_scalarResultCounter
=
1
;
/** Counter for SQL parameter positions. */
private
$_sqlParamIndex
=
1
;
/** The ParserResult. */
...
...
lib/vendor/addendum/annotations.php
View file @
f2812766
...
...
@@ -24,23 +24,30 @@
class
Annotation
{
public
$value
;
private
static
$creationStack
=
array
();
public
final
function
__construct
(
$data
,
$target
)
{
$reflection
=
new
ReflectionClass
(
$this
);
$class
=
$reflection
->
getName
();
if
(
isset
(
self
::
$creationStack
[
$class
]))
{
trigger_error
(
"Circular annotation reference on '
$class
'"
,
E_USER_ERROR
);
return
;
}
self
::
$creationStack
[
$class
]
=
true
;
foreach
(
$data
as
$key
=>
$value
)
{
if
(
$reflection
->
hasProperty
(
$key
))
{
$this
->
$key
=
$value
;
}
else
{
$class
=
$reflection
->
getName
();
trigger_error
(
"Property '
$key
' not defined for annotation '
$class
'"
);
}
}
$this
->
checkTargetConstraints
(
$target
);
$this
->
checkConstraints
(
$target
);
unset
(
self
::
$creationStack
[
$class
]);
}
private
function
checkTargetConstraints
(
$target
)
{
$reflection
=
new
ReflectionAnnotatedClass
(
$this
);
/*
$reflection = new ReflectionAnnotatedClass($this);
if($reflection->hasAnnotation('Target')) {
$value = $reflection->getAnnotation('Target')->value;
$values = is_array($value) ? $value : array($value);
...
...
@@ -50,7 +57,7 @@
if($value == 'property' && $target instanceof ReflectionProperty) return;
}
trigger_error("Annotation '".get_class($this)."' not allowed on ".$this->createName($target), E_USER_ERROR);
}
}
*/
}
private
function
createName
(
$target
)
{
...
...
@@ -66,7 +73,7 @@
protected
function
checkConstraints
(
$target
)
{}
}
class
Target
extends
Annotation
{}
//
class Target extends Annotation {}
class
AnnotationsBuilder
{
private
static
$cache
=
array
();
...
...
@@ -75,7 +82,7 @@
$data
=
$this
->
parse
(
$targetReflection
);
$annotations
=
array
();
foreach
(
$data
as
$class
=>
$parameters
)
{
if
(
!
Addendum
::
ignores
(
$class
))
{
if
(
is_subclass_of
(
$class
,
'Annotation'
)
&&
!
Addendum
::
ignores
(
$class
))
{
foreach
(
$parameters
as
$params
)
{
$annotationReflection
=
new
ReflectionClass
(
$class
);
$annotations
[
$class
][]
=
$annotationReflection
->
newInstance
(
$params
,
$targetReflection
);
...
...
lib/vendor/addendum/annotations/annotation_parser.php
View file @
f2812766
...
...
@@ -190,6 +190,7 @@
$this
->
add
(
new
AnnotationStringMatcher
);
$this
->
add
(
new
AnnotationNumberMatcher
);
$this
->
add
(
new
AnnotationArrayMatcher
);
$this
->
add
(
new
AnnotationStaticConstantMatcher
);
}
}
...
...
@@ -332,4 +333,20 @@
return
$matches
[
1
];
}
}
class
AnnotationStaticConstantMatcher
extends
RegexMatcher
{
public
function
__construct
()
{
parent
::
__construct
(
'(\w+::\w+)'
);
}
protected
function
process
(
$matches
)
{
$name
=
$matches
[
1
];
if
(
!
defined
(
$name
))
{
trigger_error
(
"Constant '
$name
' used in annotation was not defined."
);
return
false
;
}
return
constant
(
$name
);
}
}
?>
lib/vendor/addendum/annotations/tests/acceptance_test.php
View file @
f2812766
...
...
@@ -35,6 +35,32 @@
class
FirstAnnotation
extends
Annotation
{}
class
SecondAnnotation
extends
Annotation
{}
class
NoAnnotation
{}
/** @NoAnnotation @FirstAnnotation */
class
ExampleWithInvalidAnnotation
{}
/** @SelfReferencingAnnotation */
class
SelfReferencingAnnotation
extends
Annotation
{}
/** @IndirectReferenceLoopAnnotationHelper */
class
IndirectReferenceLoopAnnotation
extends
Annotation
{}
/** @IndirectReferenceLoopAnnotation */
class
IndirectReferenceLoopAnnotationHelper
extends
Annotation
{}
class
Statics
{
const
A_CONSTANT
=
'constant'
;
static
public
$static
=
'static'
;
}
/** @FirstAnnotation(Statics::A_CONSTANT) */
class
ClassAnnotatedWithStaticConstant
{}
/** @FirstAnnotation(Statics::UNKNOWN_CONSTANT) */
class
ClassAnnotatedWithNonExistingConstant
{}
class
TestOfAnnotations
extends
UnitTestCase
{
public
function
testReflectionAnnotatedClass
()
{
...
...
@@ -192,6 +218,36 @@
$this
->
assertIsA
(
$annotations
[
0
],
'FirstAnnotation'
);
$this
->
assertIsA
(
$annotations
[
1
],
'FirstAnnotation'
);
}
public
function
testClassWithNoAnnotationParentShouldNotBeParsed
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'ExampleWithInvalidAnnotation'
);
$annotations
=
$reflection
=
$reflection
->
getAnnotations
();
$this
->
assertEqual
(
count
(
$annotations
),
1
);
$this
->
assertIsA
(
$annotations
[
0
],
'FirstAnnotation'
);
}
public
function
testCircularReferenceShouldThrowError
()
{
$this
->
expectError
(
"Circular annotation reference on 'SelfReferencingAnnotation'"
);
$reflection
=
new
ReflectionAnnotatedClass
(
'SelfReferencingAnnotation'
);
$reflection
->
getAnnotations
();
$this
->
expectError
(
"Circular annotation reference on 'IndirectReferenceLoopAnnotationHelper'"
);
$reflection
=
new
ReflectionAnnotatedClass
(
'IndirectReferenceLoopAnnotation'
);
$reflection
->
getAnnotations
();
}
public
function
testConstInAnnotationShouldReturnCorrectValue
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'ClassAnnotatedWithStaticConstant'
);
$annotation
=
$reflection
->
getAnnotation
(
'FirstAnnotation'
);
$this
->
assertEqual
(
$annotation
->
value
,
Statics
::
A_CONSTANT
);
}
public
function
testBadConstInAnnotationShouldCauseError
()
{
$this
->
expectError
(
"Constant 'Statics::UNKNOWN_CONSTANT' used in annotation was not defined."
);
$reflection
=
new
ReflectionAnnotatedClass
(
'ClassAnnotatedWithNonExistingConstant'
);
$annotation
=
$reflection
->
getAnnotation
(
'FirstAnnotation'
);
}
}
Mock
::
generatePartial
(
'AnnotationsBuilder'
,
'MockedAnnotationsBuilder'
,
array
(
'getDocComment'
));
...
...
lib/vendor/addendum/annotations/tests/all_tests.php
View file @
f2812766
...
...
@@ -8,26 +8,21 @@
require_once
(
dirname
(
__FILE__
)
.
'/annotation_parser_test.php'
);
require_once
(
dirname
(
__FILE__
)
.
'/doc_comment_test.php'
);
class
AllTests
extends
GroupTest
{
function
__construct
(
$title
=
false
)
{
parent
::
__construct
(
$title
);
$this
->
addTestClass
(
'TestOfAnnotations'
);
$this
->
addTestClass
(
'TestOfPerformanceFeatures'
);
$this
->
addTestClass
(
'TestOfSupportingFeatures'
);
$this
->
addTestClass
(
'TestOfAnnotation'
);
$this
->
addTestClass
(
'TestOfConstrainedAnnotation'
);
$this
->
addTestClass
(
'TestOfMatchers'
);
$this
->
addTestClass
(
'TestOfAnnotationMatchers'
);
$this
->
addTestClass
(
'TestOfDocComment'
);
}
}
$suite
=
new
TestSuite
(
'All tests'
);
$suite
->
add
(
new
TestOfAnnotations
);
$suite
->
add
(
new
TestOfPerformanceFeatures
);
$suite
->
add
(
new
TestOfSupportingFeatures
);
$suite
->
add
(
new
TestOfAnnotation
);
$suite
->
add
(
new
TestOfConstrainedAnnotation
);
$suite
->
add
(
new
TestOfMatchers
);
$suite
->
add
(
new
TestOfAnnotationMatchers
);
$suite
->
add
(
new
TestOfDocComment
);
$reporter
=
TextReporter
::
inCli
()
?
new
TextReporter
()
:
new
HtmlReporter
();
Addendum
::
setRawMode
(
false
);
$test
=
new
AllTests
(
'All tests in reflection mode'
);
$test
->
run
(
new
HtmlReporter
());
$suite
->
run
(
$reporter
);
Addendum
::
setRawMode
(
true
);
$test
=
new
AllTests
(
'All tests in raw mode'
);
$test
->
run
(
new
HtmlReporter
());
$suite
->
run
(
$reporter
);
?>
lib/vendor/addendum/annotations/tests/annotation_parser_test.php
View file @
f2812766
...
...
@@ -48,6 +48,11 @@
$this
->
assertEqual
(
$value
,
'1234'
);
}
}
class
StaticClass
{
const
A_CONSTANT
=
'constant'
;
}
class
TestOfAnnotationMatchers
extends
UnitTestCase
{
public
function
testAnnotationsMatcherShouldMatchAnnotationWithGarbage
()
{
...
...
@@ -185,6 +190,11 @@
$matcher
=
new
AnnotationValueMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'{1}'
,
array
(
1
));
}
public
function
testValueMatcherShouldMatchStaticConstant
()
{
$matcher
=
new
AnnotationValueMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'StaticClass::A_CONSTANT'
,
StaticClass
::
A_CONSTANT
);
}
public
function
testArrayMatcherShouldMatchEmptyArray
()
{
$matcher
=
new
AnnotationArrayMatcher
;
...
...
@@ -299,6 +309,18 @@
$this
->
assertMatcherResult
(
$matcher
,
'"string\"string"'
,
'string"string'
);
$this
->
assertMatcherResult
(
$matcher
,
"'string\'string'"
,
"string'string"
);
}
public
function
testStaticConstantMatcherShouldMatchConstants
()
{
$matcher
=
new
AnnotationStaticConstantMatcher
;
$this
->
assertMatcherResult
(
$matcher
,
'StaticClass::A_CONSTANT'
,
StaticClass
::
A_CONSTANT
);
}
public
function
testStaticConstantMatcherShouldThrowErrorOnBadConstant
()
{
$this
->
expectError
(
"Constant 'StaticClass::NO_CONSTANT' used in annotation was not defined."
);
$matcher
=
new
AnnotationStaticConstantMatcher
;
$matcher
->
matches
(
'StaticClass::NO_CONSTANT'
,
$value
);
}
private
function
assertNotFalse
(
$value
)
{
$this
->
assertNotIdentical
(
$value
,
false
);
...
...
@@ -309,4 +331,4 @@
$this
->
assertIdentical
(
$value
,
$expected
);
}
}
?>
\ No newline at end of file
?>
lib/vendor/addendum/annotations/tests/annotation_test.php
View file @
f2812766
...
...
@@ -15,13 +15,13 @@
}
public
function
testConstructorThrowsErrorOnInvalidParameter
()
{
$this
->
expectError
(
"Property 'unknown' not defined for annotation 'TestingAnnotation'"
);
$annotation
=
new
TestingAnnotation
(
array
(
'unknown'
=>
1
),
$this
);
$this
->
assertError
(
"Property 'unknown' not defined for annotation 'TestingAnnotation'"
);
}
public
function
TODO_testConstructorThrowsErrorWithoutSpecifingRequiredParameters
()
{
$this
->
expectError
(
"Property 'required' in annotation 'TestingAnnotation' is required"
);
$annotation
=
new
TestingAnnotation
();
$this
->
assertError
(
"Property 'required' in annotation 'TestingAnnotation' is required"
);
}
}
?>
lib/vendor/addendum/annotations/tests/constrained_annotation_test.php
View file @
f2812766
...
...
@@ -55,7 +55,6 @@
$reflection
=
new
ReflectionAnnotatedClass
(
'SuccesfullyAnnotatedClass'
);
$method
=
$reflection
->
getMethod
(
'method'
);
$property
=
$reflection
->
getProperty
(
'property'
);
$this
->
assertNoErrors
();
}
public
function
testMultiTargetAnnotationThrowsErrorWhenOnWrongPlace
()
{
...
...
@@ -67,7 +66,6 @@
public
function
testMultiTargetAnnotationThrowsNoErrorWhenOnRightPlace
()
{
$reflection
=
new
ReflectionAnnotatedClass
(
'SuccesfullyAnnotatedClass'
);
$method
=
$reflection
->
getProperty
(
'property2'
);
$this
->
assertNoErrors
();
}
}
?>
\ No newline at end of file
?>
tests/Doctrine/Tests/Common/ClassLoaderTest.php
View file @
f2812766
...
...
@@ -4,6 +4,8 @@ namespace Doctrine\Tests\Common;
use
Doctrine\Common\ClassLoader
;
require_once
__DIR__
.
'/../TestInit.php'
;
class
ClassLoaderTest
extends
\Doctrine\Tests\DoctrineTestCase
{
public
function
testCustomFileExtensionAndNamespaceSeparator
()
...
...
tests/Doctrine/Tests/Common/DoctrineExceptionTest.php
View file @
f2812766
...
...
@@ -2,6 +2,8 @@
namespace
Doctrine\Tests\Common
;
require_once
__DIR__
.
'/../TestInit.php'
;
class
DoctrineExceptionTest
extends
\Doctrine\Tests\DoctrineTestCase
{
public
function
testStaticCall
()
...
...
tests/Doctrine/Tests/Common/EventManagerTest.php
View file @
f2812766
...
...
@@ -5,6 +5,8 @@ namespace Doctrine\Tests\Common;
use
Doctrine\Common\EventManager
;
use
Doctrine\Common\EventArgs
;
require_once
__DIR__
.
'/../TestInit.php'
;
class
EventManagerTest
extends
\Doctrine\Tests\DoctrineTestCase
{
/* Some pseudo events */
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
f2812766
...
...
@@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema;
require_once
__DIR__
.
'/../../../TestInit.php'
;
class
MySqlSchemaManagerTest
extends
SchemaManagerFunctionalTest
class
MySqlSchemaManagerTest
extends
SchemaManagerFunctionalTest
Case
{
public
function
testListDatabases
()
{
...
...
@@ -15,14 +15,20 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTest
$this
->
assertEquals
(
true
,
in_array
(
'test_create_database'
,
$databases
));
}
/**
* @expectedException \Exception
*/
public
function
testListFunctions
()
{
return
$this
->
assertUnsupportedMethod
(
'listFunctions'
);
$this
->
_sm
->
listFunctions
(
);
}
/**
* @expectedException \Exception
*/
public
function
testListTriggers
()
{
return
$this
->
assertUnsupportedMethod
(
'listTriggers'
);
$this
->
_sm
->
listTriggers
(
);
}
public
function
testListSequences
()
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/OracleSchemaManagerTest.php
View file @
f2812766
...
...
@@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema;
require_once
__DIR__
.
'/../../../TestInit.php'
;
class
OracleSchemaManagerTest
extends
SchemaManagerFunctionalTest
class
OracleSchemaManagerTest
extends
SchemaManagerFunctionalTest
Case
{
public
function
testListDatabases
()
{
...
...
@@ -21,9 +21,12 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTest
$this
->
assertEquals
(
array
(),
$functions
);
}
/**
* @expectedException \Exception
*/
public
function
testListTriggers
()
{
return
$this
->
assertUnsupportedMethod
(
'listTriggers'
);
$this
->
_sm
->
listTriggers
(
);
}
public
function
testListSequences
()
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/PostgreSqlSchemaManagerTest.php
View file @
f2812766
...
...
@@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema;
require_once
__DIR__
.
'/../../../TestInit.php'
;
class
PostgreSqlSchemaManagerTest
extends
SchemaManagerFunctionalTest
class
PostgreSqlSchemaManagerTest
extends
SchemaManagerFunctionalTest
Case
{
public
function
testListDatabases
()
{
...
...
@@ -15,9 +15,12 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTest
$this
->
assertEquals
(
true
,
in_array
(
'test_create_database'
,
$databases
));
}
/**
* @expectedException \Exception
*/
public
function
testListFunctions
()
{
return
$this
->
assertUnsupportedMethod
(
'listFunctions'
);
$this
->
_sm
->
listFunctions
(
);
}
public
function
testListTriggers
()
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTest.php
→
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTest
Case
.php
View file @
f2812766
...
...
@@ -4,7 +4,9 @@ namespace Doctrine\Tests\DBAL\Functional\Schema;
use
Doctrine\DBAL\Types\Type
;
class
SchemaManagerFunctionalTest
extends
\Doctrine\Tests\DbalFunctionalTestCase
require_once
__DIR__
.
'/../../../TestInit.php'
;
class
SchemaManagerFunctionalTestCase
extends
\Doctrine\Tests\DbalFunctionalTestCase
{
protected
function
setUp
()
{
...
...
@@ -23,7 +25,7 @@ class SchemaManagerFunctionalTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
_sm
=
$this
->
_conn
->
getSchemaManager
();
}
p
ublic
function
createTestTable
(
$name
=
'test_table'
,
$data
=
array
())
p
rotected
function
createTestTable
(
$name
=
'test_table'
,
$data
=
array
())
{
if
(
!
isset
(
$data
[
'columns'
]))
{
$columns
=
array
(
...
...
@@ -52,15 +54,4 @@ class SchemaManagerFunctionalTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
_sm
->
dropAndCreateTable
(
$name
,
$columns
,
$options
);
}
public
function
assertUnsupportedMethod
(
$method
)
{
try
{
$this
->
_sm
->
$method
();
}
catch
(
\Exception
$e
)
{
return
;
}
$this
->
fail
(
$method
.
'() should throw an exception because it is not supported in '
.
$this
->
_conn
->
getDatabasePlatform
()
->
getName
());
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
View file @
f2812766
...
...
@@ -6,21 +6,30 @@ use Doctrine\DBAL\Schema;
require_once
__DIR__
.
'/../../../TestInit.php'
;
class
SqliteSchemaManagerTest
extends
SchemaManagerFunctionalTest
class
SqliteSchemaManagerTest
extends
SchemaManagerFunctionalTest
Case
{
/**
* @expectedException \Exception
*/
public
function
testListDatabases
()
{
return
$this
->
assertUnsupportedMethod
(
'listDatabases'
);
$this
->
_sm
->
listDatabases
(
);
}
/**
* @expectedException \Exception
*/
public
function
testListFunctions
()
{
return
$this
->
assertUnsupportedMethod
(
'listFunctions'
);
$this
->
_sm
->
listFunctions
(
);
}
/**
* @expectedException \Exception
*/
public
function
testListTriggers
()
{
return
$this
->
assertUnsupportedMethod
(
'listTriggers'
);
$this
->
_sm
->
listTriggers
(
);
}
public
function
testListSequences
()
...
...
@@ -92,9 +101,12 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
$this
->
assertEquals
(
true
,
in_array
(
'list_tables_test'
,
$tables
));
}
/**
* @expectedException \Exception
*/
public
function
testListUsers
()
{
return
$this
->
assertUnsupportedMethod
(
'listUsers'
);
$this
->
_sm
->
listUsers
(
);
}
public
function
testListViews
()
...
...
@@ -157,14 +169,12 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
$this
->
assertEquals
(
null
,
$tableColumns
[
1
][
'default'
]);
}
/**
* @expectedException \Exception
*/
public
function
testCreateSequence
()
{
return
$this
->
assertUnsupportedMethod
(
'createSequence'
);
}
public
function
testCreateConstraint
()
{
return
$this
->
assertUnsupportedMethod
(
'createConstraint'
);
$this
->
_sm
->
createSequence
(
'seqname'
,
1
,
1
);
}
/* FIXME: See comment in AbstractSchemaManager#dropIndex($table, $name)
...
...
@@ -185,34 +195,51 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTest
$this->assertEquals(true, $tableIndexes[0]['unique']);
}*/
/**
* @expectedException \Exception
*/
public
function
testCreateForeignKey
()
{
return
$this
->
assertUnsupportedMethod
(
'createForeignKey'
);
$this
->
_sm
->
createForeignKey
(
'table'
,
array
()
);
}
/**
* @expectedException \Exception
*/
public
function
testRenameTable
()
{
return
$this
->
assertUnsupportedMethod
(
'renameTabl
e'
);
$this
->
_sm
->
renameTable
(
'oldname'
,
'newnam
e'
);
}
/**
* @expectedException \Exception
*/
public
function
testAddTableColumn
()
{
return
$this
->
assertUnsupportedMethod
(
'addTableColumn'
);
return
$this
->
_sm
->
addTableColumn
(
'table'
,
'column'
,
array
()
);
}
/**
* @expectedException \Exception
*/
public
function
testRemoveTableColumn
()
{
return
$this
->
assertUnsupportedMethod
(
'removeTableC
olumn'
);
$this
->
_sm
->
removeTableColumn
(
'table'
,
'c
olumn'
);
}
/**
* @expectedException \Exception
*/
public
function
testChangeTableColumn
()
{
return
$this
->
assertUnsupportedMethod
(
'changeTableColumn'
);
$this
->
_sm
->
changeTableColumn
(
'name'
,
'type'
,
null
,
array
()
);
}
/**
* @expectedException \Exception
*/
public
function
testRenameTableColumn
()
{
return
$this
->
assertUnsupportedMethod
(
'renameTableColumn'
);
$this
->
_sm
->
renameTableColumn
(
'table'
,
'old'
,
'new'
,
array
()
);
}
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/AllTests.php
View file @
f2812766
...
...
@@ -30,7 +30,6 @@ class AllTests
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\UnitOfWorkTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\EntityManagerTest'
);
//$suite->addTestSuite('Doctrine\Tests\ORM\EntityPersisterTest');
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\CommitOrderCalculatorTest'
);
$suite
->
addTest
(
Query\AllTests
::
suite
());
...
...
tests/Doctrine/Tests/ORM/Criteria/DqlGenerationTest.php
View file @
f2812766
...
...
@@ -36,6 +36,10 @@ require_once __DIR__ . '/../../TestInit.php';
*/
class
DqlGenerationTest
extends
\Doctrine\Tests\OrmTestCase
{
protected
function
setUp
()
{
$this
->
markTestSkipped
(
'Not yet implemented.'
);
}
protected
function
createQuery
()
{
return
$this
->
_em
->
createQuery
();
...
...
tests/Doctrine/Tests/ORM/EntityPersisterTest.php
deleted
100644 → 0
View file @
e21d8fff
<?php
namespace
Doctrine\Tests\ORM
;
use
Doctrine\Tests\Mocks\ConnectionMock
;
use
Doctrine\Tests\Mocks\EntityManagerMock
;
use
Doctrine\Tests\Mocks\UnitOfWorkMock
;
use
Doctrine\Tests\Mocks\SequenceMock
;
use
Doctrine\Tests\Models\Forum\ForumUser
;
use
Doctrine\Tests\Models\Forum\ForumAvatar
;
require_once
__DIR__
.
'/../TestInit.php'
;
class
EntityPersisterTest
extends
\Doctrine\Tests\OrmTestCase
{
private
$_connMock
;
private
$_emMock
;
private
$_idGenMock
;
private
$_uowMock
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
_connMock
=
new
ConnectionMock
(
array
(),
new
\Doctrine\Tests\Mocks\DriverMock
());
$this
->
_emMock
=
EntityManagerMock
::
create
(
$this
->
_connMock
);
$this
->
_uowMock
=
new
UnitOfWorkMock
(
$this
->
_emMock
);
$this
->
_emMock
->
setUnitOfWork
(
$this
->
_uowMock
);
$this
->
_idGenMock
=
new
SequenceMock
(
$this
->
_emMock
,
'seq'
,
20
);
//$this->_emMock->setIdGenerator('Doctrine\Tests\Models\Forum\ForumUser', $this->_idGenMock);
}
public
function
testSimpleInsert
()
{
$userPersister
=
new
\Doctrine\ORM\Persisters\SingleTablePersister
(
$this
->
_emMock
,
$this
->
_emMock
->
getClassMetadata
(
"Doctrine\Tests\Models\Forum\ForumUser"
));
$avatarPersister
=
new
\Doctrine\ORM\Persisters\StandardEntityPersister
(
$this
->
_emMock
,
$this
->
_emMock
->
getClassMetadata
(
"Doctrine\Tests\Models\Forum\ForumAvatar"
));
$user
=
new
ForumUser
();
$user
->
username
=
"romanb"
;
$user
->
avatar
=
new
ForumAvatar
();
$this
->
_uowMock
->
setDataChangeSet
(
$user
,
array
(
'username'
=>
array
(
''
,
'romanb'
),
'avatar'
=>
array
(
''
,
$user
->
avatar
)));
//insert
$avatarPersister
->
insert
(
$user
->
avatar
);
$inserts
=
$this
->
_connMock
->
getInserts
();
//check
$this
->
assertEquals
(
1
,
count
(
$inserts
));
$this
->
assertTrue
(
isset
(
$inserts
[
'forum_avatars'
]));
$this
->
assertEquals
(
1
,
count
(
$inserts
[
'forum_avatars'
]));
$this
->
assertEquals
(
null
,
$user
->
avatar
->
id
);
$user
->
avatar
->
id
=
0
;
// Fake that we got an id
//insert
$userPersister
->
insert
(
$user
);
$inserts
=
$this
->
_connMock
->
getInserts
();
//check
$this
->
assertEquals
(
2
,
count
(
$inserts
));
$this
->
assertEquals
(
null
,
$user
->
id
);
$this
->
assertTrue
(
isset
(
$inserts
[
'forum_users'
]));
$this
->
assertEquals
(
1
,
count
(
$inserts
[
'forum_users'
]));
$this
->
assertEquals
(
3
,
count
(
$inserts
[
'forum_users'
][
0
]));
//username column
$this
->
assertTrue
(
isset
(
$inserts
[
'forum_users'
][
0
][
'username'
]));
$this
->
assertEquals
(
'romanb'
,
$inserts
[
'forum_users'
][
0
][
'username'
]);
//avatar_id join column
$this
->
assertTrue
(
isset
(
$inserts
[
'forum_users'
][
0
][
'avatar_id'
]));
$this
->
assertEquals
(
0
,
$inserts
[
'forum_users'
][
0
][
'avatar_id'
]);
}
}
\ No newline at end of file
tests/Doctrine/Tests/ORM/Functional/AllTests.php
View file @
f2812766
...
...
@@ -25,6 +25,7 @@ class AllTests
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\ClassTableInheritanceTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\DetachedEntityTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\QueryCacheTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Functional\QueryTest'
);
return
$suite
;
}
...
...
tests/Doctrine/Tests/ORM/Functional/QueryTest.php
View file @
f2812766
...
...
@@ -31,9 +31,9 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
_em
->
clear
();
$query
=
$this
->
_em
->
createQuery
(
"select u, upper(u.name) from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"
);
$result
=
$query
->
getResultList
();
$this
->
assertEquals
(
1
,
count
(
$result
));
$this
->
assertTrue
(
$result
[
0
][
0
]
instanceof
CmsUser
);
$this
->
assertEquals
(
'Guilherme'
,
$result
[
0
][
0
]
->
name
);
...
...
@@ -54,7 +54,7 @@ class QueryTest extends \Doctrine\Tests\OrmFunctionalTestCase
$this
->
assertEquals
(
'Guilherme'
,
$scalarResult
[
0
][
'u_name'
]);
$this
->
assertEquals
(
'gblanco'
,
$scalarResult
[
0
][
'u_username'
]);
$this
->
assertEquals
(
'developer'
,
$scalarResult
[
0
][
'u_status'
]);
$this
->
assertEquals
(
'GUILHERME'
,
$scalarResult
[
0
][
'dctrn_1'
]);
$this
->
assertEquals
(
'GUILHERME'
,
$scalarResult
[
0
][
1
]);
$query
=
$this
->
_em
->
createQuery
(
"select upper(u.name) from Doctrine\Tests\Models\CMS\CmsUser u where u.username = 'gblanco'"
);
$this
->
assertEquals
(
'GUILHERME'
,
$query
->
getSingleScalarResult
());
...
...
tests/Doctrine/Tests/ORM/Hydration/ArrayHydratorTest.php
View file @
f2812766
...
...
@@ -7,12 +7,12 @@ use Doctrine\ORM\Query\ResultSetMapping;
require_once
__DIR__
.
'/../../TestInit.php'
;
class
ArrayHydratorTest
extends
HydrationTest
class
ArrayHydratorTest
extends
HydrationTest
Case
{
/**
* Select u.id, u.name from Doctrine\Tests\Models\CMS\CmsUser u
*/
public
function
test
NewHydration
SimpleEntityQuery
()
public
function
testSimpleEntityQuery
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -48,7 +48,7 @@ class ArrayHydratorTest extends HydrationTest
/**
*
*/
public
function
test
NewHydration
SimpleMultipleRootEntityQuery
()
public
function
testSimpleMultipleRootEntityQuery
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -99,7 +99,7 @@ class ArrayHydratorTest extends HydrationTest
* select u.id, u.status, p.phonenumber, upper(u.name) as u__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
*/
public
function
test
NewHydration
MixedQueryFetchJoin
()
public
function
testMixedQueryFetchJoin
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -166,7 +166,7 @@ class ArrayHydratorTest extends HydrationTest
* select u.id, u.status, count(p.phonenumber) as p__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id group by u.id, u.status
*/
public
function
test
NewHydration
MixedQueryNormalJoin
()
public
function
testMixedQueryNormalJoin
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -211,7 +211,7 @@ class ArrayHydratorTest extends HydrationTest
* select u.id, u.status, upper(u.name) as p__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
*/
public
function
test
NewHydration
MixedQueryFetchJoinCustomIndex
()
public
function
testMixedQueryFetchJoinCustomIndex
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -286,7 +286,7 @@ class ArrayHydratorTest extends HydrationTest
* inner join PHONENUMBERS p ON u.id = p.user_id
* inner join ARTICLES a ON u.id = a.user_id
*/
public
function
test
NewHydration
MixedQueryMultipleFetchJoin
()
public
function
testMixedQueryMultipleFetchJoin
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -405,7 +405,7 @@ class ArrayHydratorTest extends HydrationTest
* inner join ARTICLES a ON u.id = a.user_id
* left outer join COMMENTS c ON a.id = c.article_id
*/
public
function
test
NewHydration
MixedQueryMultipleDeepMixedFetchJoin
()
public
function
testMixedQueryMultipleDeepMixedFetchJoin
()
{
$rsm
=
new
ResultSetMapping
;
...
...
@@ -563,7 +563,7 @@ class ArrayHydratorTest extends HydrationTest
* 1 | 0 | First | 1 | 3 | 1
* 1 | 0 | First | 2 | 4 | 1
*/
public
function
test
NewHydration
EntityQueryCustomResultSetOrder
()
public
function
testEntityQueryCustomResultSetOrder
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\Forum\ForumCategory'
,
'c'
);
...
...
tests/Doctrine/Tests/ORM/Hydration/HydrationTest.php
→
tests/Doctrine/Tests/ORM/Hydration/HydrationTest
Case
.php
View file @
f2812766
...
...
@@ -7,7 +7,7 @@ require_once __DIR__ . '/../../TestInit.php';
use
Doctrine\ORM\Query\ParserResult
;
use
Doctrine\ORM\Query\Parser
;
class
HydrationTest
extends
\Doctrine\Tests\OrmTestCase
class
HydrationTest
Case
extends
\Doctrine\Tests\OrmTestCase
{
protected
$_em
;
...
...
tests/Doctrine/Tests/ORM/Hydration/ObjectHydratorTest.php
View file @
f2812766
...
...
@@ -7,12 +7,12 @@ use Doctrine\ORM\Query\ResultSetMapping;
require_once
__DIR__
.
'/../../TestInit.php'
;
class
ObjectHydratorTest
extends
HydrationTest
class
ObjectHydratorTest
extends
HydrationTest
Case
{
/**
* Select u.id, u.name from \Doctrine\Tests\Models\CMS\CmsUser u
*/
public
function
test
NewHydration
SimpleEntityQuery
()
public
function
testSimpleEntityQuery
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -49,7 +49,7 @@ class ObjectHydratorTest extends HydrationTest
/**
* Select u.id, u.name from \Doctrine\Tests\Models\CMS\CmsUser u
*/
public
function
test
NewHydration
SimpleMultipleRootEntityQuery
()
public
function
testSimpleMultipleRootEntityQuery
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -105,7 +105,7 @@ class ObjectHydratorTest extends HydrationTest
* select u.id, u.status, p.phonenumber, upper(u.name) as u__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
*/
public
function
test
NewHydration
MixedQueryFetchJoin
()
public
function
testMixedQueryFetchJoin
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -179,7 +179,7 @@ class ObjectHydratorTest extends HydrationTest
* select u.id, u.status, count(p.phonenumber) as p__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id group by u.id, u.status
*/
public
function
test
NewHydration
MixedQueryNormalJoin
()
public
function
testMixedQueryNormalJoin
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -226,7 +226,7 @@ class ObjectHydratorTest extends HydrationTest
* select u.id, u.status, upper(u.name) as p__0 from USERS u
* INNER JOIN PHONENUMBERS p ON u.id = p.user_id
*/
public
function
test
NewHydration
MixedQueryFetchJoinCustomIndex
()
public
function
testMixedQueryFetchJoinCustomIndex
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -305,7 +305,7 @@ class ObjectHydratorTest extends HydrationTest
* inner join PHONENUMBERS p ON u.id = p.user_id
* inner join ARTICLES a ON u.id = a.user_id
*/
public
function
test
NewHydration
MixedQueryMultipleFetchJoin
()
public
function
testMixedQueryMultipleFetchJoin
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -420,7 +420,7 @@ class ObjectHydratorTest extends HydrationTest
* inner join ARTICLES a ON u.id = a.user_id
* left outer join COMMENTS c ON a.id = c.article_id
*/
public
function
test
NewHydration
MixedQueryMultipleDeepMixedFetchJoin
()
public
function
testMixedQueryMultipleDeepMixedFetchJoin
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\CMS\CmsUser'
,
'u'
);
...
...
@@ -571,7 +571,7 @@ class ObjectHydratorTest extends HydrationTest
* 1 | 0 | First | 1 | 3 | 1
* 1 | 0 | First | 2 | 4 | 1
*/
public
function
test
NewHydration
EntityQueryCustomResultSetOrder
()
public
function
testEntityQueryCustomResultSetOrder
()
{
$rsm
=
new
ResultSetMapping
;
$rsm
->
addEntityResult
(
'Doctrine\Tests\Models\Forum\ForumCategory'
,
'c'
);
...
...
tests/Doctrine/Tests/ORM/Hydration/ScalarHydratorTest.php
View file @
f2812766
...
...
@@ -7,7 +7,7 @@ use Doctrine\ORM\Query\ResultSetMapping;
require_once
__DIR__
.
'/../../TestInit.php'
;
class
ScalarHydratorTest
extends
HydrationTest
class
ScalarHydratorTest
extends
HydrationTest
Case
{
/**
* Select u.id, u.name from CmsUser u
...
...
tests/Doctrine/Tests/ORM/Hydration/SingleScalarHydratorTest.php
View file @
f2812766
...
...
@@ -7,7 +7,7 @@ use Doctrine\ORM\Query\ResultSetMapping;
require_once
__DIR__
.
'/../../TestInit.php'
;
class
SingleScalarHydratorTest
extends
HydrationTest
class
SingleScalarHydratorTest
extends
HydrationTest
Case
{
/** Result set provider for the HYDRATE_SINGLE_SCALAR tests */
public
static
function
singleScalarResultSetProvider
()
{
...
...
tests/Doctrine/Tests/ORM/Query/AllTests.php
View file @
f2812766
...
...
@@ -19,7 +19,6 @@ class AllTests
{
$suite
=
new
\Doctrine\Tests\DoctrineTestSuite
(
'Doctrine Orm Query'
);
//$suite->addTestSuite('Doctrine\Tests\ORM\Query\IdentifierRecognitionTest');
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Query\SelectSqlGenerationTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Query\LanguageRecognitionTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\ORM\Query\LexerTest'
);
...
...
tests/Doctrine/Tests/ORM/Query/IdentifierRecognitionTest.php
deleted
100644 → 0
View file @
e21d8fff
<?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.doctrine-project.org>.
*/
namespace
Doctrine\Tests\ORM\Query
;
require_once
__DIR__
.
'/../../TestInit.php'
;
/**
* Test case for testing the saving and referencing of query identifiers.
*
* @author Guilherme Blanco <guilhermeblanco@hotmail.com>
* @author Janne Vanhala <jpvanhal@cc.hut.fi>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link http://www.phpdoctrine.org
* @since 2.0
* @version $Revision$
*/
class
IdentifierRecognitionTest
extends
\Doctrine\Tests\OrmTestCase
{
private
$_em
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
_em
=
$this
->
_getTestEntityManager
();
}
public
function
testSingleAliasDeclarationIsSupported
()
{
$entityManager
=
$this
->
_em
;
$query
=
$entityManager
->
createQuery
(
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u'
);
$parserResult
=
$query
->
parse
();
$decl
=
$parserResult
->
getQueryComponent
(
'u'
);
$this
->
assertTrue
(
$decl
[
'metadata'
]
instanceof
\Doctrine\ORM\Mapping\ClassMetadata
);
$this
->
assertEquals
(
null
,
$decl
[
'relation'
]);
$this
->
assertEquals
(
null
,
$decl
[
'parent'
]);
$this
->
assertEquals
(
null
,
$decl
[
'scalar'
]);
$this
->
assertEquals
(
null
,
$decl
[
'map'
]);
}
public
function
testSingleAliasDeclarationWithIndexByIsSupported
()
{
$entityManager
=
$this
->
_em
;
$query
=
$entityManager
->
createQuery
(
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id'
);
$parserResult
=
$query
->
parse
();
$decl
=
$parserResult
->
getQueryComponent
(
'u'
);
$this
->
assertTrue
(
$decl
[
'metadata'
]
instanceof
\Doctrine\ORM\Mapping\ClassMetadata
);
$this
->
assertEquals
(
null
,
$decl
[
'relation'
]);
$this
->
assertEquals
(
null
,
$decl
[
'parent'
]);
$this
->
assertEquals
(
null
,
$decl
[
'scalar'
]);
$this
->
assertEquals
(
'id'
,
$decl
[
'map'
]);
}
public
function
testQueryParserSupportsMultipleAliasDeclarations
()
{
$entityManager
=
$this
->
_em
;
$query
=
$entityManager
->
createQuery
(
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.phonenumbers p'
);
$parserResult
=
$query
->
parse
();
$decl
=
$parserResult
->
getQueryComponent
(
'u'
);
$this
->
assertTrue
(
$decl
[
'metadata'
]
instanceof
\Doctrine\ORM\Mapping\ClassMetadata
);
$this
->
assertEquals
(
null
,
$decl
[
'relation'
]);
$this
->
assertEquals
(
null
,
$decl
[
'parent'
]);
$this
->
assertEquals
(
null
,
$decl
[
'scalar'
]);
$this
->
assertEquals
(
'id'
,
$decl
[
'map'
]);
$decl
=
$parserResult
->
getQueryComponent
(
'p'
);
$this
->
assertTrue
(
$decl
[
'metadata'
]
instanceof
\Doctrine\ORM\Mapping\ClassMetadata
);
$this
->
assertTrue
(
$decl
[
'relation'
]
instanceof
\Doctrine\ORM\Mapping\AssociationMapping
);
$this
->
assertEquals
(
'u'
,
$decl
[
'parent'
]);
$this
->
assertEquals
(
null
,
$decl
[
'scalar'
]);
$this
->
assertEquals
(
null
,
$decl
[
'map'
]);
}
public
function
testQueryParserSupportsMultipleAliasDeclarationsWithIndexBy
()
{
$entityManager
=
$this
->
_em
;
$query
=
$entityManager
->
createQuery
(
'SELECT u FROM Doctrine\Tests\Models\CMS\CmsUser u INDEX BY u.id LEFT JOIN u.articles a INNER JOIN u.phonenumbers pn INDEX BY pn.phonenumber'
);
$parserResult
=
$query
->
parse
();
$decl
=
$parserResult
->
getQueryComponent
(
'u'
);
$this
->
assertTrue
(
$decl
[
'metadata'
]
instanceof
\Doctrine\ORM\Mapping\ClassMetadata
);
$this
->
assertEquals
(
null
,
$decl
[
'relation'
]);
$this
->
assertEquals
(
null
,
$decl
[
'parent'
]);
$this
->
assertEquals
(
null
,
$decl
[
'scalar'
]);
$this
->
assertEquals
(
'id'
,
$decl
[
'map'
]);
$decl
=
$parserResult
->
getQueryComponent
(
'a'
);
$this
->
assertTrue
(
$decl
[
'metadata'
]
instanceof
\Doctrine\ORM\Mapping\ClassMetadata
);
$this
->
assertTrue
(
$decl
[
'relation'
]
instanceof
\Doctrine\ORM\Mapping\AssociationMapping
);
$this
->
assertEquals
(
'u'
,
$decl
[
'parent'
]);
$this
->
assertEquals
(
null
,
$decl
[
'scalar'
]);
$this
->
assertEquals
(
null
,
$decl
[
'map'
]);
$decl
=
$parserResult
->
getQueryComponent
(
'pn'
);
$this
->
assertTrue
(
$decl
[
'metadata'
]
instanceof
\Doctrine\ORM\Mapping\ClassMetadata
);
$this
->
assertTrue
(
$decl
[
'relation'
]
instanceof
\Doctrine\ORM\Mapping\AssociationMapping
);
$this
->
assertEquals
(
'u'
,
$decl
[
'parent'
]);
$this
->
assertEquals
(
null
,
$decl
[
'scalar'
]);
$this
->
assertEquals
(
'phonenumber'
,
$decl
[
'map'
]);
}
}
tests/Doctrine/Tests/TestInit.php
View file @
f2812766
...
...
@@ -6,7 +6,7 @@ namespace Doctrine\Tests;
require_once
'PHPUnit/Framework.php'
;
require_once
'PHPUnit/TextUI/TestRunner.php'
;
require_once
'
../lib/Doctrine/Common/ClassLoader.php'
;
require_once
__DIR__
.
'/../../
../lib/Doctrine/Common/ClassLoader.php'
;
$classLoader
=
new
\Doctrine\Common\ClassLoader
();
...
...
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