Passed
Push — master ( 0b20e6...3a20e7 )
by Aimeos
05:22 queued 55s
created

StandardTest::setUpBeforeClass()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
rs 10
cc 2
nc 2
nop 0
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