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
37176110
Commit
37176110
authored
Dec 15, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0][DDC-211] Fixed wrong number in test case.
parent
cced2bd6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
116 additions
and
0 deletions
+116
-0
DDC211Test.php
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php
+116
-0
No files found.
tests/Doctrine/Tests/ORM/Functional/Ticket/DDC211Test.php
0 → 100644
View file @
37176110
<?php
namespace
Doctrine\Tests\ORM\Functional\Ticket
;
require_once
__DIR__
.
'/../../../TestInit.php'
;
class
DDC211Test
extends
\Doctrine\Tests\OrmFunctionalTestCase
{
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
_schemaTool
->
createSchema
(
array
(
$this
->
_em
->
getClassMetadata
(
__NAMESPACE__
.
'\DDC211User'
),
$this
->
_em
->
getClassMetadata
(
__NAMESPACE__
.
'\DDC211Group'
)
));
}
public
function
testIssue
()
{
//$this->_em->getConnection()->getConfiguration()->setSqlLogger(new \Doctrine\DBAL\Logging\EchoSqlLogger);
$user
=
new
DDC211User
;
$user
->
setName
(
'John Doe'
);
$this
->
_em
->
persist
(
$user
);
$this
->
_em
->
flush
();
$groupNames
=
array
(
'group 1'
,
'group 2'
,
'group 3'
,
'group 4'
);
foreach
(
$groupNames
as
$name
)
{
$group
=
new
DDC211Group
;
$group
->
setName
(
$name
);
$this
->
_em
->
persist
(
$group
);
$this
->
_em
->
flush
();
if
(
!
$user
->
getGroups
()
->
contains
(
$group
))
{
$user
->
getGroups
()
->
add
(
$group
);
$group
->
getUsers
()
->
add
(
$user
);
$this
->
_em
->
flush
();
}
}
$this
->
assertEquals
(
4
,
$user
->
getGroups
()
->
count
());
}
}
/**
* @Entity
* @Table(name="ddc211_users")
*/
class
DDC211User
{
/**
* @Id
* @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO")
*/
protected
$id
;
/**
* @Column(name="name", type="string")
*/
protected
$name
;
/**
* @ManyToMany(targetEntity="DDC211Group")
* @JoinTable(name="user_groups",
* joinColumns={@JoinColumn(name="user_id", referencedColumnName="id")},
* inverseJoinColumns={@JoinColumn(name="group_id", referencedColumnName="id")}
* )
*/
protected
$groups
;
public
function
__construct
()
{
$this
->
groups
=
new
\Doctrine\Common\Collections\ArrayCollection
();
}
public
function
setName
(
$name
)
{
$this
->
name
=
$name
;
}
public
function
getGroups
()
{
return
$this
->
groups
;
}
}
/**
* @Entity
* @Table(name="ddc211_groups")
*/
class
DDC211Group
{
/**
* @Id
* @Column(name="id", type="integer")
* @GeneratedValue(strategy="AUTO")
*/
protected
$id
;
/**
* @Column(name="name", type="string")
*/
protected
$name
;
/**
* @ManyToMany(targetEntity="DDC211User", mappedBy="groups")
*/
protected
$users
;
public
function
__construct
()
{
$this
->
users
=
new
\Doctrine\Common\Collections\ArrayCollection
();
}
public
function
setName
(
$name
)
{
$this
->
name
=
$name
;
}
public
function
getUsers
()
{
return
$this
->
users
;
}
}
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