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
7542482e
Commit
7542482e
authored
Dec 11, 2009
by
beberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] DDC-113 - Added test-case that shows it works.
parent
fade63a2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
2 deletions
+51
-2
LifecycleCallbackTest.php
...s/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php
+51
-2
No files found.
tests/Doctrine/Tests/ORM/Functional/LifecycleCallbackTest.php
View file @
7542482e
...
@@ -11,7 +11,8 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
...
@@ -11,7 +11,8 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
try
{
try
{
$this
->
_schemaTool
->
createSchema
(
array
(
$this
->
_schemaTool
->
createSchema
(
array
(
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity'
),
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\LifecycleCallbackTestEntity'
),
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser'
)
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\LifecycleCallbackTestUser'
),
$this
->
_em
->
getClassMetadata
(
'Doctrine\Tests\ORM\Functional\LifecycleCallbackCascader'
),
));
));
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
// Swallow all exceptions. We do not test the schema tool here.
// Swallow all exceptions. We do not test the schema tool here.
...
@@ -79,6 +80,25 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
...
@@ -79,6 +80,25 @@ class LifecycleCallbackTest extends \Doctrine\Tests\OrmFunctionalTestCase
$reference
->
getId
();
// trigger proxy load
$reference
->
getId
();
// trigger proxy load
$this
->
assertTrue
(
$reference
->
postLoadCallbackInvoked
);
$this
->
assertTrue
(
$reference
->
postLoadCallbackInvoked
);
}
}
/**
* @group DDC-113
*/
public
function
testCascadedEntitiesCallsPrePersist
()
{
$e1
=
new
LifecycleCallbackTestEntity
;
$e2
=
new
LifecycleCallbackTestEntity
;
$c
=
new
LifecycleCallbackCascader
();
$c
->
entities
[]
=
$e1
;
$c
->
entities
[]
=
$e2
;
$this
->
_em
->
persist
(
$c
);
$this
->
_em
->
flush
();
$this
->
assertTrue
(
$e1
->
prePersistCallbackInvoked
);
$this
->
assertTrue
(
$e2
->
prePersistCallbackInvoked
);
}
}
}
/** @Entity @HasLifecycleCallbacks */
/** @Entity @HasLifecycleCallbacks */
...
@@ -116,10 +136,16 @@ class LifecycleCallbackTestEntity
...
@@ -116,10 +136,16 @@ class LifecycleCallbackTestEntity
*/
*/
private
$id
;
private
$id
;
/**
/**
* @Column(type="string")
* @Column(type="string"
, nullable=true
)
*/
*/
public
$value
;
public
$value
;
/**
* @ManyToOne(targetEntity="LifecycleCallbackCascader")
* @JoinColumn(name="cascader_id", referencedColumnName="id")
*/
public
$cascader
;
public
function
getId
()
{
public
function
getId
()
{
return
$this
->
id
;
return
$this
->
id
;
}
}
...
@@ -143,4 +169,27 @@ class LifecycleCallbackTestEntity
...
@@ -143,4 +169,27 @@ class LifecycleCallbackTestEntity
public
function
doStuffOnPreUpdate
()
{
public
function
doStuffOnPreUpdate
()
{
$this
->
value
=
'changed from preUpdate callback!'
;
$this
->
value
=
'changed from preUpdate callback!'
;
}
}
}
/**
* @Entity
* @Table(name="lc_cb_test_cascade")
*/
class
LifecycleCallbackCascader
{
/**
* @Id @Column(type="integer")
* @GeneratedValue(strategy="AUTO")
*/
private
$id
;
/**
* @OneToMany(targetEntity="LifecycleCallbackTestEntity", mappedBy="product", cascade={"persist"})
*/
public
$entities
;
public
function
__construct
()
{
$this
->
entities
=
new
\Doctrine\Common\Collections\ArrayCollection
();
}
}
}
\ 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