Skip to content

Commit

Permalink
Fix some false mocking inside various tests (#7392)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamazu committed May 3, 2024
1 parent d6d9831 commit 37b0d17
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 18 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -12910,11 +12910,6 @@ parameters:
count: 1
path: src/Sulu/Bundle/MarkupBundle/Tests/Unit/Listener/MarkupListenerTest.php

-
message: "#^Property Symfony\\\\Component\\\\HttpFoundation\\\\Response\\:\\:\\$headers \\(Symfony\\\\Component\\\\HttpFoundation\\\\ResponseHeaderBag\\) does not accept Symfony\\\\Component\\\\HttpFoundation\\\\HeaderBag\\.$#"
count: 1
path: src/Sulu/Bundle/MarkupBundle/Tests/Unit/Listener/MarkupListenerTest.php

-
message: "#^Method Sulu\\\\Bundle\\\\MarkupBundle\\\\Tests\\\\Unit\\\\Markup\\\\HtmlTagExtractorTest\\:\\:provideMultipleTags\\(\\) has no return type specified\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function testLoadGroup(): void
public function testNoFixturesInteraction(): void
{
$helper = $this->prophesize(QuestionHelper::class);
$helper->setHelperSet(Argument::cetera())->willReturn(null);
$helper->setHelperSet(Argument::cetera())->shouldBeCalled();
$helper->getName()->willReturn('question');
$helper->ask(Argument::cetera())->shouldBeCalled()->willReturn(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Sulu\Bundle\DocumentManagerBundle\Routing\Loader\VersionRouteLoader;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Loader\LoaderResolverInterface;
use Symfony\Component\Routing\RouteCollection;

class VersionRouteLoaderTest extends TestCase
{
Expand All @@ -32,11 +33,14 @@ public function testLoadWithActivatedVersioning(): void
{
$versionRouteLoader = new VersionRouteLoader(true);
$resolver = $this->prophesize(LoaderResolverInterface::class);

$routeDefinitons = new RouteCollection();

$loader = $this->prophesize(LoaderInterface::class);
$loader->load('routing.yml', 'rest')->shouldBeCalled();
$loader->load('routing.yml', 'rest')->shouldBeCalled()->willReturn($routeDefinitons);
$resolver->resolve('routing.yml', 'rest')->willReturn($loader->reveal());
$versionRouteLoader->setResolver($resolver->reveal());

$versionRouteLoader->load('routing.yml');
$this->assertEquals($routeDefinitons, $versionRouteLoader->load('routing.yml'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Prophecy\Prophecy\ObjectProphecy;
use Sulu\Bundle\MarkupBundle\Listener\MarkupListener;
use Sulu\Bundle\MarkupBundle\Markup\MarkupParserInterface;
use Symfony\Component\HttpFoundation\HeaderBag;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
Expand All @@ -42,11 +41,6 @@ class MarkupListenerTest extends TestCase
*/
private $response;

/**
* @var ObjectProphecy<HeaderBag>
*/
private $responseHeaders;

/**
* @var ObjectProphecy<Request>
*/
Expand All @@ -71,9 +65,6 @@ protected function setUp(): void
$this->request = $this->prophesize(Request::class);
$this->response = $this->prophesize(Response::class);

$this->responseHeaders = $this->prophesize(HeaderBag::class);
$this->response->reveal()->headers = $this->responseHeaders->reveal();

$this->event = new ResponseEvent(
$this->kernel->reveal(),
$this->request->reveal(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function setUp(): void
$router = $this->prophesize(RouterInterface::class);
$session = $this->prophesize(Session::class);
$session->get('_security.admin.target_path')->willReturn('/admin/#target/path');
$session->set(Security::AUTHENTICATION_ERROR, $this->exception->reveal())->willReturn(null);
$session->set(Security::AUTHENTICATION_ERROR, $this->exception->reveal())->will(function() {});
$this->request->getSession()
->willReturn($session->reveal());
$router->generate('sulu_admin')->willReturn('/admin');
Expand Down

0 comments on commit 37b0d17

Please sign in to comment.