|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017-2023 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Media\Application; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class StandardTest extends \PHPUnit\Framework\TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
public static function setUpBeforeClass() : void |
|
15
|
|
|
{ |
|
16
|
|
|
$dir = dirname( dirname( dirname( __DIR__ ) ) ) . '/tmp'; |
|
17
|
|
|
|
|
18
|
|
|
if( !is_dir( $dir ) ) { |
|
19
|
|
|
mkdir( $dir, 0755, true ); |
|
20
|
|
|
} |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
public function testConstruct() |
|
25
|
|
|
{ |
|
26
|
|
|
$ds = DIRECTORY_SEPARATOR; |
|
27
|
|
|
$content = file_get_contents( dirname( __DIR__ ) . $ds . '_testfiles' . $ds . 'application.txt' ); |
|
28
|
|
|
|
|
29
|
|
|
$media = new \Aimeos\MW\Media\Application\Standard( $content, 'application/octet-stream', [] ); |
|
30
|
|
|
|
|
31
|
|
|
$this->assertEquals( 'application/octet-stream', $media->getMimetype() ); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
public function testSave() |
|
36
|
|
|
{ |
|
37
|
|
|
$ds = DIRECTORY_SEPARATOR; |
|
38
|
|
|
$content = file_get_contents( dirname( __DIR__ ) . $ds . '_testfiles' . $ds . 'application.txt' ); |
|
39
|
|
|
|
|
40
|
|
|
$media = new \Aimeos\MW\Media\Application\Standard( $content, 'application/octet-stream', [] ); |
|
41
|
|
|
|
|
42
|
|
|
$this->assertEquals( 'some text', $media->save() ); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
public function testSaveFile() |
|
47
|
|
|
{ |
|
48
|
|
|
$ds = DIRECTORY_SEPARATOR; |
|
49
|
|
|
$content = file_get_contents( dirname( __DIR__ ) . $ds . '_testfiles' . $ds . 'application.txt' ); |
|
50
|
|
|
$dest = dirname( dirname( dirname( __DIR__ ) ) ) . $ds . 'tmp' . $ds . 'application.txt'; |
|
51
|
|
|
|
|
52
|
|
|
$media = new \Aimeos\MW\Media\Application\Standard( $content, 'application/octet-stream', [] ); |
|
53
|
|
|
$media->save( $dest ); |
|
54
|
|
|
|
|
55
|
|
|
$this->assertEquals( true, file_exists( $dest ) ); |
|
56
|
|
|
unlink( $dest ); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|