forked from DataValues/Common
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonolingualTextValueTest.php
More file actions
95 lines (82 loc) · 2.04 KB
/
MonolingualTextValueTest.php
File metadata and controls
95 lines (82 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace DataValues\Tests;
use DataValues\MonolingualTextValue;
/**
* @covers DataValues\MonolingualTextValue
*
* @since 0.1
*
* @group DataValue
* @group DataValueExtensions
*
* @license GPL-2.0+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
class MonolingualTextValueTest extends DataValueTest {
/**
* @see DataValueTest::getClass
*
* @return string
*/
public function getClass() {
return 'DataValues\MonolingualTextValue';
}
public function validConstructorArgumentsProvider() {
return [
[ 'en', 'foo' ],
[ 'en', ' foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz foo bar baz ' ],
];
}
public function invalidConstructorArgumentsProvider() {
return [
[ 42, null ],
[ [], null ],
[ false, null ],
[ true, null ],
[ null, null ],
[ 'en', 42 ],
[ 'en', false ],
[ 'en', [] ],
[ 'en', null ],
[ '', 'foo' ],
];
}
public function testNewFromArray() {
$array = [ 'text' => 'foo', 'language' => 'en' ];
$value = MonolingualTextValue::newFromArray( $array );
$this->assertSame( $array, $value->getArrayValue() );
}
/**
* @dataProvider invalidArrayProvider
*/
public function testNewFromArrayWithInvalidArray( array $array ) {
$this->setExpectedException( 'DataValues\IllegalValueException' );
MonolingualTextValue::newFromArray( $array );
}
public function invalidArrayProvider() {
return [
[ [] ],
[ [ null ] ],
[ [ '' ] ],
[ [ 'en', 'foo' ] ],
[ [ 'language' => 'en' ] ],
[ [ 'text' => 'foo' ] ],
];
}
public function testGetSortKey() {
$value = new MonolingualTextValue( 'en', 'foo' );
$this->assertSame( 'enfoo', $value->getSortKey() );
}
/**
* @dataProvider instanceProvider
*/
public function testGetText( MonolingualTextValue $text, array $arguments ) {
$this->assertEquals( $arguments[1], $text->getText() );
}
/**
* @dataProvider instanceProvider
*/
public function testGetLanguageCode( MonolingualTextValue $text, array $arguments ) {
$this->assertEquals( $arguments[0], $text->getLanguageCode() );
}
}