7
7
8
8
use Laminas \Stdlib \Parameters ;
9
9
use Magento \Backend \Block \Template \Context ;
10
+ use Magento \Framework \App \Filesystem \DirectoryList ;
10
11
use Magento \Framework \Data \Collection ;
12
+ use Magento \Framework \Filesystem ;
11
13
use Magento \Framework \View \LayoutInterface ;
12
14
use Magento \TestFramework \Helper \Bootstrap ;
13
15
use PHPUnit \Framework \TestCase ;
@@ -34,7 +36,7 @@ protected function setUp(): void
34
36
{
35
37
parent ::setUp ();
36
38
37
- $ this ->_layoutMock = Bootstrap::getObjectManager ()->get (
39
+ $ this ->_layoutMock = Bootstrap::getObjectManager ()->create (
38
40
LayoutInterface::class
39
41
);
40
42
$ context = Bootstrap::getObjectManager ()->create (
@@ -122,4 +124,21 @@ public function testExtendedTemplateMarkup(): void
122
124
$ html = str_replace (["\n" , " " ], '' , $ html );
123
125
$ this ->assertStringEndsWith ("</table></div> " , $ html );
124
126
}
127
+
128
+ public function testGetCsvFileStartsWithBOM (): void
129
+ {
130
+ $ collection = Bootstrap::getObjectManager ()->create (Collection::class);
131
+ $ this ->_block ->setCollection ($ collection );
132
+ $ data = $ this ->_block ->getCsvFile ();
133
+
134
+ $ filesystem = Bootstrap::getObjectManager ()->get (Filesystem::class);
135
+ $ directory = $ filesystem ->getDirectoryWrite (DirectoryList::VAR_DIR );
136
+ self ::assertTrue ($ directory ->isFile ($ data ['value ' ]));
137
+ self ::assertStringStartsWith (
138
+ pack ('CCC ' , 0xef , 0xbb , 0xbf ),
139
+ $ directory ->readFile ($ data ['value ' ])
140
+ );
141
+
142
+ $ directory ->delete ($ data ['value ' ]);
143
+ }
125
144
}
0 commit comments