public function testTestCaseFinishedEvent()
 {
     Allure::lifecycle()->getStepStorage()->clear();
     Allure::lifecycle()->getStepStorage()->getLast();
     //To initialize root step
     Allure::lifecycle()->getTestCaseStorage()->clear();
     $step = new Step();
     $step->setName(self::STEP_NAME);
     $attachment = new Attachment(self::STEP_ATTACHMENT_TITLE, self::STEP_ATTACHMENT_SOURCE, self::STEP_ATTACHMENT_TYPE);
     Allure::lifecycle()->getStepStorage()->getLast()->addStep($step);
     Allure::lifecycle()->getStepStorage()->getLast()->addAttachment($attachment);
     $testCaseFromStorage = Allure::lifecycle()->getTestCaseStorage()->get();
     Allure::lifecycle()->fire(new TestCaseFinishedEvent());
     //Checking that attachments were moved
     $attachments = $testCaseFromStorage->getAttachments();
     $this->assertEquals(1, sizeof($attachments));
     $attachment = array_pop($attachments);
     $this->assertTrue($attachment instanceof Attachment && $attachment->getTitle() === self::STEP_ATTACHMENT_TITLE && $attachment->getSource() === self::STEP_ATTACHMENT_SOURCE && $attachment->getType() === self::STEP_ATTACHMENT_TYPE);
     //Checking that steps were moved
     $steps = $testCaseFromStorage->getSteps();
     $this->assertEquals(1, sizeof($steps));
     $stepFromStorage = array_pop($steps);
     $this->assertTrue($stepFromStorage instanceof Step && $stepFromStorage->getName() === self::STEP_NAME);
     $this->assertTrue(Allure::lifecycle()->getTestCaseStorage()->isEmpty());
 }
 public function testNonEmptyStorage()
 {
     $storage = new Fixtures\MockedRootStepStorage();
     $step = new Step();
     $step->setName(self::TEST_STEP_NAME);
     $storage->put($step);
     $this->assertEquals($storage->getLast()->getName(), self::TEST_STEP_NAME);
 }
 private function checkAttachmentIsCorrect(Step $step, $attachmentOutputPath, $attachmentFileName, $attachmentCaption, $attachmentType)
 {
     $this->assertTrue(file_exists($attachmentOutputPath));
     $attachments = $step->getAttachments();
     $this->assertEquals(1, sizeof($attachments));
     $attachment = array_pop($attachments);
     $this->assertInstanceOf('Yandex\\Allure\\Adapter\\Model\\Attachment', $attachment);
     $this->assertEquals($attachmentFileName, $attachment->getSource());
     $this->assertEquals($attachmentCaption, $attachment->getTitle());
     $this->assertEquals($attachmentType, $attachment->getType());
 }
 public function testLifecycle()
 {
     $attachmentTitle = 'some-title';
     $pattern = 'matching';
     $tmpDirectory = sys_get_temp_dir();
     $matchingFilename = tempnam($tmpDirectory, $pattern);
     touch($matchingFilename);
     $this->assertTrue(file_exists($matchingFilename));
     $notMatchingFilename = tempnam($tmpDirectory, 'excluded');
     $step = new Step();
     $step->addAttachment(new Attachment($attachmentTitle, $matchingFilename, ATTACHMENT_TYPE));
     $step->addAttachment(new Attachment($attachmentTitle, $notMatchingFilename, ATTACHMENT_TYPE));
     $this->assertEquals(2, sizeof($step->getAttachments()));
     $event = new RemoveAttachmentsEvent("/{$pattern}/i");
     $event->process($step);
     $this->assertEquals(1, sizeof($step->getAttachments()));
     $this->assertFalse(file_exists($matchingFilename));
     $attachments = $step->getAttachments();
     $attachment = array_pop($attachments);
     $this->assertTrue($attachment instanceof Attachment && $attachment->getSource() === $notMatchingFilename);
 }
 /**
  * @return Step
  */
 protected function getRootStep()
 {
     $step = new Step();
     $step->setName(self::ROOT_STEP_NAME);
     $step->setTitle("If you're seeing this then there's an error in step processing. " . "Please send feedback to allure@yandex-team.ru. Thank you.");
     $step->setStart(self::getTimestamp());
     $step->setStatus(Status::BROKEN);
     return $step;
 }
 protected function getRootStep()
 {
     $rootStep = new Step();
     $rootStep->setName('root-step');
     return $rootStep;
 }