Skip to content

Commit

Permalink
adding test for constructorless testclass
Browse files Browse the repository at this point in the history
  • Loading branch information
Idrinth authored and sebastianbergmann committed Jul 7, 2018
1 parent a5b103e commit 585939e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/Framework/TestResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testAddErrorOfTypeIncompleteTest()
//Stop
$result->stopOnIncomplete(true);
$result->addError($test, $throwable, $time);
$this->assertAttributeEquals(2*$time, 'time', $result);
$this->assertAttributeEquals(2 * $time, 'time', $result);
$this->assertAttributeCount(2, 'notImplemented', $result);
$this->assertAttributeEquals(true, 'stop', $result);
//Final checks
Expand Down
22 changes: 22 additions & 0 deletions tests/Framework/TestSuiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,26 @@ public function testDoNotSkipInheritedClass(): void

$this->assertCount(2, $result);
}

/**
* @expectedException PHPUnit\Framework\Exception
* @expectedExceptionMessage No valid test provided.
*/
public function testCreateTestForConstructorlessTestClass(): void
{
$reflection = $this->getMockBuilder(\ReflectionClass::class)
->setConstructorArgs([$this])
->getMock();

$reflection->expects($this->once())
->method('getConstructor')
->willReturn(null);
$reflection->expects($this->once())
->method('isInstantiable')
->willReturn(true);
$reflection->expects($this->once())
->method('getName')
->willReturn(__CLASS__);
TestSuite::createTest($reflection, 'TestForConstructorlessTestClass');
}
}

0 comments on commit 585939e

Please sign in to comment.