|
@@ -126,7 +126,24 @@ class Controller extends BaseController
|
126
|
126
|
*/
|
127
|
127
|
protected function getUserId()
|
128
|
128
|
{
|
129
|
|
- return $this->getUser()->getId();
|
|
129
|
+ /**
|
|
130
|
+ * Bug lors des tests: L'user n'est pas 'lié' a celui en base par doctrine.
|
|
131
|
+ * Docrine le voit si on faire une requete directe.
|
|
132
|
+ */
|
|
133
|
+ if ($this->container->getParameter('env') == 'test')
|
|
134
|
+ {
|
|
135
|
+ $user = $this->getDoctrine()->getRepository('MuzichCoreBundle:User')->findOneById(
|
|
136
|
+ $this->container->get('security.context')->getToken()->getUser()->getId(),
|
|
137
|
+ array()
|
|
138
|
+ )->getSingleResult();
|
|
139
|
+ return $user->getId();
|
|
140
|
+ }
|
|
141
|
+
|
|
142
|
+ if (($user = $this->getUser()) != 'anon.')
|
|
143
|
+ {
|
|
144
|
+ return $user->getId();
|
|
145
|
+ }
|
|
146
|
+ throw new \Exception('User not connected');
|
130
|
147
|
}
|
131
|
148
|
|
132
|
149
|
/**
|