ElementControllerTest.php 40KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197
  1. <?php
  2. namespace Muzich\CoreBundle\Tests\Controller;
  3. use Muzich\CoreBundle\lib\FunctionalTest;
  4. class ElementControllerTest extends FunctionalTest
  5. {
  6. public function testAddElementAjax()
  7. {
  8. $this->client = self::createClient();
  9. $this->connectUser('joelle', 'toor');
  10. $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
  11. $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
  12. // L'élément n'existe pas encore
  13. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  14. ->findOneByName('Musique qui dechire')
  15. ;
  16. $this->assertTrue(is_null($element));
  17. // On commence par ajouter un tag
  18. $url = $this->generateUrl('element_add');
  19. $extract = $this->crawler->filter('input[name="element_add[_token]"]')
  20. ->extract(array('value'));
  21. $csrf = $extract[0];
  22. $crawler = $this->client->request(
  23. 'POST',
  24. $url,
  25. array(
  26. 'element_add' => array(
  27. '_token' => $csrf,
  28. 'name' => 'Musique qui dechire',
  29. 'url' => 'http://www.youtube.com/watch?v=WC8qb_of04E',
  30. 'tags' => json_encode(array($hardtek->getId(), $tribe->getId()))
  31. )
  32. ),
  33. array(),
  34. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  35. );
  36. $this->isResponseSuccess();
  37. $response = json_decode($this->client->getResponse()->getContent(), true);
  38. $this->assertEquals($response['status'], 'success');
  39. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  40. ->findOneByName('Musique qui dechire')
  41. ;
  42. $this->assertTrue(!is_null($element));
  43. }
  44. public function testAddElementInGroupAjax()
  45. {
  46. $this->client = self::createClient();
  47. $this->connectUser('joelle', 'toor');
  48. $Fans_de_psytrance = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
  49. $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
  50. $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
  51. // L'élément n'existe pas encore
  52. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  53. ->findOneByName('Musique qui dechire dans psytrance')
  54. ;
  55. $this->assertTrue(is_null($element));
  56. // On commence par ajouter un tag
  57. $url = $this->generateUrl('element_add', array('group_slug' => $Fans_de_psytrance->getSlug()));
  58. $extract = $this->crawler->filter('input[name="element_add[_token]"]')
  59. ->extract(array('value'));
  60. $csrf = $extract[0];
  61. $crawler = $this->client->request(
  62. 'POST',
  63. $url,
  64. array(
  65. 'element_add' => array(
  66. '_token' => $csrf,
  67. 'name' => 'Musique qui dechire dans psytrance',
  68. 'url' => 'http://www.youtube.com/watch?v=WC8qb_of04E',
  69. 'tags' => json_encode(array($hardtek->getId(), $tribe->getId()))
  70. )
  71. ),
  72. array(),
  73. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  74. );
  75. $this->isResponseSuccess();
  76. $response = json_decode($this->client->getResponse()->getContent(), true);
  77. $this->assertEquals($response['status'], 'success');
  78. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  79. ->findOneBy(array(
  80. 'name' => 'Musique qui dechire dans psytrance',
  81. 'group' => $Fans_de_psytrance->getId()
  82. ))
  83. ;
  84. $this->assertTrue(!is_null($element));
  85. }
  86. public function testAddElementAjaxFail()
  87. {
  88. $this->client = self::createClient();
  89. $this->connectUser('joelle', 'toor');
  90. $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
  91. $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
  92. // L'élément n'existe pas encore
  93. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  94. ->findOneByName('Musique qui dechire')
  95. ;
  96. $this->assertTrue(is_null($element));
  97. // On commence par ajouter un tag
  98. $url = $this->generateUrl('element_add');
  99. $extract = $this->crawler->filter('input[name="element_add[_token]"]')
  100. ->extract(array('value'));
  101. $csrf = $extract[0];
  102. $crawler = $this->client->request(
  103. 'POST',
  104. $url,
  105. array(
  106. 'element_add' => array(
  107. '_token' => $csrf,
  108. 'name' => 'Musique qui dechire',
  109. 'url' => 'http://www',
  110. 'tags' => json_encode(array($hardtek->getId(), $tribe->getId()))
  111. )
  112. ),
  113. array(),
  114. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  115. );
  116. $this->isResponseSuccess();
  117. $response = json_decode($this->client->getResponse()->getContent(), true);
  118. $this->assertEquals($response['status'], 'error');
  119. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  120. ->findOneByName('Musique qui dechire')
  121. ;
  122. $this->assertTrue(is_null($element));
  123. }
  124. public function testAddElementInGroupAjaxFail()
  125. {
  126. $this->client = self::createClient();
  127. $this->connectUser('joelle', 'toor');
  128. $Fans_de_psytrance = $this->getDoctrine()->getRepository('MuzichCoreBundle:Group')->findOneByName('Fans de psytrance');
  129. $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
  130. $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
  131. // L'élément n'existe pas encore
  132. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  133. ->findOneByName('zo')
  134. ;
  135. $this->assertTrue(is_null($element));
  136. // On commence par ajouter un tag
  137. $url = $this->generateUrl('element_add', array('group_slug' => $Fans_de_psytrance->getSlug()));
  138. $extract = $this->crawler->filter('input[name="element_add[_token]"]')
  139. ->extract(array('value'));
  140. $csrf = $extract[0];
  141. $crawler = $this->client->request(
  142. 'POST',
  143. $url,
  144. array(
  145. 'element_add' => array(
  146. '_token' => $csrf,
  147. 'name' => 'zo',
  148. 'url' => 'http://www.youtube.com/watch?v=WC8qb_of04E',
  149. 'tags' => json_encode(array($hardtek->getId(), $tribe->getId()))
  150. )
  151. ),
  152. array(),
  153. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  154. );
  155. $this->isResponseSuccess();
  156. $response = json_decode($this->client->getResponse()->getContent(), true);
  157. $this->assertEquals($response['status'], 'error');
  158. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  159. ->findOneBy(array(
  160. 'name' => 'zo',
  161. 'group' => $Fans_de_psytrance->getId()
  162. ))
  163. ;
  164. $this->assertTrue(is_null($element));
  165. }
  166. public function testUpdateElement()
  167. {
  168. $this->client = self::createClient();
  169. $this->connectUser('bux', 'toor');
  170. $bux = $this->getUser();
  171. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  172. ->findOneByName('Ed Cox - La fanfare des teuffeurs (Hardcordian)')
  173. ;
  174. // On est sur la page home, on peut voir le lien de modification de l'élément
  175. $this->exist('a[href="'.($url = $this->generateUrl('element_edit', array('element_id' => $element->getId()))).'"]');
  176. // On effectue la demande ajax d'edition
  177. $crawler = $this->client->request(
  178. 'GET',
  179. $url,
  180. array(),
  181. array(),
  182. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  183. );
  184. $this->isResponseSuccess();
  185. $response = json_decode($this->client->getResponse()->getContent(), true);
  186. $this->assertEquals($response['status'], 'success');
  187. $this->assertEquals($response['form_name'], 'element_'.$element->getId());
  188. $this->assertTrue(strpos($response['html'], 'class="edit_element"') !== false);
  189. // Il faut que l'on récupère le token
  190. preg_match("#name=\"element_add\[_token\]\" value=\"([a-zA-Z0-9]+)\" />#", $response['html'], $chaines);
  191. $csrf = $chaines[1];
  192. // On effectue la modification en ajax
  193. $url = $this->generateUrl('element_update', array(
  194. 'element_id' => $element->getId(),
  195. 'dom_id' => 'element_'.$element->getId()
  196. ));
  197. $crawler = $this->client->request(
  198. 'POST',
  199. $url,
  200. array(
  201. 'element_add' => array(
  202. '_token' => $csrf,
  203. 'name' => $element->getName().'555',
  204. 'url' => $element->getUrl(),
  205. 'tags' => $element->getTagsIdsJson()
  206. )
  207. ),
  208. array(),
  209. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  210. );
  211. $this->isResponseSuccess();
  212. $response = json_decode($this->client->getResponse()->getContent(), true);
  213. $this->assertEquals($response['status'], 'success');
  214. $this->assertTrue(strpos($response['html'], $element->getName().'555') !== false);
  215. $this->crawler = $this->client->request('GET', $this->generateUrl('home'));
  216. $this->exist('span.element_name:contains("'.$element->getName().'555'.'")');
  217. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  218. ->findOneByName($element->getName().'555')
  219. ;
  220. $this->assertTrue(!is_null($element));
  221. }
  222. public function testDeleteElement()
  223. {
  224. $this->client = self::createClient();
  225. $this->connectUser('bux', 'toor');
  226. $bux = $this->getUser();
  227. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  228. ->findOneByName('Ed Cox - La fanfare des teuffeurs (Hardcordian)')
  229. ;
  230. // On est sur la page home, on peut voir le lien de suppression l'élément
  231. $this->exist('a[href="'.($url = $this->generateUrl('element_remove', array(
  232. 'element_id' => $element->getId()
  233. ))).'"]');
  234. // Suppression de l'élément
  235. // On effectue la demande ajax d'edition
  236. $crawler = $this->client->request(
  237. 'GET',
  238. $url,
  239. array(),
  240. array(),
  241. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  242. );
  243. $this->isResponseSuccess();
  244. $response = json_decode($this->client->getResponse()->getContent(), true);
  245. $this->assertEquals($response['status'], 'success');
  246. $this->crawler = $this->client->request('GET', $this->generateUrl('home'));
  247. $this->notExist('span.element_name:contains("'.$element->getName().'")');
  248. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  249. ->findOneByName('Ed Cox - La fanfare des teuffeurs (Hardcordian)')
  250. ;
  251. $this->assertTrue(is_null($element));
  252. }
  253. /**
  254. * Procédure de vote
  255. */
  256. public function testVote()
  257. {
  258. $this->client = self::createClient();
  259. $this->connectUser('paul', 'toor');
  260. $paul = $this->getUser();
  261. $joelle = $this->getUser('joelle');
  262. $jean = $this->getUser('jean');
  263. // D'après les fixtures, un des élément porte le vote de paul
  264. $element_soul = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  265. ->findOneByName('SOULFLY - Prophecy')
  266. ;
  267. // On peut donc voir le lien pour "dé-voter"
  268. $url_unvote_soul = $this->generateUrl('ajax_element_remove_vote_good', array(
  269. 'element_id' => $element_soul->getId(),
  270. 'token' => $paul->getPersonalHash()
  271. ));
  272. $this->exist('a.vote[href="'.$url_unvote_soul.'"]');
  273. // On contrôle le contenu pour cet element
  274. $this->assertEquals($element_soul->getPoints(), 1);
  275. // Et son id est la
  276. $this->assertEquals($element_soul->getVoteGoodIds(), array(
  277. (string)$paul->getId()
  278. ));
  279. // On va voter pour un element a bux
  280. $element_ed = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  281. ->findOneByName('Ed Cox - La fanfare des teuffeurs (Hardcordian)')
  282. ;
  283. // Actuellement (fixtures) son score est de 2
  284. $this->assertEquals($element_ed->getPoints(), 2);
  285. // Et ce sont (fixtures) ces deux user qui ont voté
  286. $this->assertEquals($element_ed->getVoteGoodIds(), array((string)$joelle->getId(), (string)$jean->getId()));
  287. // On peut d'ailleur constater que la reputation de bux est de 7 (fixtures)
  288. $bux = $this->getUser('bux');
  289. $this->assertEquals($bux->getReputation(), 22);
  290. // paul va voter
  291. $crawler = $this->client->request(
  292. 'GET',
  293. $this->generateUrl('ajax_element_add_vote_good', array(
  294. 'element_id' => $element_ed->getId(),
  295. 'token' => $paul->getPersonalHash()
  296. )),
  297. array(),
  298. array(),
  299. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  300. );
  301. $this->isResponseSuccess();
  302. $response = json_decode($this->client->getResponse()->getContent(), true);
  303. $this->assertEquals($response['status'], 'success');
  304. // On recontrôle l'élément voir si tout a été enregistré
  305. $element_ed = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  306. ->findOneByName('Ed Cox - La fanfare des teuffeurs (Hardcordian)')
  307. ;
  308. // Son score est mainteannt de 3
  309. $this->assertEquals($element_ed->getPoints(), 3);
  310. // Et son id est la
  311. $this->assertEquals($element_ed->getVoteGoodIds(), array(
  312. (string)$joelle->getId(),
  313. (string)$jean->getId(),
  314. (string)$paul->getId()
  315. ));
  316. // On peut d'ailleur constater que la reputation de bux est maintenant de 8
  317. $bux = $this->getUser('bux');
  318. $this->assertEquals($bux->getReputation(), 23);
  319. // Pau retire son vote de soulfy
  320. $crawler = $this->client->request(
  321. 'GET',
  322. $url_unvote_soul,
  323. array(),
  324. array(),
  325. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  326. );
  327. $element_soul = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  328. ->findOneByName('SOULFLY - Prophecy')
  329. ;
  330. // On contrôle le contenu pour cet element
  331. $this->assertEquals($element_soul->getPoints(), 0);
  332. // Et son id est la
  333. $this->assertEquals($element_soul->getVoteGoodIds(), array());
  334. // On peut d'ailleur constater que la reputation de bux est maintenant de 7
  335. $bux = $this->getUser('bux');
  336. $this->assertEquals($bux->getReputation(), 22);
  337. // On déconnecte paul, pour faire voter bob sur le partage ed cox
  338. $this->disconnectUser();
  339. $this->connectUser('bob', 'toor');
  340. $bob = $this->getUser();
  341. // bob va donc votre pour le partage d'ed cox
  342. $crawler = $this->client->request(
  343. 'GET',
  344. $this->generateUrl('ajax_element_add_vote_good', array(
  345. 'element_id' => $element_ed->getId(),
  346. 'token' => $bob->getPersonalHash()
  347. )),
  348. array(),
  349. array(),
  350. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  351. );
  352. $this->isResponseSuccess();
  353. $response = json_decode($this->client->getResponse()->getContent(), true);
  354. $this->assertEquals($response['status'], 'success');
  355. // On recontrôle l'élément voir si tout a été enregistré
  356. $element_ed = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  357. ->findOneByName('Ed Cox - La fanfare des teuffeurs (Hardcordian)')
  358. ;
  359. // Son score est mainteannt de 3
  360. $this->assertEquals($element_ed->getPoints(), 4);
  361. // Et son id est la
  362. $this->assertEquals($element_ed->getVoteGoodIds(), array(
  363. (string)$joelle->getId(),
  364. (string)$jean->getId(),
  365. (string)$paul->getId(),
  366. (string)$bob->getId()
  367. ));
  368. // On peut d'ailleur constater que la reputation de bux est maintenant de 8
  369. $bux = $this->getUser('bux');
  370. $this->assertEquals($bux->getReputation(), 23);
  371. }
  372. /**
  373. * Test des procédure concernants al proposition de tags sur un élément
  374. *
  375. * On test ici:
  376. * * Proposition de tags
  377. * * La consultation de ces propositions
  378. * * L'acceptation
  379. */
  380. public function testTagsPropositionAccept()
  381. {
  382. $this->client = self::createClient();
  383. $this->connectUser('paul', 'toor');
  384. $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
  385. $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
  386. $tsouzoumi = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tsouzoumi');
  387. $soug = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Soug');
  388. $metal = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Metal');
  389. $paul = $this->getUser();
  390. $bux = $this->getUser('bux');
  391. $joelle = $this->getUser('joelle');
  392. $points_pour_tags_add = $this->getContainer()->getParameter('reputation_element_tags_element_prop_value');
  393. $points_joelle = $joelle->getReputation();
  394. $points_bux = $bux->getReputation();
  395. $points_paul = $paul->getReputation();
  396. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  397. ->findOneByName('AZYD AZYLUM Live au Café Provisoire')
  398. ;
  399. // Pas de proposition en base pur cet élément
  400. $propositions = $this->getDoctrine()->getEntityManager()->getRepository('MuzichCoreBundle:ElementTagsProposition')
  401. ->findOneByElement($element->getId())
  402. ;
  403. $this->assertEquals(0, count($propositions));
  404. // Pas d'événement pour bux
  405. $events = $this->getDoctrine()->getEntityManager()
  406. ->createQuery('SELECT e FROM MuzichCoreBundle:Event e
  407. WHERE e.user = :uid AND e.type = :type'
  408. )
  409. ->setParameters(array(
  410. 'uid' => $bux->getId(),
  411. 'type' => \Muzich\CoreBundle\Entity\Event::TYPE_TAGS_PROPOSED
  412. ))
  413. ->getArrayResult()
  414. ;
  415. $this->assertEquals(count($events), 0);
  416. // On teste la récupération du formulaire au moin une fois
  417. $crawler = $this->client->request(
  418. 'GET',
  419. $this->generateUrl('ajax_element_propose_tags_open',
  420. array('element_id' => $element->getId())
  421. ),
  422. array(),
  423. array(),
  424. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  425. );
  426. $this->isResponseSuccess();
  427. $response = json_decode($this->client->getResponse()->getContent(), true);
  428. $this->assertEquals($response['status'], 'success');
  429. $this->assertEquals($response['form_name'], 'element_tag_proposition_'.$element->getId());
  430. $this->assertTrue(strpos($response['html'], 'class="tag_proposition"') !== false);
  431. // paul propose une serie de tags
  432. $crawler = $this->client->request(
  433. 'POST',
  434. $this->generateUrl('ajax_element_propose_tags_proceed',
  435. array('element_id' => $element->getId(), 'token' => $paul->getPersonalHash())
  436. ),
  437. array(
  438. 'element_tag_proposition_'.$element->getId() => array(
  439. 'tags' => json_encode(array($hardtek->getId(), $tribe->getId()))
  440. )
  441. ),
  442. array(),
  443. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  444. );
  445. $this->isResponseSuccess();
  446. $response = json_decode($this->client->getResponse()->getContent(), true);
  447. $this->assertEquals($response['status'], 'success');
  448. // On a maintenant la proposition en base
  449. $propositions = $this->getDoctrine()->getEntityManager()
  450. ->createQuery('SELECT p, t FROM MuzichCoreBundle:ElementTagsProposition p'
  451. .' JOIN p.tags t WHERE p.element = :eid AND p.user = :uid')
  452. ->setParameters(array(
  453. 'eid' => $element->getId(),
  454. 'uid' => $paul->getId()
  455. ))
  456. ->getResult()
  457. ;
  458. $this->assertEquals(1, count($propositions));
  459. $proposition_paul = $propositions[0];
  460. // Les tags sont aussi en base
  461. foreach ($propositions[0]->getTags() as $tag)
  462. {
  463. if (in_array($tag->getId(), array($hardtek->getId(), $tribe->getId())))
  464. {
  465. $this->assertTrue(true);
  466. }
  467. else
  468. {
  469. $this->assertTrue(false);
  470. }
  471. }
  472. // Il y a maintenant un event pour bux
  473. $events = $this->getDoctrine()->getEntityManager()
  474. ->createQuery('SELECT e FROM MuzichCoreBundle:Event e
  475. WHERE e.user = :uid AND e.type = :type'
  476. )
  477. ->setParameters(array(
  478. 'uid' => $bux->getId(),
  479. 'type' => \Muzich\CoreBundle\Entity\Event::TYPE_TAGS_PROPOSED
  480. ))
  481. ->getArrayResult()
  482. ;
  483. $this->assertEquals(count($events), 1);
  484. $this->assertEquals($events[0]['type'], \Muzich\CoreBundle\Entity\Event::TYPE_TAGS_PROPOSED);
  485. //
  486. $this->assertEquals($events[0]['count'], 1);
  487. $this->assertEquals($events[0]['ids'], json_encode(array((string)$element->getId())));
  488. // si il propose un liste vide de tags, c'est refusé bien entendu
  489. $crawler = $this->client->request(
  490. 'POST',
  491. $this->generateUrl('ajax_element_propose_tags_proceed',
  492. array('element_id' => $element->getId(), 'token' => $paul->getPersonalHash())
  493. ),
  494. array(
  495. 'element_tag_proposition_'.$element->getId() => array(
  496. 'tags' => json_encode(array())
  497. )
  498. ),
  499. array(),
  500. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  501. );
  502. $this->isResponseSuccess();
  503. $response = json_decode($this->client->getResponse()->getContent(), true);
  504. $this->assertEquals($response['status'], 'error');
  505. /*
  506. * joelle va aussi proposer des tags sur cet élément
  507. */
  508. $this->disconnectUser();
  509. $this->connectUser('joelle', 'toor');
  510. $joelle = $this->getUser();
  511. // joelle propose une serie de tags
  512. $crawler = $this->client->request(
  513. 'POST',
  514. $this->generateUrl('ajax_element_propose_tags_proceed',
  515. array('element_id' => $element->getId(), 'token' => $joelle->getPersonalHash())
  516. ),
  517. array(
  518. 'element_tag_proposition_'.$element->getId() => array(
  519. 'tags' => json_encode(array($tsouzoumi->getId(), $soug->getId(), $metal->getId()))
  520. )
  521. ),
  522. array(),
  523. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  524. );
  525. $this->isResponseSuccess();
  526. $response = json_decode($this->client->getResponse()->getContent(), true);
  527. $this->assertEquals($response['status'], 'success');
  528. // On a maintenant la proposition en base
  529. $propositions = $this->getDoctrine()->getEntityManager()
  530. ->createQuery('SELECT p, t FROM MuzichCoreBundle:ElementTagsProposition p'
  531. .' JOIN p.tags t WHERE p.element = :eid AND p.user = :uid')
  532. ->setParameters(array(
  533. 'eid' => $element->getId(),
  534. 'uid' => $joelle->getId()
  535. ))
  536. ->getResult()
  537. ;
  538. $this->assertEquals(1, count($propositions));
  539. $proposition_joelle = $propositions[0];
  540. // Les tags sont aussi en base
  541. foreach ($propositions[0]->getTags() as $tag)
  542. {
  543. if (in_array($tag->getId(), array($tsouzoumi->getId(), $soug->getId(), $metal->getId())))
  544. {
  545. $this->assertTrue(true);
  546. }
  547. else
  548. {
  549. $this->assertTrue(false);
  550. }
  551. }
  552. // avec la propsoition de joelle le nombre d'event n'a pas bougé (le compteur compte les éléments)
  553. $events = $this->getDoctrine()->getEntityManager()
  554. ->createQuery('SELECT e FROM MuzichCoreBundle:Event e
  555. WHERE e.user = :uid AND e.type = :type'
  556. )
  557. ->setParameters(array(
  558. 'uid' => $bux->getId(),
  559. 'type' => \Muzich\CoreBundle\Entity\Event::TYPE_TAGS_PROPOSED
  560. ))
  561. ->getArrayResult()
  562. ;
  563. $this->assertEquals(count($events), 1);
  564. $this->assertEquals($events[0]['type'], \Muzich\CoreBundle\Entity\Event::TYPE_TAGS_PROPOSED);
  565. //
  566. $this->assertEquals($events[0]['count'], 1);
  567. $this->assertEquals($events[0]['ids'], json_encode(array((string)$element->getId())));
  568. /*
  569. * C'est au tour de bux d'aller voir ces proposition
  570. */
  571. $this->disconnectUser();
  572. $this->connectUser('bux', 'toor');
  573. $bux = $this->getUser();
  574. // Il peut voir le lien vers l'ouverture des propositions
  575. $url = $this->generateUrl('ajax_element_proposed_tags_view', array('element_id' => $element->getId()));
  576. $this->exist('a[href="'.$url.'"]');
  577. // On récupére ces propositions
  578. $crawler = $this->client->request(
  579. 'GET',
  580. $url,
  581. array(),
  582. array(),
  583. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  584. );
  585. $this->isResponseSuccess();
  586. $response = json_decode($this->client->getResponse()->getContent(), true);
  587. $this->assertEquals($response['status'], 'success');
  588. $url_accept_paul = $this->generateUrl('ajax_element_proposed_tags_accept', array(
  589. 'proposition_id' => $proposition_paul->getId(),
  590. 'token' => $bux->getPersonalHash()
  591. ));
  592. $url_accept_joelle = $this->generateUrl('ajax_element_proposed_tags_accept', array(
  593. 'proposition_id' => $proposition_joelle->getId(),
  594. 'token' => $bux->getPersonalHash()
  595. ));
  596. $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_paul.'"') !== false);
  597. $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_joelle.'"') !== false);
  598. $url_refuse = $this->generateUrl('ajax_element_proposed_tags_refuse', array(
  599. 'element_id' => $element->getId(),
  600. 'token' => $bux->getPersonalHash()
  601. ));
  602. // On accepete la poposition de joelle
  603. $crawler = $this->client->request(
  604. 'GET',
  605. $url_accept_joelle,
  606. array(),
  607. array(),
  608. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  609. );
  610. $this->isResponseSuccess();
  611. $response = json_decode($this->client->getResponse()->getContent(), true);
  612. $this->assertEquals($response['status'], 'success');
  613. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  614. ->findOneByName('AZYD AZYLUM Live au Café Provisoire')
  615. ;
  616. // Les tags de l'élément ont bien été mis a jour
  617. foreach (json_decode($element->getTagsIdsJson(), true) as $id)
  618. {
  619. if (in_array($id, array($metal->getId(), $soug->getId(), $tsouzoumi->getId())))
  620. {
  621. $this->assertTrue(true);
  622. }
  623. else
  624. {
  625. $this->assertTrue(false);
  626. }
  627. }
  628. $ids = json_decode($element->getTagsIdsJson(), true);
  629. foreach (array($metal->getId(), $soug->getId(), $tsouzoumi->getId()) as $id)
  630. {
  631. if (in_array($id, $ids))
  632. {
  633. $this->assertTrue(true);
  634. }
  635. else
  636. {
  637. $this->assertTrue(false);
  638. }
  639. }
  640. // La proposition de joelle a disparu
  641. $propositions = $this->getDoctrine()->getEntityManager()
  642. ->createQuery('SELECT p, t FROM MuzichCoreBundle:ElementTagsProposition p'
  643. .' JOIN p.tags t WHERE p.element = :eid AND p.user = :uid')
  644. ->setParameters(array(
  645. 'eid' => $element->getId(),
  646. 'uid' => $joelle->getId()
  647. ))
  648. ->getResult()
  649. ;
  650. $this->assertEquals(0, count($propositions));
  651. // celle de paul aussi
  652. $propositions = $this->getDoctrine()->getEntityManager()
  653. ->createQuery('SELECT p, t FROM MuzichCoreBundle:ElementTagsProposition p'
  654. .' JOIN p.tags t WHERE p.element = :eid AND p.user = :uid')
  655. ->setParameters(array(
  656. 'eid' => $element->getId(),
  657. 'uid' => $paul->getId()
  658. ))
  659. ->getResult()
  660. ;
  661. $this->assertEquals(0, count($propositions));
  662. // Mais on a un event en archive pour joelle
  663. $archives = $this->getDoctrine()->getEntityManager()
  664. ->createQuery('SELECT a FROM MuzichCoreBundle:EventArchive a'
  665. .' WHERE a.user = :uid AND a.type = :type')
  666. ->setParameters(array(
  667. 'uid' => $joelle->getId(),
  668. 'type' => \Muzich\CoreBundle\Entity\EventArchive::PROP_TAGS_ELEMENT_ACCEPTED
  669. ))
  670. ->getResult()
  671. ;
  672. $this->assertEquals(1, count($archives));
  673. $this->assertEquals(1, $archives[0]->getCount());
  674. // paul lui n'a pas d'archives
  675. $archives = $this->getDoctrine()->getEntityManager()
  676. ->createQuery('SELECT a FROM MuzichCoreBundle:EventArchive a'
  677. .' WHERE a.user = :uid AND a.type = :type')
  678. ->setParameters(array(
  679. 'uid' => $paul->getId(),
  680. 'type' => \Muzich\CoreBundle\Entity\EventArchive::PROP_TAGS_ELEMENT_ACCEPTED
  681. ))
  682. ->getResult()
  683. ;
  684. $this->assertEquals(0, count($archives));
  685. // contrôle de l'évolution des points
  686. $bux = $this->getUser('bux');
  687. $joelle = $this->getUser('joelle');
  688. $paul = $this->getUser('paul');
  689. $this->assertEquals($points_bux, $bux->getReputation());
  690. $this->assertEquals($points_joelle + $points_pour_tags_add, $joelle->getReputation());
  691. $this->assertEquals($points_paul, $paul->getReputation());
  692. }
  693. /**
  694. * Test des procédure concernants al proposition de tags sur un élément
  695. *
  696. * On test ici:
  697. * * Proposition de tags
  698. * * La consultation de ces propositions
  699. * * Le refus
  700. */
  701. public function testTagsPropositionRefuse()
  702. {
  703. $this->client = self::createClient();
  704. $this->connectUser('paul', 'toor');
  705. $hardtek = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Hardtek');
  706. $tribe = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tribe');
  707. $tsouzoumi = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Tsouzoumi');
  708. $soug = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Soug');
  709. $metal = $this->getDoctrine()->getRepository('MuzichCoreBundle:Tag')->findOneByName('Metal');
  710. $paul = $this->getUser();
  711. $bux = $this->getUser('bux');
  712. $joelle = $this->getUser('joelle');
  713. $points_pour_tags_add = $this->getContainer()->getParameter('reputation_element_tags_element_prop_value');
  714. $points_joelle = $joelle->getReputation();
  715. $points_bux = $bux->getReputation();
  716. $points_paul = $paul->getReputation();
  717. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  718. ->findOneByName('AZYD AZYLUM Live au Café Provisoire')
  719. ;
  720. // Pas de proposition en base pur cet élément
  721. $propositions = $this->getDoctrine()->getEntityManager()->getRepository('MuzichCoreBundle:ElementTagsProposition')
  722. ->findOneByElement($element->getId())
  723. ;
  724. $this->assertEquals(0, count($propositions));
  725. // Pas d'événement pour bux
  726. $events = $this->getDoctrine()->getEntityManager()
  727. ->createQuery('SELECT e FROM MuzichCoreBundle:Event e
  728. WHERE e.user = :uid AND e.type = :type'
  729. )
  730. ->setParameters(array(
  731. 'uid' => $bux->getId(),
  732. 'type' => \Muzich\CoreBundle\Entity\Event::TYPE_TAGS_PROPOSED
  733. ))
  734. ->getArrayResult()
  735. ;
  736. $this->assertEquals(count($events), 0);
  737. // On teste la récupération du formulaire au moin une fois
  738. $crawler = $this->client->request(
  739. 'GET',
  740. $this->generateUrl('ajax_element_propose_tags_open',
  741. array('element_id' => $element->getId())
  742. ),
  743. array(),
  744. array(),
  745. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  746. );
  747. $this->isResponseSuccess();
  748. $response = json_decode($this->client->getResponse()->getContent(), true);
  749. $this->assertEquals($response['status'], 'success');
  750. $this->assertEquals($response['form_name'], 'element_tag_proposition_'.$element->getId());
  751. $this->assertTrue(strpos($response['html'], 'class="tag_proposition"') !== false);
  752. // paul propose une serie de tags
  753. $crawler = $this->client->request(
  754. 'POST',
  755. $this->generateUrl('ajax_element_propose_tags_proceed',
  756. array('element_id' => $element->getId(), 'token' => $paul->getPersonalHash())
  757. ),
  758. array(
  759. 'element_tag_proposition_'.$element->getId() => array(
  760. 'tags' => json_encode(array($hardtek->getId(), $tribe->getId()))
  761. )
  762. ),
  763. array(),
  764. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  765. );
  766. $this->isResponseSuccess();
  767. $response = json_decode($this->client->getResponse()->getContent(), true);
  768. $this->assertEquals($response['status'], 'success');
  769. // On a maintenant la proposition en base
  770. $propositions = $this->getDoctrine()->getEntityManager()
  771. ->createQuery('SELECT p, t FROM MuzichCoreBundle:ElementTagsProposition p'
  772. .' JOIN p.tags t WHERE p.element = :eid AND p.user = :uid')
  773. ->setParameters(array(
  774. 'eid' => $element->getId(),
  775. 'uid' => $paul->getId()
  776. ))
  777. ->getResult()
  778. ;
  779. $this->assertEquals(1, count($propositions));
  780. $proposition_paul = $propositions[0];
  781. // Les tags sont aussi en base
  782. foreach ($propositions[0]->getTags() as $tag)
  783. {
  784. if (in_array($tag->getId(), array($hardtek->getId(), $tribe->getId())))
  785. {
  786. $this->assertTrue(true);
  787. }
  788. else
  789. {
  790. $this->assertTrue(false);
  791. }
  792. }
  793. // Il y a maintenant un event pour bux
  794. $events = $this->getDoctrine()->getEntityManager()
  795. ->createQuery('SELECT e FROM MuzichCoreBundle:Event e
  796. WHERE e.user = :uid AND e.type = :type'
  797. )
  798. ->setParameters(array(
  799. 'uid' => $bux->getId(),
  800. 'type' => \Muzich\CoreBundle\Entity\Event::TYPE_TAGS_PROPOSED
  801. ))
  802. ->getArrayResult()
  803. ;
  804. $this->assertEquals(count($events), 1);
  805. $this->assertEquals($events[0]['type'], \Muzich\CoreBundle\Entity\Event::TYPE_TAGS_PROPOSED);
  806. //
  807. $this->assertEquals($events[0]['count'], 1);
  808. $this->assertEquals($events[0]['ids'], json_encode(array((string)$element->getId())));
  809. // si il propose un liste vide de tags, c'est refusé bien entendu
  810. $crawler = $this->client->request(
  811. 'POST',
  812. $this->generateUrl('ajax_element_propose_tags_proceed',
  813. array('element_id' => $element->getId(), 'token' => $paul->getPersonalHash())
  814. ),
  815. array(
  816. 'element_tag_proposition_'.$element->getId() => array(
  817. 'tags' => json_encode(array())
  818. )
  819. ),
  820. array(),
  821. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  822. );
  823. $this->isResponseSuccess();
  824. $response = json_decode($this->client->getResponse()->getContent(), true);
  825. $this->assertEquals($response['status'], 'error');
  826. /*
  827. * joelle va aussi proposer des tags sur cet élément
  828. */
  829. $this->disconnectUser();
  830. $this->connectUser('joelle', 'toor');
  831. $joelle = $this->getUser();
  832. // joelle propose une serie de tags
  833. $crawler = $this->client->request(
  834. 'POST',
  835. $this->generateUrl('ajax_element_propose_tags_proceed',
  836. array('element_id' => $element->getId(), 'token' => $joelle->getPersonalHash())
  837. ),
  838. array(
  839. 'element_tag_proposition_'.$element->getId() => array(
  840. 'tags' => json_encode(array($tsouzoumi->getId(), $soug->getId(), $metal->getId()))
  841. )
  842. ),
  843. array(),
  844. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  845. );
  846. $this->isResponseSuccess();
  847. $response = json_decode($this->client->getResponse()->getContent(), true);
  848. $this->assertEquals($response['status'], 'success');
  849. // On a maintenant la proposition en base
  850. $propositions = $this->getDoctrine()->getEntityManager()
  851. ->createQuery('SELECT p, t FROM MuzichCoreBundle:ElementTagsProposition p'
  852. .' JOIN p.tags t WHERE p.element = :eid AND p.user = :uid')
  853. ->setParameters(array(
  854. 'eid' => $element->getId(),
  855. 'uid' => $joelle->getId()
  856. ))
  857. ->getResult()
  858. ;
  859. $this->assertEquals(1, count($propositions));
  860. $proposition_joelle = $propositions[0];
  861. // Les tags sont aussi en base
  862. foreach ($propositions[0]->getTags() as $tag)
  863. {
  864. if (in_array($tag->getId(), array($tsouzoumi->getId(), $soug->getId(), $metal->getId())))
  865. {
  866. $this->assertTrue(true);
  867. }
  868. else
  869. {
  870. $this->assertTrue(false);
  871. }
  872. }
  873. // avec la propsoition de joelle le nombre d'event n'a pas bougé (le compteur compte les éléments)
  874. $events = $this->getDoctrine()->getEntityManager()
  875. ->createQuery('SELECT e FROM MuzichCoreBundle:Event e
  876. WHERE e.user = :uid AND e.type = :type'
  877. )
  878. ->setParameters(array(
  879. 'uid' => $bux->getId(),
  880. 'type' => \Muzich\CoreBundle\Entity\Event::TYPE_TAGS_PROPOSED
  881. ))
  882. ->getArrayResult()
  883. ;
  884. $this->assertEquals(count($events), 1);
  885. $this->assertEquals($events[0]['type'], \Muzich\CoreBundle\Entity\Event::TYPE_TAGS_PROPOSED);
  886. //
  887. $this->assertEquals($events[0]['count'], 1);
  888. $this->assertEquals($events[0]['ids'], json_encode(array((string)$element->getId())));
  889. /*
  890. * C'est au tour de bux d'aller voir ces proposition
  891. */
  892. $this->disconnectUser();
  893. $this->connectUser('bux', 'toor');
  894. $bux = $this->getUser();
  895. // Il peut voir le lien vers l'ouverture des propositions
  896. $url = $this->generateUrl('ajax_element_proposed_tags_view', array('element_id' => $element->getId()));
  897. $this->exist('a[href="'.$url.'"]');
  898. // On récupére ces propositions
  899. $crawler = $this->client->request(
  900. 'GET',
  901. $url,
  902. array(),
  903. array(),
  904. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  905. );
  906. $this->isResponseSuccess();
  907. $response = json_decode($this->client->getResponse()->getContent(), true);
  908. $this->assertEquals($response['status'], 'success');
  909. $url_accept_paul = $this->generateUrl('ajax_element_proposed_tags_accept', array(
  910. 'proposition_id' => $proposition_paul->getId(),
  911. 'token' => $bux->getPersonalHash()
  912. ));
  913. $url_accept_joelle = $this->generateUrl('ajax_element_proposed_tags_accept', array(
  914. 'proposition_id' => $proposition_joelle->getId(),
  915. 'token' => $bux->getPersonalHash()
  916. ));
  917. $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_paul.'"') !== false);
  918. $this->assertTrue(strpos($response['html'], 'href="'.$url_accept_joelle.'"') !== false);
  919. $url_refuse = $this->generateUrl('ajax_element_proposed_tags_refuse', array(
  920. 'element_id' => $element->getId(),
  921. 'token' => $bux->getPersonalHash()
  922. ));
  923. // On accepete la poposition de joelle
  924. $crawler = $this->client->request(
  925. 'GET',
  926. $url_refuse,
  927. array(),
  928. array(),
  929. array('HTTP_X-Requested-With' => 'XMLHttpRequest')
  930. );
  931. $this->isResponseSuccess();
  932. $response = json_decode($this->client->getResponse()->getContent(), true);
  933. $this->assertEquals($response['status'], 'success');
  934. $element = $this->getDoctrine()->getRepository('MuzichCoreBundle:Element')
  935. ->findOneByName('AZYD AZYLUM Live au Café Provisoire')
  936. ;
  937. // Les tags de l'élément n'ont pas bougés
  938. $this->assertEquals(
  939. json_encode(array($metal->getId())),
  940. $element->getTagsIdsJson()
  941. );
  942. // La proposition de joelle a disparu
  943. $propositions = $this->getDoctrine()->getEntityManager()
  944. ->createQuery('SELECT p, t FROM MuzichCoreBundle:ElementTagsProposition p'
  945. .' JOIN p.tags t WHERE p.element = :eid AND p.user = :uid')
  946. ->setParameters(array(
  947. 'eid' => $element->getId(),
  948. 'uid' => $joelle->getId()
  949. ))
  950. ->getResult()
  951. ;
  952. $this->assertEquals(0, count($propositions));
  953. // celle de paul aussi
  954. $propositions = $this->getDoctrine()->getEntityManager()
  955. ->createQuery('SELECT p, t FROM MuzichCoreBundle:ElementTagsProposition p'
  956. .' JOIN p.tags t WHERE p.element = :eid AND p.user = :uid')
  957. ->setParameters(array(
  958. 'eid' => $element->getId(),
  959. 'uid' => $paul->getId()
  960. ))
  961. ->getResult()
  962. ;
  963. $this->assertEquals(0, count($propositions));
  964. // Et on as pas d'archive pour joelle
  965. $archives = $this->getDoctrine()->getEntityManager()
  966. ->createQuery('SELECT a FROM MuzichCoreBundle:EventArchive a'
  967. .' WHERE a.user = :uid AND a.type = :type')
  968. ->setParameters(array(
  969. 'uid' => $joelle->getId(),
  970. 'type' => \Muzich\CoreBundle\Entity\EventArchive::PROP_TAGS_ELEMENT_ACCEPTED
  971. ))
  972. ->getResult()
  973. ;
  974. $this->assertEquals(0, count($archives));
  975. // paul lui n'a pas d'archives non plus
  976. $archives = $this->getDoctrine()->getEntityManager()
  977. ->createQuery('SELECT a FROM MuzichCoreBundle:EventArchive a'
  978. .' WHERE a.user = :uid AND a.type = :type')
  979. ->setParameters(array(
  980. 'uid' => $paul->getId(),
  981. 'type' => \Muzich\CoreBundle\Entity\EventArchive::PROP_TAGS_ELEMENT_ACCEPTED
  982. ))
  983. ->getResult()
  984. ;
  985. $this->assertEquals(0, count($archives));
  986. // contrôle de l'évolution des points
  987. $bux = $this->getUser('bux');
  988. $joelle = $this->getUser('joelle');
  989. $paul = $this->getUser('paul');
  990. $this->assertEquals($points_bux, $bux->getReputation());
  991. $this->assertEquals($points_joelle, $joelle->getReputation());
  992. $this->assertEquals($points_paul, $paul->getReputation());
  993. }
  994. }