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
ab1a8848
Commit
ab1a8848
authored
Jul 14, 2007
by
njero
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put the contents in the file
parent
0cd2bc70
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
133 additions
and
23 deletions
+133
-23
TicketNjeroTestCase.php
tests/TicketNjeroTestCase.php
+133
-23
No files found.
tests/TicketNjeroTestCase.php
View file @
ab1a8848
<?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_TicketNjero_TestCase
*
* @package Doctrine
* @author
Konsta Vesterinen <kvesteri@cc.hut.fi
>
* @author
Jeff Rafter <lists@jeffrafter.com
>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
class
CoverageCode
extends
Doctrine_Record
{
public
function
setTableDefinition
(){
$this
->
setTableName
(
'coverage_codes'
);
$this
->
hasColumn
(
'id'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'primary'
=>
true
,
'autoincrement'
=>
true
));
$this
->
hasColumn
(
'code'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'notblank'
=>
true
,));
$this
->
hasColumn
(
'description'
,
'string'
,
4000
,
array
(
'notnull'
=>
true
,
'notblank'
=>
true
,));
}
public
function
setUp
(){
$this
->
index
(
'code'
,
array
(
'fields'
=>
'code'
));
}
}
class
PolicyCode
extends
Doctrine_Record
{
public
function
setTableDefinition
(){
$this
->
setTableName
(
'policy_codes'
);
$this
->
hasColumn
(
'id'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'primary'
=>
true
,
'autoincrement'
=>
true
));
$this
->
hasColumn
(
'code'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'notblank'
=>
true
,));
$this
->
hasColumn
(
'description'
,
'string'
,
4000
,
array
(
'notnull'
=>
true
,
'notblank'
=>
true
,));
}
public
function
setUp
(){
$this
->
index
(
'code'
,
array
(
'fields'
=>
'code'
));
}
}
class
LiabilityCode
extends
Doctrine_Record
{
public
function
setTableDefinition
(){
$this
->
setTableName
(
'liability_codes'
);
$this
->
hasColumn
(
'id'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'primary'
=>
true
,
'autoincrement'
=>
true
));
$this
->
hasColumn
(
'code'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'notblank'
=>
true
,));
$this
->
hasColumn
(
'description'
,
'string'
,
4000
,
array
(
'notnull'
=>
true
,
'notblank'
=>
true
,));
}
public
function
setUp
(){
$this
->
index
(
'code'
,
array
(
'fields'
=>
'code'
));
}
}
class
Policy
extends
Doctrine_Record
{
public
function
setTableDefinition
(){
$this
->
setTableName
(
'policies'
);
$this
->
hasColumn
(
'id'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'primary'
=>
true
,
'autoincrement'
=>
true
));
$this
->
hasColumn
(
'rate_id'
,
'integer'
,
4
,
array
(
));
$this
->
hasColumn
(
'policy_number'
,
'integer'
,
4
,
array
(
'unique'
=>
true
,
));
}
public
function
setUp
(){
$this
->
hasOne
(
'Rate'
,
array
(
'local'
=>
'rate_id'
,
'foreign'
=>
'id'
));
}
}
class
Rate
extends
Doctrine_Record
{
public
function
setTableDefinition
(){
$this
->
setTableName
(
'rates'
);
$this
->
hasColumn
(
'id'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'primary'
=>
true
,
'autoincrement'
=>
true
));
$this
->
hasColumn
(
'policy_code'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'notblank'
=>
true
,));
$this
->
hasColumn
(
'coverage_code'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'notblank'
=>
true
,));
$this
->
hasColumn
(
'liability_code'
,
'integer'
,
4
,
array
(
'notnull'
=>
true
,
'notblank'
=>
true
,));
$this
->
hasColumn
(
'total_rate'
,
'float'
,
null
,
array
(
'notnull'
=>
true
,
'notblank'
=>
true
,));
}
public
function
setUp
(){
$this
->
index
(
'policy_code_idx'
,
array
(
'fields'
=>
'policy_code'
));
$this
->
index
(
'coverage_code_idx'
,
array
(
'fields'
=>
'coverage_code'
));
$this
->
index
(
'liability_code_idx'
,
array
(
'fields'
=>
'liability_code'
));
$this
->
hasOne
(
'PolicyCode'
,
array
(
'local'
=>
'policy_code'
,
'foreign'
=>
'code'
));
$this
->
hasOne
(
'CoverageCode'
,
array
(
'local'
=>
'coverage_code'
,
'foreign'
=>
'code'
));
$this
->
hasOne
(
'LiabilityCode'
,
array
(
'local'
=>
'liability_code'
,
'foreign'
=>
'code'
));
}
}
class
Doctrine_TicketNjero_TestCase
extends
Doctrine_UnitTestCase
{
}
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
$this
->
tables
[]
=
'CoverageCode'
;
$this
->
tables
[]
=
'PolicyCode'
;
$this
->
tables
[]
=
'LiabilityCode'
;
$this
->
tables
[]
=
'Policy'
;
$this
->
tables
[]
=
'Rate'
;
parent
::
prepareTables
();
}
public
function
testHasOneMultiLevelRelations
()
{
$policy_code
=
new
PolicyCode
();
$policy_code
->
code
=
1
;
$policy_code
->
description
=
"Special Policy"
;
$policy_code
->
save
();
$coverage_code
=
new
CoverageCode
();
$coverage_code
->
code
=
1
;
$coverage_code
->
description
=
"Full Coverage"
;
$coverage_code
->
save
();
$liability_code
=
new
LiabilityCode
();
$liability_code
->
code
=
1
;
$liability_code
->
description
=
"Limited Territory"
;
$liability_code
->
save
();
$rate
=
new
Rate
();
$rate
->
policy_code
=
1
;
$rate
->
coverage_code
=
1
;
$rate
->
liability_code
=
1
;
$rate
->
total_rate
=
123.45
;
$rate
->
save
();
$policy
=
new
Policy
();
$policy
->
rate_id
=
1
;
$policy
->
policy_number
=
"123456789"
;
$policy
->
save
();
$q
=
new
Doctrine_Query
();
$p
=
$q
->
from
(
"Policy p"
)
->
where
(
"p.id = 1"
)
->
execute
()
->
getFirst
();
$this
->
assertEqual
(
$p
->
rate_id
,
1
);
$this
->
assertEqual
(
$p
->
Rate
->
id
,
2
);
}
}
?>
...
...
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