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); }