Completed
Push — master ( 9b0aba...0a2150 )
by Aimeos
15:35
created

StandardTest::testSave()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 9
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
rs 9.6666
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2017
6
 */
7
8
9
namespace Aimeos\MW\Media\Application;
10
11
12
class StandardTest extends \PHPUnit_Framework_TestCase
13
{
14
	public function testConstruct()
15
	{
16
		$ds = DIRECTORY_SEPARATOR;
17
		$content = file_get_contents( dirname( __DIR__ ) . $ds . '_testfiles' . $ds . 'application.txt' );
18
19
		$media = new \Aimeos\MW\Media\Application\Standard( $content, 'application/octet-stream', array() );
20
21
		$this->assertEquals( 'application/octet-stream', $media->getMimetype() );
22
	}
23
24
25
	public function testSave()
26
	{
27
		$ds = DIRECTORY_SEPARATOR;
28
		$content = file_get_contents( dirname( __DIR__ ) . $ds . '_testfiles' . $ds . 'application.txt' );
29
30
		$media = new \Aimeos\MW\Media\Application\Standard( $content, 'application/octet-stream', array() );
31
32
		$this->assertEquals( 'some text', $media->save() );
33
	}
34
35
36
	public function testSaveFile()
37
	{
38
		$ds = DIRECTORY_SEPARATOR;
39
		$content = file_get_contents( dirname( __DIR__ ) . $ds . '_testfiles' . $ds . 'application.txt' );
40
		$dest = dirname( dirname( dirname( __DIR__ ) ) ) . $ds . 'tmp' . $ds . 'application.txt';
41
42
		$media = new \Aimeos\MW\Media\Application\Standard( $content, 'application/octet-stream', array() );
43
		$media->save( $dest );
44
45
		$this->assertEquals( true, file_exists( $dest ) );
46
		unlink( $dest );
47
	}
48
}
49