Browse Source

Evolution #160: Test pour reputation

bastien 13 years ago
parent
commit
0ad71a8c54

+ 17 - 1
src/Muzich/CoreBundle/Tests/Controller/ElementControllerTest.php View File

502
     // Et ce sont (fixtures) ces deux user qui ont voté
502
     // Et ce sont (fixtures) ces deux user qui ont voté
503
     $this->assertEquals($element_ed->getVoteGoodIds(), array((string)$joelle->getId(), (string)$jean->getId()));
503
     $this->assertEquals($element_ed->getVoteGoodIds(), array((string)$joelle->getId(), (string)$jean->getId()));
504
     
504
     
505
-    // paul va voter egallement
505
+    // On peut d'ailleur constater que la reputation de bux est de 7 (fixtures)
506
+    $bux = $this->getUser('bux');
507
+    $this->assertEquals($bux->getReputation(), 7);
508
+    
509
+    // paul va voter 
506
     $crawler = $this->client->request(
510
     $crawler = $this->client->request(
507
       'GET', 
511
       'GET', 
508
       $this->generateUrl('ajax_element_add_vote_good', array(
512
       $this->generateUrl('ajax_element_add_vote_good', array(
534
       (string)$paul->getId()
538
       (string)$paul->getId()
535
     ));
539
     ));
536
     
540
     
541
+    // On peut d'ailleur constater que la reputation de bux est maintenant de 8
542
+    $bux = $this->getUser('bux');
543
+    $this->assertEquals($bux->getReputation(), 8);
544
+    
537
     // Pau retire son vote de soulfy
545
     // Pau retire son vote de soulfy
538
     $crawler = $this->client->request(
546
     $crawler = $this->client->request(
539
       'GET', 
547
       'GET', 
552
     // Et son id est la
560
     // Et son id est la
553
     $this->assertEquals($element_soul->getVoteGoodIds(), array());
561
     $this->assertEquals($element_soul->getVoteGoodIds(), array());
554
     
562
     
563
+    // On peut d'ailleur constater que la reputation de bux est maintenant de 7
564
+    $bux = $this->getUser('bux');
565
+    $this->assertEquals($bux->getReputation(), 7);
566
+    
555
     // On déconnecte paul, pour faire voter bob sur le partage ed cox
567
     // On déconnecte paul, pour faire voter bob sur le partage ed cox
556
     $this->disconnectUser();
568
     $this->disconnectUser();
557
     $this->connectUser('bob', 'toor');
569
     $this->connectUser('bob', 'toor');
589
       (string)$paul->getId(),
601
       (string)$paul->getId(),
590
       (string)$bob->getId()
602
       (string)$bob->getId()
591
     ));
603
     ));
604
+    
605
+    // On peut d'ailleur constater que la reputation de bux est maintenant de 8
606
+    $bux = $this->getUser('bux');
607
+    $this->assertEquals($bux->getReputation(), 8);
592
   }
608
   }
593
   
609
   
594
 }
610
 }

+ 55 - 0
src/Muzich/CoreBundle/Tests/Controller/ReputationTest.php View File

1
+<?php
2
+
3
+namespace Muzich\CoreBundle\Tests\Controller;
4
+
5
+use Muzich\CoreBundle\lib\FunctionalTest;
6
+
7
+//use Symfony\Bundle\FrameworkBundle\Console\Application;
8
+//use Muzich\CoreBundle\Command\RecalculateReputationCommand;
9
+//use Symfony\Component\Console\Tester\CommandTester;
10
+////use \AppKernel;
11
+//use Symfony\Component\HttpFoundation\Request;
12
+
13
+class ReputationTest extends FunctionalTest
14
+{
15
+  
16
+//  public function testCommandLineCalculateReputation()
17
+//  {
18
+//    require_once __DIR__.'/../../../../../app/bootstrap.php.cache';
19
+//    require_once __DIR__.'/../../../../../app/AppKernel.php';
20
+//    
21
+//    $kernel = new \AppKernel('test', true);
22
+//    $kernel->loadClassCache();
23
+//    $kernel->handle(Request::createFromGlobals())->send();
24
+//    
25
+//    $application = new Application($kernel);
26
+//    $application->add(new RecalculateReputationCommand());
27
+//
28
+//    $command = $application->find('users:reputation:recalculate');
29
+//    $commandTester = new CommandTester($command);
30
+//    
31
+//    $bux = $this->getUser('bux');
32
+//    $bux->setReputation(0);
33
+//    $this->getDoctrine()->getEntityManager()->persist($bux);
34
+//    $this->getDoctrine()->getEntityManager()->flush();
35
+//    
36
+//    $bux = $this->getUser('bux');
37
+//    $this->assertEquals($bux->getReputation(), 0);
38
+//    
39
+//    //$commandTester->execute(array('command' => $command->getName()));
40
+//  }
41
+  
42
+  /**
43
+   * Test de l'impact sur la reputation lorsque il y a vote sur element
44
+   */
45
+  public function testImpactElementVote()
46
+  {
47
+    $this->client = self::createClient();
48
+    $this->connectUser('paul', 'toor');
49
+    $paul = $this->getUser();
50
+    
51
+    //
52
+    
53
+  }
54
+  
55
+}