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
14075fa7
Commit
14075fa7
authored
Nov 21, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some tests for new attributes
parent
5f1a4074
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
151 additions
and
26 deletions
+151
-26
ConfigurableTestCase.php
tests/ConfigurableTestCase.php
+151
-26
No files found.
tests/ConfigurableTestCase.php
View file @
14075fa7
<?php
require_once
(
"UnitTestCase.php"
);
class
Doctrine_ConfigurableTestCase
extends
Doctrine_UnitTestCase
{
class
Doctrine_Configurable
_
TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareTables
()
{
}
public
function
prepareData
()
{
}
public
function
testGetIndexNameFormatAttribute
()
{
// default index name format is %_idx
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_IDXNAME_FORMAT
),
'%_idx'
);
}
public
function
testGetSequenceNameFormatAttribute
()
{
// default sequence name format is %_seq
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_SEQNAME_FORMAT
),
'%_seq'
);
}
public
function
testSetIndexNameFormatAttribute
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_IDXNAME_FORMAT
,
'%_index'
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_IDXNAME_FORMAT
),
'%_index'
);
}
public
function
testSetSequenceNameFormatAttribute
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_SEQNAME_FORMAT
,
'%_sequence'
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_SEQNAME_FORMAT
),
'%_sequence'
);
}
public
function
testExceptionIsThrownWhenSettingIndexNameFormatAttributeAtTableLevel
()
{
try
{
$this
->
connection
->
getTable
(
'Entity'
)
->
setAttribute
(
Doctrine
::
ATTR_IDXNAME_FORMAT
,
'%_idx'
);
$this
->
fail
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testExceptionIsThrownWhenSettingSequenceNameFormatAttributeAtTableLevel
()
{
try
{
$this
->
connection
->
getTable
(
'Entity'
)
->
setAttribute
(
Doctrine
::
ATTR_SEQNAME_FORMAT
,
'%_seq'
);
$this
->
fail
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSettingFieldCaseIsSuccesfulWithZero
()
{
try
{
$this
->
connection
->
setAttribute
(
Doctrine
::
ATTR_FIELD_CASE
,
0
);
$this
->
pass
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
fail
();
}
}
public
function
testSettingFieldCaseIsSuccesfulWithCaseConstants
()
{
try
{
$this
->
connection
->
setAttribute
(
Doctrine
::
ATTR_FIELD_CASE
,
CASE_LOWER
);
$this
->
pass
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
fail
();
}
}
public
function
testSettingFieldCaseIsSuccesfulWithCaseConstants2
()
{
try
{
$this
->
connection
->
setAttribute
(
Doctrine
::
ATTR_FIELD_CASE
,
CASE_UPPER
);
$this
->
pass
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
fail
();
}
}
public
function
testExceptionIsThrownWhenSettingFieldCaseToNotZeroOneOrTwo
()
{
try
{
$this
->
connection
->
setAttribute
(
Doctrine
::
ATTR_FIELD_CASE
,
-
1
);
$this
->
fail
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testExceptionIsThrownWhenSettingFieldCaseToNotZeroOneOrTwo2
()
{
try
{
$this
->
connection
->
setAttribute
(
Doctrine
::
ATTR_FIELD_CASE
,
5
);
$this
->
fail
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testDefaultQuoteIdentifierAttributeValueIsFalse
()
{
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_QUOTE_IDENTIFIER
),
false
);
}
public
function
testQuoteIdentifierAttributeAcceptsBooleans
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_QUOTE_IDENTIFIER
,
true
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_QUOTE_IDENTIFIER
),
true
);
}
public
function
testDefaultSequenceColumnNameAttributeValueIsId
()
{
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_SEQCOL_NAME
),
'id'
);
}
public
function
testSequenceColumnNameAttributeAcceptsStrings
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_SEQCOL_NAME
,
'sequence'
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_SEQCOL_NAME
),
'sequence'
);
}
public
function
testValidatorAttributeAcceptsBooleans
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
true
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_VLD
),
true
);
}
public
function
testAutoLengthValidationAttributeAcceptsBooleans
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_AUTO_LENGTH_VLD
,
true
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_AUTO_LENGTH_VLD
),
true
);
}
public
function
testAutoTypeValidationAttributeAcceptsBooleans
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_AUTO_TYPE_VLD
,
true
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_AUTO_TYPE_VLD
),
true
);
}
public
function
testDefaultPortabilityAttributeValueIsAll
()
{
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
),
Doctrine
::
PORTABILITY_ALL
);
}
public
function
testPortabilityAttributeAcceptsPortabilityConstants
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_PORTABILITY
,
Doctrine
::
PORTABILITY_RTRIM
|
Doctrine
::
PORTABILITY_FIX_CASE
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_PORTABILITY
),
Doctrine
::
PORTABILITY_RTRIM
|
Doctrine
::
PORTABILITY_FIX_CASE
);
}
public
function
testDefaultListenerIsDoctrineEventListener
()
{
$this
->
assertTrue
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
instanceof
Doctrine_EventListener
);
}
public
function
testListenerAttributeAcceptsEventListenerObjects
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_LISTENER
,
new
Doctrine_EventListener_Debugger
());
$this
->
assertTrue
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
instanceof
Doctrine_EventListener_Debugger
);
}
public
function
testCollectionKeyAttributeAcceptsValidColumnName
()
{
try
{
$this
->
connection
->
getTable
(
'User'
)
->
setAttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'name'
);
$this
->
pass
();
}
catch
(
Exception
$e
)
{
$this
->
fail
();
}
}
public
function
testSettingInvalidColumnNameToCollectionKeyAttributeThrowsException
()
{
try
{
$this
->
connection
->
getTable
(
'User'
)
->
setAttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'unknown'
);
$this
->
fail
();
}
catch
(
Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSettingCollectionKeyAttributeOnOtherThanTableLevelThrowsException
()
{
try
{
$this
->
connection
->
setAttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'name'
);
$this
->
fail
();
}
catch
(
Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testSetAttribute
()
{
$table
=
$this
->
connection
->
getTable
(
"User"
);
/**
...
...
@@ -22,9 +172,6 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_BATCH_SIZE
,
5
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_BATCH_SIZE
),
5
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_LISTENER
,
new
Doctrine_EventListener_Debugger
());
$this
->
assertTrue
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
instanceof
Doctrine_EventListener_Debugger
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_LOCKMODE
,
Doctrine
::
LOCK_PESSIMISTIC
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_LOCKMODE
),
Doctrine
::
LOCK_PESSIMISTIC
);
...
...
@@ -54,28 +201,6 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
$this
->
connection
->
commit
();
}
$e
=
false
;
try
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_COLL_KEY
,
"name"
);
}
catch
(
Exception
$e
)
{
}
$this
->
assertTrue
(
$e
instanceof
Exception
);
$e
=
false
;
try
{
$table
->
setAttribute
(
Doctrine
::
ATTR_COLL_KEY
,
"unknown"
);
}
catch
(
Exception
$e
)
{
}
$this
->
assertTrue
(
$e
instanceof
Exception
);
$e
=
true
;
try
{
$table
->
setAttribute
(
Doctrine
::
ATTR_COLL_KEY
,
"name"
);
}
catch
(
Exception
$e
)
{
}
$this
->
assertTrue
(
$e
);
$e
=
false
;
try
{
$this
->
connection
->
beginTransaction
();
$this
->
connection
->
setAttribute
(
Doctrine
::
ATTR_LOCKMODE
,
Doctrine
::
LOCK_PESSIMISTIC
);
...
...
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