Completed
Push — master ( dd8aad...6526e1 )
by mw
04:06
created

testNewTimeValueForOutOfRangeTimestamp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4286
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace SEQL\Tests;
4
5
use SEQL\DataValueDeserializer;
6
use SMW\DIWikiPage;
7
use SMW\DIProperty;
8
use SMWDITime as DITime;
9
10
/**
11
 * @covers \SEQL\DataValueDeserializer
12
 * @group semantic-external-query-lookup
13
 *
14
 * @license GNU GPL v2+
15
 * @since 1.0
16
 *
17
 * @author mwjames
18
 */
19
class DataValueDeserializerTest extends \PHPUnit_Framework_TestCase {
20
21
	public function testCanConstruct() {
22
23
		$this->assertInstanceOf(
24
			'\SEQL\DataValueDeserializer',
25
			new DataValueDeserializer( 'foo' )
26
		);
27
	}
28
29
	public function testNewDiWikiPage() {
30
31
		$instance = new DataValueDeserializer( 'foo' );
32
33
		$value = array(
34
			'namespace' => NS_MAIN,
35
			'fulltext'  => 'abc def'
36
		);
37
38
		$this->assertEquals(
39
			new DIWikiPage( 'Foo:abc_def', NS_MAIN ),
40
			$instance->newDiWikiPage( $value )
41
		);
42
	}
43
44
	public function testNewTimeValueForOutOfRangeTimestamp() {
45
46
		$instance = new DataValueDeserializer( 'foo' );
47
48
		$property = new DIProperty( 'Bar' );
49
		$property->setPropertyTypeId( '_dat' );
50
51
		$this->assertNotEquals(
52
			DITime::doUnserialize( '2/-200' ),
53
			$instance->newDataValueFrom( $property, '-2000101000000' )
54
		);
55
	}
56
57
	public function testNewTimeValueForRawTimeFromat() {
58
59
		$instance = new DataValueDeserializer( 'foo' );
60
61
		$property = new DIProperty( 'Bar' );
62
		$property->setPropertyTypeId( '_dat' );
63
64
		$this->assertEquals(
65
			DITime::doUnserialize( '2/-200' ),
66
			$instance->newDataValueFrom( $property, array( 'raw' => '2/-200' ) )->getDataItem()
67
		);
68
	}
69
70
}
71