Skip to content

It does not like Mockery nor Prophecy #134

@jeroenvdgulik

Description

@jeroenvdgulik

It seems that the static analyser doesn't like Mocking tools.

<?php

namespace Example;

class Book {
	private $price;
	
	public function assignPrice(int $price)
	{
		$this->price = $price;
	}
}
<?php

namespace Example;

class BookTest {

	function it_should_mock_a_book()
	{
		$mockBook = \Mockery::mock(Book::class);

		$mockBook->shouldReceive('assignPrice')
				->with(100)
				->andReturn(NULL);		
	}

}

➜ mockery vendor/bin/phpstan analyse -l 5 src
2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


Line src/Example/BookTest.php


11 Method Mockery\MockInterface::shouldReceive() invoked with 1 parameter, 0 required.


[ERROR] Found 1 error

<?php

namespace Example;

use PHPUnit\Framework\TestCase;
use Prophecy\Prophecy\ObjectProphecy;

class BookTest extends TestCase {

	function it_should_mock_a_book()
	{
		/** @var ObjectProphecy|Book */
		$mockBook = $this->prophesize(Book::class);

		$mockBook->assignPrice(100)->willReturn(null);
	}

}

➜ mockery vendor/bin/phpstan analyse -l 5 src
2/2 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%


Line src/Example/BookTest.php


15 Call to an undefined method Prophecy\Prophecy\ObjectProphecy::assignPrice().


[ERROR] Found 1 error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions