1212namespace bitExpert \Phing \SecurityChecker ;
1313
1414use PHPUnit \Framework \TestCase ;
15- use SensioLabs \Security \Crawler \ CrawlerInterface ;
15+ use SensioLabs \Security \Crawler ;
1616use SensioLabs \Security \SecurityChecker ;
1717
1818/**
2323class SecurityCheckerTaskUnitTest extends TestCase
2424{
2525 /**
26- * @var CrawlerInterface |TestCase
26+ * @var Crawler |TestCase
2727 */
2828 private $ crawler ;
2929 /**
@@ -92,8 +92,9 @@ public function endPointParameterShouldBePassedToSecurityCheckerWhenGiven()
9292
9393 /**
9494 * @test
95+ * @expectedException \BuildException
9596 */
96- public function advisoriesIncludingLinkWillCallLogMethodFiveTimes ()
97+ public function advisoriesIncludingLinkWillCallLogMethodFiveTimesAndThrowBuildException ()
9798 {
9899 $ vulnerabilities = [
99100 'my/dependency ' => [
@@ -119,8 +120,9 @@ public function advisoriesIncludingLinkWillCallLogMethodFiveTimes()
119120
120121 /**
121122 * @test
123+ * @expectedException \BuildException
122124 */
123- public function advisoriesWithEmptyLinkWillCallLogMethodFourTimes ()
125+ public function advisoriesWithEmptyLinkWillCallLogMethodFourTimesAndThrowBuildException ()
124126 {
125127 $ vulnerabilities = [
126128 'my/dependency ' => [
@@ -144,20 +146,6 @@ public function advisoriesWithEmptyLinkWillCallLogMethodFourTimes()
144146 $ this ->checkerTask ->main ();
145147 }
146148
147- /**
148- * @test
149- * @expectedException \BuildException
150- */
151- public function throwsBuildExceptionWhenVulnerabilitiesFound ()
152- {
153- $ this ->checker ->expects ($ this ->once ())
154- ->method ('getLastVulnerabilityCount ' )
155- ->will ($ this ->returnValue (1 ));
156-
157- $ this ->checkerTask ->setLockfile (__FILE__ );
158- $ this ->checkerTask ->main ();
159- }
160-
161149 /**
162150 * Helper method to create all required mock objects and configure the {@link \SensioLabs\Security\SecurityChecker}
163151 * instance to return the given $vulnerabilities.
@@ -166,14 +154,14 @@ public function throwsBuildExceptionWhenVulnerabilitiesFound()
166154 */
167155 protected function createMockObjects (array $ vulnerabilities = [])
168156 {
169- $ this ->crawler = $ this ->createMock (CrawlerInterface ::class);
157+ $ this ->crawler = $ this ->createMock (Crawler ::class);
170158 $ this ->checker = $ this ->createMock (SecurityChecker::class);
171159 $ this ->checker ->expects ($ this ->any ())
172160 ->method ('check ' )
173- ->will ( $ this -> returnValue ( $ vulnerabilities) );
161+ ->willReturn ( $ vulnerabilities );
174162 $ this ->checker ->expects ($ this ->any ())
175163 ->method ('getCrawler ' )
176- ->will ($ this ->returnValue ( $ this -> crawler ) );
164+ ->willReturn ($ this ->crawler );
177165
178166 $ this ->checkerTask = $ this ->createPartialMock (
179167 SecurityCheckerTask::class,
@@ -184,7 +172,7 @@ protected function createMockObjects(array $vulnerabilities = [])
184172 );
185173 $ this ->checkerTask ->expects ($ this ->any ())
186174 ->method ('getSecurityChecker ' )
187- ->will ($ this ->returnValue ( $ this -> checker ) );
175+ ->willReturn ($ this ->checker );
188176 $ this ->checkerTask ->setProject (new \Project ());
189177 }
190178}
0 commit comments