Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LQDN Adminsys
don
Commits
84a9edea
Commit
84a9edea
authored
Nov 29, 2018
by
Okhin
Browse files
Getting the user test to work, by retrieving the lastInsertId and not assuming it's 3
parent
2559bc0a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/LQDN/Command/UserCreateCommand.php
View file @
84a9edea
...
...
@@ -7,6 +7,8 @@ class UserCreateCommand
private
$email
;
private
$hash
;
private
$pseudo
;
private
$cumul
;
private
$total
;
public
function
__construct
(
$email
,
$hash
,
$pseudo
,
$cumul
,
$total
)
{
...
...
src/LQDN/Handler/UserHandler.php
View file @
84a9edea
...
...
@@ -39,13 +39,13 @@ class UserHandler
*/
public
function
handleUserCreateCommand
(
UserCreateCommand
$command
)
{
$stmt
=
$this
->
connection
->
prepar
e
(
'INSERT INTO users(email, hash, pseudo, total, cumul) VALUES (:email, :hash, :pseudo, :total, :cumul)'
);
$stmt
->
bindValue
(
'email'
,
$command
->
getEmail
()
);
$stmt
->
bindValue
(
'hash'
,
$command
->
getHash
()
);
$stmt
->
bindValue
(
'pseudo'
,
$command
->
getPseudo
()
);
$stmt
->
bindValue
(
'total'
,
$command
->
getTotal
()
);
$stmt
->
bindValue
(
'cumul'
,
$command
->
getCumul
()
);
$stmt
->
execute
(
);
$this
->
connection
->
executeUpdat
e
(
'INSERT INTO users(email, hash, pseudo, total, cumul) VALUES (:email, :hash, :pseudo, :total, :cumul)'
,
[
'email'
=>
$command
->
getEmail
()
,
'hash'
=>
$command
->
getHash
()
,
'pseudo'
=>
$command
->
getPseudo
()
,
'total'
=>
$command
->
getTotal
()
,
'cumul'
=>
$command
->
getCumul
()
,
]
);
}
/**
...
...
tests/functional/Handler/UserHandlerTest.php
View file @
84a9edea
...
...
@@ -28,6 +28,10 @@ class UserHandlerTest extends FunctionalTest
public
function
testUserCreateCommand
()
{
$this
->
container
[
'command_handler'
]
->
handle
(
new
UserCreateCommand
(
'eve@example.org'
,
'not a hash'
,
'Eve'
,
0
,
0
));
$last_id
=
$this
->
container
[
'db'
]
->
lastInsertId
();
$user
=
$this
->
getUser
(
$last_id
);
$this
->
assertSame
(
'eve@example.org'
,
$user
[
'email'
]);
}
public
function
testUserUpdateTotal
()
...
...
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