Skip to content

Commit 0b8400c

Browse files
committed
Merge pull request #133 from brianium/feature/result-accessors
include accessors to test result counts
2 parents 9678cb1 + 486b21d commit 0b8400c

File tree

2 files changed

+63
-6
lines changed

2 files changed

+63
-6
lines changed

specs/test-result.spec.php

+20-6
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,27 @@
134134
});
135135
});
136136

137-
describe("->getPendingCount()", function() {
138-
it("should return the pending count tracked by the result", function() {
137+
describe('pending test accessors', function () {
138+
it('should allow access to the total number of pending tests', function () {
139139
$result = new TestResult($this->eventEmitter);
140-
$pending = new Test("pending");
141-
$result->pendTest($pending);
142-
$count = $result->getPendingCount();
143-
assert($count == 1, "pending count should be 1");
140+
$result->setPendingCount(1);
141+
assert($result->getPendingCount() === 1, 'should have returned pending count');
142+
});
143+
});
144+
145+
describe('failure accessors', function () {
146+
it('should allow access to the total number of failures', function () {
147+
$result = new TestResult($this->eventEmitter);
148+
$result->setFailureCount(1);
149+
assert($result->getFailureCount() === 1, 'should have returned failure count');
150+
});
151+
});
152+
153+
describe('test count accessors', function () {
154+
it('should allow access to the total number of tests', function () {
155+
$result = new TestResult($this->eventEmitter);
156+
$result->setTestCount(1);
157+
assert($result->getTestCount() === 1, 'should have returned test count');
144158
});
145159
});
146160
});

src/Core/TestResult.php

+43
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public function endTest(TestInterface $test)
113113
}
114114

115115
/**
116+
* Get the number of failures tracked by this result.
117+
*
116118
* @return int
117119
*/
118120
public function getFailureCount()
@@ -121,6 +123,20 @@ public function getFailureCount()
121123
}
122124

123125
/**
126+
* Set the number of failures tracked by this result.
127+
*
128+
* @param int $failureCount
129+
*/
130+
public function setFailureCount($failureCount)
131+
{
132+
$this->failureCount = $failureCount;
133+
return $this;
134+
}
135+
136+
/**
137+
* Get the number of tests tracked by this
138+
* result.
139+
*
124140
* @return int
125141
*/
126142
public function getTestCount()
@@ -129,10 +145,37 @@ public function getTestCount()
129145
}
130146

131147
/**
148+
* Set the number of tests tracked by this
149+
* result.
150+
*
151+
* @param int $testCount
152+
*/
153+
public function setTestCount($testCount)
154+
{
155+
$this->testCount = $testCount;
156+
return $this;
157+
}
158+
159+
/**
160+
* Get the number of pending tests tracked
161+
* by this test result.
162+
*
132163
* @return int
133164
*/
134165
public function getPendingCount()
135166
{
136167
return $this->pendingCount;
137168
}
169+
170+
/**
171+
* Set the number of pending tests tracked
172+
* by this test result.
173+
*
174+
* @param int $pendingCount
175+
*/
176+
public function setPendingCount($pendingCount)
177+
{
178+
$this->pendingCount = $pendingCount;
179+
return $this;
180+
}
138181
}

0 commit comments

Comments
 (0)