示例#1
0
 public function testShouldBeAlertedReturnsFalseWithSettingNone()
 {
     $this->user->setAlertSetting(AlertSetting::NONE);
     foreach (ResultStatus::getAll() as $status) {
         $result = new TestResult();
         $result->setStatus($status)->setInfo("Stahp shut up and take my money scumbag stacy trollface.");
         $this->assertFalse($this->user->shouldBeAlerted($result));
     }
 }
示例#2
0
 public function run(\Overwatch\TestBundle\Entity\Test $test)
 {
     $testResult = new TestResult();
     $testResult->setTest($test);
     try {
         $result = $this->get($test->getExpectation())->run($test->getActual(), $test->getExpected());
         $testResult->setStatus(ResultStatus::PASSED);
         $testResult->setInfo($result);
     } catch (\Exception $ex) {
         $result = $ex;
         $testResult->setInfo($ex->getMessage());
     }
     if ($result instanceof ExpectationException\ExpectationFailedException) {
         $testResult->setStatus(ResultStatus::FAILED);
     } else {
         if ($result instanceof ExpectationException\ExpectationUnsatisfactoryException) {
             $testResult->setStatus(ResultStatus::UNSATISFACTORY);
         } else {
             if ($result instanceof \Exception) {
                 $testResult->setStatus(ResultStatus::ERROR);
             }
         }
     }
     return $testResult;
 }
示例#3
0
 public function testIsAChange()
 {
     $oldResult = new TestResult();
     $oldResult->setStatus(ResultStatus::PASSED)->setTest($this->test);
     $this->test->addResult($oldResult);
     $this->result->setStatus(ResultStatus::PASSED)->setTest($this->test);
     $this->test->addResult($this->result);
     $this->assertFalse($this->result->isAChange());
     $newResult = new TestResult();
     $newResult->setStatus(ResultStatus::UNSATISFACTORY)->setTest($this->test);
     $this->test->addResult($newResult);
     $this->assertTrue($newResult->isAChange());
 }
示例#4
0
 public function load(ObjectManager $em)
 {
     $result1 = new TestResult();
     $result1->setTest($this->getReference('test-1'))->setStatus(ResultStatus::PASSED)->setInfo("Ermahgerd cool story bro trollface soon overly manly man.")->setCreatedAt("-2 hours");
     $em->persist($result1);
     $result2 = new TestResult();
     $result2->setTest($this->getReference('test-1'))->setStatus(ResultStatus::FAILED)->setInfo("Brace yourselves doge forever alone bad luck Brian.")->setCreatedAt("-1 hour");
     $em->persist($result2);
     $result3 = new TestResult();
     $result3->setTest($this->getReference('test-1'))->setStatus(ResultStatus::PASSED)->setInfo("Me gusta success kid upvoting Obama first world problems.")->setCreatedAt("-30 minutes");
     $em->persist($result3);
     $result4 = new TestResult();
     $result4->setTest($this->getReference('test-2'))->setStatus(ResultStatus::PASSED)->setInfo("This test is thrown in to try and trick the system. Muahhaha.")->setCreatedAt("-10 minutes");
     $em->persist($result4);
     $this->addReference('result-1', $result1);
     $this->addReference('result-2', $result2);
     $this->addReference('result-3', $result3);
     $this->addReference('result-4', $result4);
     $em->flush();
 }
示例#5
0
 private function sendEmail(TestResult $result, array $users)
 {
     $message = \Swift_Message::newInstance()->setSubject($result->getTest()->getName() . " " . $result->getStatus())->setFrom($this->config['report_from'])->setTo($users)->setBody($this->container->get('templating')->render('OverwatchServiceBundle:Email:result.txt.twig', ["result" => $result]), 'text\\plain');
     $this->container->get('mailer')->send($message);
 }
示例#6
0
 /**
  * Should this user be alerted for the passed TestResult?
  * 
  * @param \Overwatch\ResultBundle\Entity\TestResult $result
  * @return bool
  */
 public function shouldBeAlerted(\Overwatch\ResultBundle\Entity\TestResult $result)
 {
     $setting = $this->getAlertSetting();
     if ($this->isLocked() || $setting === AlertSetting::NONE) {
         return false;
     }
     if (!$this->hasGroup($result->getTest()->getGroup()->getName())) {
         return false;
     }
     if ($setting === AlertSetting::ALL) {
         return true;
     }
     if ($result->isUnsuccessful() && $setting === AlertSetting::CHANGE_ALL) {
         return true;
     }
     if ($result->isAChange()) {
         if (in_array($setting, [AlertSetting::CHANGE, AlertSetting::CHANGE_ALL])) {
             return true;
         }
         if ($result->isUnsuccessful() && $setting === AlertSetting::CHANGE_BAD) {
             return true;
         }
     }
     return false;
 }