7
7
8
8
use Magento \FunctionalTestingFramework \Allure \AllureHelper ;
9
9
use Magento \FunctionalTestingFramework \Allure \Event \AddUniqueAttachmentEvent ;
10
+ use PHPUnit \Framework \TestCase ;
10
11
use Yandex \Allure \Adapter \Allure ;
11
- use Yandex \Allure \Adapter \Event \ AddAttachmentEvent ;
12
+ use Yandex \Allure \Adapter \AllureException ;
12
13
use Yandex \Allure \Adapter \Event \StepFinishedEvent ;
13
14
use Yandex \Allure \Adapter \Event \StepStartedEvent ;
14
15
use Yandex \Allure \Adapter \Model \Attachment ;
15
- use PHPUnit \Framework \TestCase ;
16
16
17
17
class AllureHelperTest extends TestCase
18
18
{
@@ -27,8 +27,8 @@ public function tearDown(): void
27
27
}
28
28
29
29
/**
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
32
32
*/
33
33
public function testAddAttachmentToStep ()
34
34
{
@@ -50,7 +50,7 @@ public function testAddAttachmentToStep()
50
50
51
51
/**
52
52
* AddAttachmentToLastStep should add an attachment only to the last step
53
- * @throws \Yandex\Allure\Adapter\ AllureException
53
+ * @throws AllureException
54
54
*/
55
55
public function testAddAttachmentToLastStep ()
56
56
{
@@ -86,14 +86,15 @@ public function testAddAttachmentToLastStep()
86
86
87
87
/**
88
88
* AddAttachment actions should have files with different attachment names
89
- * @throws \Yandex\Allure\Adapter\ AllureException
89
+ * @throws AllureException
90
90
*/
91
91
public function testAddAttachementUniqueName ()
92
92
{
93
- $ this ->mockCopyFile ();
94
93
$ expectedData = "string " ;
95
94
$ expectedCaption = "caption " ;
96
95
96
+ $ this ->mockCopyFile ($ expectedData , $ expectedCaption );
97
+
97
98
//Prepare Allure lifecycle
98
99
Allure::lifecycle ()->fire (new StepStartedEvent ('firstStep ' ));
99
100
@@ -110,7 +111,6 @@ public function testAddAttachementUniqueName()
110
111
111
112
/**
112
113
* Mock entire attachment writing mechanisms
113
- * @throws \Exception
114
114
*/
115
115
public function mockAttachmentWriteEvent ()
116
116
{
@@ -122,13 +122,15 @@ public function mockAttachmentWriteEvent()
122
122
123
123
/**
124
124
* Mock only file writing mechanism
125
- * @throws \Exception
125
+ * @throws \ReflectionException
126
126
*/
127
- public function mockCopyFile ()
127
+ public function mockCopyFile (string $ expectedData , string $ expectedCaption )
128
128
{
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 );
133
135
}
134
136
}
0 commit comments