Skip to content

Commit fa4edc7

Browse files
committed
Merge pull request #43 from brianjmiller/issue34-tests
Add unit tests around 0 raw score
2 parents ea572af + b10eb6a commit fa4edc7

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

tests/ResultTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,20 @@ public function testAsVersion() {
7575
$this->assertEquals($versioned, $args, "success only: 1.0.0");
7676
}
7777

78+
// reported https://github.com/RusticiSoftware/TinCanPHP/issues/34
79+
public function testAsVersionScoreZeroRaw() {
80+
$args = [
81+
'score' => [
82+
'raw' => 0,
83+
]
84+
];
85+
86+
$obj = Result::fromJSON(json_encode($args, JSON_UNESCAPED_SLASHES));
87+
$versioned = $obj->asVersion('1.0.0');
88+
89+
$this->assertEquals($versioned, $args, "serialized version matches original");
90+
}
91+
7892
public function testCompareWithSignature() {
7993
$score1 = new TinCan\Score(
8094
[

tests/ScoreTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,14 @@ public function testCompareWithSignature() {
216216
];
217217
$this->runSignatureCases("TinCan\Score", $cases);
218218
}
219+
220+
public function testZeroValue() {
221+
$args = [
222+
'raw' => 0
223+
];
224+
$obj = new Score($args);
225+
$versioned = $obj->asVersion('1.0.0');
226+
227+
$this->assertEquals($versioned, $args, "raw with 0 as value");
228+
}
219229
}

0 commit comments

Comments
 (0)