Completed
Pull Request — master (#53)
by Jeroen De
06:28 queued 03:58
created

DonationTest::testCancelModifiesData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace WMDE\Fundraising\Store\Tests;
4
5
use WMDE\Fundraising\Entities\Donation;
6
7
/**
8
 * @covers WMDE\Fundraising\Entities\Donation
9
 *
10
 * @licence GNU GPL v2+
11
 * @author Jeroen De Dauw < [email protected] >
12
 */
13
class DonationTest extends \PHPUnit_Framework_TestCase {
14
15
	public function testCancelSetsDeletionDateAndStatus() {
16
		$donation = new Donation();
17
18
		$donation->cancel();
19
20
		$this->assertSame( 'D', $donation->getStatus() );
21
		$this->assertInternalType( 'string', $donation->getDtDel() );
22
	}
23
24
	public function testCancelModifiesData() {
25
		$donation = new Donation();
26
27
		$donation->encodeAndSetData( [
28
			'nyan' => 'cat'
29
		] );
30
31
		$donation->cancel();
32
		$data = $donation->getDecodedData();
33
34
		$this->assertSame( 'cat', $data['nyan'] );
35
		$this->assertSame( 'D', $data['status'] );
36
		$this->assertInternalType( 'string', $data['dt_del'] );
37
		$this->assertSame( '', $data['utoken'] );
38
	}
39
40
	public function testDataEncodingAndDecodingRoundtrips() {
41
		$donation = new Donation();
42
43
		$someData = [
44
			'nyan' => 'cat',
45
			'foo' => null,
46
			'bar' => 9000.01,
47
			'baz' => [ true ]
48
		];
49
50
		$donation->encodeAndSetData( $someData );
51
52
		$this->assertSame( $someData, $donation->getDecodedData() );
53
	}
54
55
}
56