/**
  * @param         $name
  * @param         $user
  * @param         $quantite
  * @param boolean $filter
  * @param int     $day
  * @param string  $method
  * @return string
  */
 public function rename($name, User $user, $quantite, $filter = false, $day = 5, $method = 'EXP')
 {
     $date = $this->weekDate($day);
     if ($filter) {
         $name = $this->extractName($name);
     }
     return sprintf('%s-%s-X%s-%s-%s', $date, $method, $quantite, $user->getUsername(), $name);
 }
 public function testShouldReturnDateInGoodFormat()
 {
     $session = new Session(new MockArraySessionStorage());
     $user = new User();
     $user->setUsername('kristen');
     $tokenStorage = new TokenStorage();
     $tokenStorage->setToken(new UsernamePasswordToken($user, 'test', 'fritage', array('ROLE_USER')));
     $namer = new FinorthoNamer($tokenStorage, $session);
     $date = $namer->weekDate(5);
     $carbon = Carbon::createFromFormat('ymd', $date);
     $this->assertFalse($carbon->isWeekend());
 }
 public function testShloudGiveBackAnArray()
 {
     $user = new User();
     $user->setUsername('kristen');
     $tokenStorage = new TokenStorage();
     $tokenStorage->setToken(new UsernamePasswordToken($user, 'test', 'fritage', array('ROLE_USER')));
     $repository = $this->getMockBuilder('\\Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $repository->expects($this->once())->method('findBy')->will($this->returnValue(array(array('id' => 1, 'url' => 'test', 'name' => 'ect..'))));
     // Last, mock the EntityManager to return the mock of the repository
     $entityManager = $this->getMockBuilder('\\Doctrine\\Common\\Persistence\\ObjectManager')->disableOriginalConstructor()->getMock();
     $entityManager->expects($this->any())->method('getRepository')->willReturn($repository);
     $last = new LastUploads($entityManager, $tokenStorage);
     $this->assertTrue(is_array($last->get()));
 }
Example #4
0
 public function setUp()
 {
     $this->from = '*****@*****.**';
     $this->to = '*****@*****.**';
     $this->host = 'server';
     $mailjet = $this->getMockBuilder('\\Headoo\\HeadooMailjetBundle\\Wrapper\\MailjetWrapper')->disableOriginalConstructor()->getMock();
     $mailjet->expects($this->once())->method('__call')->will($this->returnCallback(function ($_, $args) {
         return $args;
     }));
     $this->email = new Email($mailjet, $this->from, $this->to, $this->host);
     $user = new User();
     $user->setUsername('testman');
     $user->setEmail('*****@*****.**');
     $this->user = $user;
 }
Example #5
0
 /**
  * Envoyer à l'administrateur le message qui a été posté sur la plateforme
  *
  * @param User $user Utilisateur qui a envoyé le message
  * @param string $message Message de l'utilisateur
  * @return mixed
  */
 public function sendAdminNotificationMessage(User $user, $message)
 {
     $template = $this->getTemplate($user->getUsername(), $user->getEmail(), $this->host, null, $message);
     $params = array("method" => "POST", "from" => $this->from, "to" => $this->to, "subject" => "Nouveau message d'aide de l'utilisateur", "html" => $template);
     return $this->mailjet->sendEmail($params);
 }