-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPRSStatementUploadTest.php
51 lines (45 loc) · 1.47 KB
/
PRSStatementUploadTest.php
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
<?php
namespace Trackshift\Test\Upload;
use Trackshift\Upload\PRSStatementUpload;
class PRSStatementUploadTest extends UploadTestCase {
public function testGetUsageTotal():void {
$fileContent = <<<DATA
Record Number,Work Title,Amount (performance revenue)
1,Song 1,0.0016
2,Song 1,0.0016
3,Song 1,0.0072
4,Song 2,0.0036
5,Song 2,0.0048
6,Song 3,0.0081
7,Song 3,0.0005
8,Song 3,0.0006
9,Song 3,0.0002
DATA;
$tmpFileName = self::getTempFile($fileContent);
$sut = new PRSStatementUpload($tmpFileName);
$moneyTotalUsage = $sut->getUsageTotal();
self::assertSame(0.0282, $moneyTotalUsage->value);
self::assertSame("£0.02", (string)$moneyTotalUsage);
}
public function testGetAggregatedUsageTotals():void {
$fileContent = <<<DATA
Record Number,Work Title,Amount (performance revenue)
1,Song 1,0.0016
2,Song 1,0.0016
3,Song 1,0.0072
4,Song 2,0.0036
5,Song 2,0.0048
6,Song 3,0.0081
7,Song 3,0.0005
8,Song 3,0.0006
9,Song 3,0.0002
DATA;
$tmpFileName = self::getTempFile($fileContent);
$sut = new PRSStatementUpload($tmpFileName);
$aggregatedTotalUsage = $sut->getAggregatedUsageTotal("Work Title");
self::assertSame(0.0104, $aggregatedTotalUsage->getTotalForAggregate("Song 1")->value);
self::assertSame(0.0084, $aggregatedTotalUsage->getTotalForAggregate("Song 2")->value);
self::assertSame(0.0094, $aggregatedTotalUsage->getTotalForAggregate("Song 3")->value);
self::assertSame(0.0282, $aggregatedTotalUsage->getTotal()->value);
}
}