private function generateXML($tmpDir)
 {
     AnnotationRegistry::registerAutoloadNamespace('JMS\\Serializer\\Annotation', __DIR__ . "/../../../../vendor/jms/serializer/src");
     Model\Provider::setOutputDirectory($tmpDir);
     Allure::setDefaultLifecycle();
     $testSuiteStartedEvent = new TestSuiteStartedEvent(TEST_SUITE_NAME);
     $uuid = $testSuiteStartedEvent->getUuid();
     $testSuiteStartedEvent->setTitle(TEST_SUITE_TITLE);
     $testSuiteStartedEvent->setDescription(new Description(DescriptionType::HTML, DESCRIPTION));
     $testSuiteStartedEvent->setLabels([Label::feature(FEATURE_NAME), Label::story(STORY_NAME)]);
     Allure::lifecycle()->fire($testSuiteStartedEvent);
     $testCaseStartedEvent = new TestCaseStartedEvent($uuid, TEST_CASE_NAME);
     $testCaseStartedEvent->setDescription(new Description(DescriptionType::MARKDOWN, DESCRIPTION));
     $testCaseStartedEvent->setLabels([Label::feature(FEATURE_NAME), Label::story(STORY_NAME), Label::severity(SeverityLevel::MINOR)]);
     $testCaseStartedEvent->setTitle(TEST_CASE_TITLE);
     $testCaseStartedEvent->setParameters([new Parameter(PARAMETER_NAME, PARAMETER_VALUE, ParameterKind::SYSTEM_PROPERTY)]);
     Allure::lifecycle()->fire($testCaseStartedEvent);
     $testCaseFailureEvent = new TestCaseFailedEvent();
     $testCaseFailureEvent = $testCaseFailureEvent->withMessage(FAILURE_MESSAGE)->withException(new \Exception());
     Allure::lifecycle()->fire($testCaseFailureEvent);
     $stepStartedEvent = new StepStartedEvent(STEP_NAME);
     $stepStartedEvent = $stepStartedEvent->withTitle(STEP_TITLE);
     Allure::lifecycle()->fire($stepStartedEvent);
     Allure::lifecycle()->fire(new AddAttachmentEvent(STEP_ATTACHMENT_SOURCE, STEP_ATTACHMENT_TITLE, 'text/plain'));
     Allure::lifecycle()->fire(new StepFinishedEvent());
     Allure::lifecycle()->fire(new TestCaseFinishedEvent());
     Allure::lifecycle()->fire(new TestSuiteFinishedEvent($uuid));
     return $uuid;
 }
 protected function setUp()
 {
     parent::setUp();
     $this->mockedLifecycle = new MockedLifecycle();
     Allure::setLifecycle($this->getMockedLifecycle());
     $this->allureAdapter = new AllureAdapter('test-output-directory', true);
 }
 /**
  * Adds a simple step to current test case
  * @param string $name step name
  * @param callable $logic anonymous function containing the entire step logic.
  * @param string $title an optional title for the step
  * @return mixed
  * @throws \Yandex\Allure\Adapter\AllureException
  * @throws \Exception
  */
 public function executeStep($name, $logic, $title = null)
 {
     $logicResult = null;
     if (isset($name) && is_callable($logic)) {
         $event = new StepStartedEvent($name);
         if (isset($title)) {
             $event->withTitle($title);
         } else {
             $event->withTitle($name);
         }
         Allure::lifecycle()->fire($event);
         try {
             $logicResult = $logic();
             Allure::lifecycle()->fire(new StepFinishedEvent());
         } catch (Exception $e) {
             $stepFailedEvent = new StepFailedEvent();
             Allure::lifecycle()->fire($stepFailedEvent);
             Allure::lifecycle()->fire(new StepFinishedEvent());
             throw $e;
         }
     } else {
         throw new AllureException("Step name shouldn't be null and logic should be a callable.");
     }
     return $logicResult;
 }
 public function testAddAttachment()
 {
     $attachmentContents = 'test-contents';
     $attachmentCaption = 'test-title';
     $attachmentType = 'text/html';
     Provider::setOutputDirectory(sys_get_temp_dir());
     $this->addAttachment($attachmentContents, $attachmentCaption, $attachmentType);
     $event = Allure::lifecycle()->getLastEvent();
     $this->assertTrue($event instanceof AddAttachmentEvent && $event->getFilePathOrContents() === $attachmentContents && $event->getCaption() === $attachmentCaption && $event->getType() === $attachmentType);
 }
 public function testTestSuiteFinishedEvent()
 {
     Allure::lifecycle()->getTestSuiteStorage()->clear();
     $testSuite = Allure::lifecycle()->getTestSuiteStorage()->get(self::TEST_SUITE_UUID);
     $testSuite->addTestCase(new TestCase());
     $this->assertEquals(1, Allure::lifecycle()->getTestSuiteStorage()->size());
     $outputDirectory = sys_get_temp_dir();
     AnnotationRegistry::registerAutoloadNamespace('JMS\\Serializer\\Annotation', __DIR__ . "/../../../../vendor/jms/serializer/src");
     Provider::setOutputDirectory($outputDirectory);
     $xmlFilePath = $outputDirectory . DIRECTORY_SEPARATOR . self::TEST_SUITE_UUID . '-testsuite.xml';
     Allure::lifecycle()->fire(new TestSuiteFinishedEvent(self::TEST_SUITE_UUID));
     $this->assertTrue(Allure::lifecycle()->getTestSuiteStorage()->isEmpty());
     $this->assertTrue(file_exists($xmlFilePath));
 }
 /**
  * Adds a new attachment to report
  * @param string $filePathOrContents either a string with file contents or file path to copy
  * @param $caption
  * @param $type
  */
 public function addAttachment($filePathOrContents, $caption, $type = null)
 {
     Allure::lifecycle()->fire(new AddAttachmentEvent($filePathOrContents, $caption, $type));
 }
 protected function tearDown()
 {
     parent::tearDown();
     Allure::setDefaultLifecycle();
 }
 public function __construct()
 {
     parent::__construct();
     $this->reset();
 }
 /**
  * A test ended.
  *
  * @param PHPUnit_Framework_Test $test
  * @param float $time
  * @throws \Exception
  */
 public function endTest(PHPUnit_Framework_Test $test, $time)
 {
     if ($test instanceof \PHPUnit_Framework_TestCase) {
         Allure::lifecycle()->fire(new TestCaseFinishedEvent());
     }
 }
 /**
  * @return Allure
  */
 public function getLifecycle()
 {
     if (!isset($this->lifecycle)) {
         $this->lifecycle = Allure::lifecycle();
     }
     return $this->lifecycle;
 }