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

StandardTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 37
c 1
b 0
f 0
rs 10
wmc 3
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstruct() 0 9 1
A testSave() 0 9 1
A testSaveFile() 0 12 1
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