Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Memorekall Member New
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rekall
Memorekall Member New
Commits
06d698c4
Commit
06d698c4
authored
3 years ago
by
Camille Simiand
Committed by
Sebastien
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Rebase and fix errors
parent
0a4410b1
No related branches found
No related tags found
3 merge requests
!43
tuleap-83-access-my-capsules
,
!42
Draft: access-my-capsules-conflicts-fixed
,
!40
Draft: Tuleap 83 access my capsules
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Entity/User.php
+1
-42
1 addition, 42 deletions
src/Entity/User.php
tests/functional/ProjectControllerTest.php
+8
-10
8 additions, 10 deletions
tests/functional/ProjectControllerTest.php
with
9 additions
and
52 deletions
src/Entity/User.php
+
1
−
42
View file @
06d698c4
...
...
@@ -3,8 +3,6 @@
namespace
App\Entity
;
use
App\Repository\UserRepository
;
use
Doctrine\Common\Collections\ArrayCollection
;
use
Doctrine\Common\Collections\Collection
;
use
Doctrine\ORM\Mapping
as
ORM
;
use
Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity
;
use
Symfony\Component\Security\Core\User\LegacyPasswordAuthenticatedUserInterface
;
...
...
@@ -84,17 +82,8 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
*/
private
string
$salt
;
/**
* @ORM\OneToMany(targetEntity=Capsule::class, mappedBy="aut_crea")
*/
private
$capsules
;
public
function
__construct
()
{
$this
->
capsules
=
new
ArrayCollection
();
}
public
function
getId
():
?
int
public
function
getId
():
int
{
return
$this
->
id
;
}
...
...
@@ -224,34 +213,4 @@ class User implements UserInterface, LegacyPasswordAuthenticatedUserInterface
{
$this
->
salt
=
$salt
;
}
/**
* @return Collection|Capsule[]
*/
public
function
getCapsules
():
Collection
{
return
$this
->
capsules
;
}
public
function
addCapsule
(
Capsule
$capsule
):
self
{
if
(
!
$this
->
capsules
->
contains
(
$capsule
))
{
$this
->
capsules
[]
=
$capsule
;
$capsule
->
setCreationauthor
(
$this
);
}
return
$this
;
}
public
function
removeCapsule
(
Capsule
$capsule
):
self
{
if
(
$this
->
capsules
->
removeElement
(
$capsule
))
{
// set the owning side to null (unless already changed)
if
(
$capsule
->
getCreationauthor
()
===
$this
)
{
$capsule
->
setCreationauthor
(
null
);
}
}
return
$this
;
}
}
This diff is collapsed.
Click to expand it.
tests/functional/ProjectControllerTest.php
+
8
−
10
View file @
06d698c4
...
...
@@ -9,7 +9,6 @@ use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use
Symfony\Bundle\FrameworkBundle\Test\WebTestCase
;
use
Symfony\Component\DomCrawler\Form
;
use
Symfony\Component\Filesystem\Filesystem
;
use
Symfony\Config\TwigExtra\StringConfig
;
class
ProjectControllerTest
extends
WebTestCase
{
...
...
@@ -18,8 +17,6 @@ class ProjectControllerTest extends WebTestCase
private
Form
$form
;
private
const
TEST_DIR_PATH
=
__DIR__
.
'/../../legacy/'
;
private
const
CAPSULE_NAME
=
'TestCapsuleName'
;
private
const
CAPSULE_DIR_PATH
=
self
::
TEST_DIR_PATH
.
self
::
CAPSULE_NAME
;
private
const
XML_FILE_PATH
=
self
::
CAPSULE_DIR_PATH
.
'/file/project.xml'
;
protected
function
setUp
():
void
{
...
...
@@ -59,12 +56,13 @@ class ProjectControllerTest extends WebTestCase
$file_system
->
remove
(
self
::
TEST_DIR_PATH
.
self
::
CAPSULE_NAME
);
$capsule_repository
=
$this
->
object_manager
->
getRepository
(
Capsule
::
class
);
$last_capsule
=
$capsule_repository
->
findOneBy
([
'name'
=>
self
::
CAPSULE_NAME
]);
$
detached_
last_capsule
=
$capsule_repository
->
findOneBy
([
'name'
=>
self
::
CAPSULE_NAME
]);
if
(
!
$last_capsule
instanceof
Capsule
)
{
if
(
!
$
detached_
last_capsule
instanceof
Capsule
)
{
throw
new
\Exception
(
"Capsule does not exist."
);
}
$last_capsule
=
$this
->
object_manager
->
merge
(
$detached_last_capsule
);
$this
->
object_manager
->
remove
(
$last_capsule
);
$this
->
object_manager
->
flush
();
}
...
...
@@ -74,19 +72,19 @@ class ProjectControllerTest extends WebTestCase
{
$dom_xml
=
new
\DOMDocument
();
$dom_xml
->
preserveWhiteSpace
=
false
;
$dom_xml
->
load
(
$this
->
create
XmlFilePath
(
$capsule_directory
));
$dom_xml
->
load
(
$this
->
get
XmlFilePath
(
$capsule_directory
));
return
$dom_xml
;
}
private
function
create
CapsuleDirPath
(
string
$capsule_directory
):
string
private
function
get
CapsuleDirPath
(
string
$capsule_directory
):
string
{
return
self
::
TEST_DIR_PATH
.
$capsule_directory
;
}
private
function
create
XmlFilePath
(
string
$capsule_directory
):
string
private
function
get
XmlFilePath
(
string
$capsule_directory
):
string
{
return
$this
->
create
CapsuleDirPath
(
$capsule_directory
)
.
'/file/project.xml'
;
return
$this
->
get
CapsuleDirPath
(
$capsule_directory
)
.
'/file/project.xml'
;
}
public
function
testProjectDirectoryWithCorrespondingXMLFileIsCreatedWhenCapsuleCreationIsSuccessful
():
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment