diff --git a/tests/Violation/Class_/BlobTest.php b/tests/Violation/Class_/BlobTest.php index 5424ec42..be8da94c 100644 --- a/tests/Violation/Class_/BlobTest.php +++ b/tests/Violation/Class_/BlobTest.php @@ -1,4 +1,5 @@ prophesize('Hal\Metric\ClassMetric'); - $prophet->get('nbMethodsPublic')->willReturn($nbMethodsPublic); - $prophet->get('lcom')->willReturn($lcom); - $prophet->get('externals')->willReturn(array_pad([], $nbExternals, '')); - $prophet->get('violations')->willReturn(new Violations()); - $class = $prophet->reveal(); + $class = $this->getMockBuilder(ClassMetric::class)->disableOriginalConstructor()->getMock(); + + $violations = new Violations(); + $class->method('get')->willReturnCallback(function ($param) use ( + $violations, + $nbMethodsPublic, + $lcom, + $nbExternals + ) { + switch ($param) { + case 'nbMethodsPublic': + return $nbMethodsPublic; + case 'lcom': + return $lcom; + case 'externals': + return array_pad([], $nbExternals, ''); + case 'violations': + return $violations; + } + }); $object = new Blob(); $object->apply($class); diff --git a/tests/Violation/Package/StableDependenciesPrincipleTest.php b/tests/Violation/Package/StableDependenciesPrincipleTest.php index 017d45fd..4eb870f4 100644 --- a/tests/Violation/Package/StableDependenciesPrincipleTest.php +++ b/tests/Violation/Package/StableDependenciesPrincipleTest.php @@ -15,13 +15,11 @@ class StableDependenciesPrincipleTest extends TestCase { public function testItIgnoresNonPackageMetrics() { - $metric = $this->prophesize(Metric::class); - + $metric = $this->getMockBuilder(Metric::class)->getMock(); + $metric->expects($this->never())->method('get'); $object = new StableDependenciesPrinciple(); - $object->apply($metric->reveal()); - - $metric->get('violations')->shouldNotHaveBeenCalled(); + $object->apply($metric); } /** @@ -36,14 +34,14 @@ public function testItAddsViolationsIfOneDependentPackageIsMoreUnstableOrAsUnsta $expectedViolationCount ) { $violations = new Violations(); - $metric = $this->prophesize(PackageMetric::class); - $metric->getInstability()->willReturn($packageInstability); - $metric->getDependentInstabilities()->willReturn($dependentInstabilities); - $metric->get('violations')->willReturn($violations); + $metric = $this->getMockBuilder(PackageMetric::class)->disableOriginalConstructor()->getMock(); + $metric->method('getInstability')->willReturn($packageInstability); + $metric->method('getDependentInstabilities')->willReturn($dependentInstabilities); + $metric->method('get')->willReturn($violations); $object = new StableDependenciesPrinciple(); - $object->apply($metric->reveal()); + $object->apply($metric); $this->assertSame($expectedViolationCount, $violations->count()); }