summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/SQLStore/ChangeOp/FieldChangeOpTest.php
blob: 690084c8007ebfda788d0f5b21d917d177e38760 (plain)
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
<?php

namespace SMW\Tests\SQLStore\ChangeOp;

use SMW\SQLStore\ChangeOp\FieldChangeOp;
use SMW\Tests\PHPUnitCompat;

/**
 * @covers \SMW\SQLStore\ChangeOp\FieldChangeOp
 * @group semantic-mediawiki
 *
 * @license GNU GPL v2+
 * @since 2.4
 *
 * @author mwjames
 */
class FieldChangeOpTest extends \PHPUnit_Framework_TestCase {

	use PHPUnitCompat;

	public function testCanConstruct() {

		$this->assertInstanceOf(
			FieldChangeOp::class,
			new FieldChangeOp()
		);
	}

	public function testChangeOp() {

		$op = [
			's_id' => 462,
			'o_serialized' => '1/2016/6/10/2/3/31/0',
			'o_sortkey' => '2457549.5857755',
		];

		$instance = new FieldChangeOp(
			$op
		);

		$this->assertFalse(
			$instance->has( 'foo' )
		);

		$this->assertSame(
			'1/2016/6/10/2/3/31/0',
			$instance->get( 'o_serialized' )
		);

		$instance->set( 'foo', 'bar' );

		$this->assertSame(
			'bar',
			$instance->get( 'foo' )
		);
	}

	public function testInvalidGetRequestThrowsException() {

		$instance = new FieldChangeOp();

		$this->setExpectedException( 'InvalidArgumentException' );
		$instance->get( 'o_serialized' );
	}

}