Skip to content

Commit dee081d

Browse files
author
silinmykola
committed
33294 change copyFile test
1 parent e365390 commit dee081d

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Allure/AllureHelperTest.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
use Magento\FunctionalTestingFramework\Allure\AllureHelper;
99
use Magento\FunctionalTestingFramework\Allure\Event\AddUniqueAttachmentEvent;
10+
use PHPUnit\Framework\TestCase;
1011
use Yandex\Allure\Adapter\Allure;
11-
use Yandex\Allure\Adapter\Event\AddAttachmentEvent;
12+
use Yandex\Allure\Adapter\AllureException;
1213
use Yandex\Allure\Adapter\Event\StepFinishedEvent;
1314
use Yandex\Allure\Adapter\Event\StepStartedEvent;
1415
use Yandex\Allure\Adapter\Model\Attachment;
15-
use PHPUnit\Framework\TestCase;
1616

1717
class AllureHelperTest extends TestCase
1818
{
@@ -27,8 +27,8 @@ public function tearDown(): void
2727
}
2828

2929
/**
30-
* AddAtachmentToStep should add an attachment to the current step
31-
* @throws \Yandex\Allure\Adapter\AllureException
30+
* AddAttachmentToStep should add an attachment to the current step
31+
* @throws AllureException
3232
*/
3333
public function testAddAttachmentToStep()
3434
{
@@ -50,7 +50,7 @@ public function testAddAttachmentToStep()
5050

5151
/**
5252
* AddAttachmentToLastStep should add an attachment only to the last step
53-
* @throws \Yandex\Allure\Adapter\AllureException
53+
* @throws AllureException
5454
*/
5555
public function testAddAttachmentToLastStep()
5656
{
@@ -86,14 +86,15 @@ public function testAddAttachmentToLastStep()
8686

8787
/**
8888
* AddAttachment actions should have files with different attachment names
89-
* @throws \Yandex\Allure\Adapter\AllureException
89+
* @throws AllureException
9090
*/
9191
public function testAddAttachementUniqueName()
9292
{
93-
$this->mockCopyFile();
9493
$expectedData = "string";
9594
$expectedCaption = "caption";
9695

96+
$this->mockCopyFile($expectedData, $expectedCaption);
97+
9798
//Prepare Allure lifecycle
9899
Allure::lifecycle()->fire(new StepStartedEvent('firstStep'));
99100

@@ -110,7 +111,6 @@ public function testAddAttachementUniqueName()
110111

111112
/**
112113
* Mock entire attachment writing mechanisms
113-
* @throws \Exception
114114
*/
115115
public function mockAttachmentWriteEvent()
116116
{
@@ -122,13 +122,15 @@ public function mockAttachmentWriteEvent()
122122

123123
/**
124124
* Mock only file writing mechanism
125-
* @throws \Exception
125+
* @throws \ReflectionException
126126
*/
127-
public function mockCopyFile()
127+
public function mockCopyFile(string $expectedData, string $expectedCaption)
128128
{
129-
$this->createMock(AddUniqueAttachmentEvent::class)
130-
->expects($this->any())
131-
->method('copyFile')
132-
->willReturn(true);
129+
$addUniqueAttachmentEvent = new AddUniqueAttachmentEvent($expectedData, $expectedCaption);
130+
$reflection = new \ReflectionClass(AddUniqueAttachmentEvent::class);
131+
$reflectionMethod = $reflection->getMethod('copyFile');
132+
$reflectionMethod->setAccessible(true);
133+
$output = $reflectionMethod->invoke($addUniqueAttachmentEvent);
134+
$this->assertEquals(true, $output);
133135
}
134136
}

0 commit comments

Comments
 (0)