diff --git a/core/modules/rest/tests/src/Unit/RestViewsStyleSerializerTest.php b/core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php similarity index 72% rename from core/modules/rest/tests/src/Unit/RestViewsStyleSerializerTest.php rename to core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php index 2acc68e..468ee59 100644 --- a/core/modules/rest/tests/src/Unit/RestViewsStyleSerializerTest.php +++ b/core/modules/rest/tests/src/Unit/Plugin/views/style/SerializerTest.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\Tests\rest\Unit\RestViewsStyleSerializerTest. + * Contains \Drupal\Tests\rest\Unit\Plugin\views\style\SerializerTest. */ namespace Drupal\Tests\rest\Unit; @@ -10,19 +10,19 @@ use Drupal\rest\Plugin\views\display\RestExport; use Drupal\rest\Plugin\views\style\Serializer; use Drupal\Tests\UnitTestCase; -use Drupal\views\Entity\View; +use Drupal\views\ViewExecutable; use Symfony\Component\Serializer\SerializerInterface; /** * @coversDefaultClass \Drupal\rest\Plugin\views\style\Serializer * @group rest */ -class RestViewsStyleSerializerTest extends UnitTestCase { +class SerializerTest extends UnitTestCase { /** * The View instance. * - * @var \Drupal\views\Entity\View|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\views\ViewExecutable|\PHPUnit_Framework_MockObject_MockObject */ protected $view; @@ -40,10 +40,10 @@ protected function setUp() { parent::setUp(); - $this->view = $this->getMock(View::class, array('initHandlers'), array( - array('id' => 'test_view'), - 'view', - )); + $this->view = $this->getMockBuilder(ViewExecutable::class) + ->disableOriginalConstructor() + ->getMock(); + // Make the view result empty so we don't have to mock the row plugin render // call. $this->view->result = []; @@ -65,18 +65,13 @@ protected function setUp() { public function testSerializerReceivesOptions() { $options = ['formats' => ['xml', 'json']]; - $mock_serializer = $this->getMockBuilder(SerializerInterface::class) - ->disableOriginalConstructor() - ->getMock(); + $mock_serializer = $this->prophesize(SerializerInterface::class); // This is the main expectation of the test. We want to make sure the // serializer options are passed to the SerializerInterface object. - $mock_serializer->expects($this->once()) - ->method('serialize') - ->with([], 'json', ['views_style_options' => $options]) - ->willReturn(''); + $mock_serializer->serialize([], 'json', ['views_style_options' => $options])->willReturn('')->shouldBeCalled(); - $view_serializer = new Serializer([], 'dummy_serializer', [], $mock_serializer, ['json', 'xml']); + $view_serializer = new Serializer([], 'dummy_serializer', [], $mock_serializer->reveal(), ['json', 'xml']); $view_serializer->options = $options; $view_serializer->view = $this->view; $view_serializer->displayHandler = $this->displayHandler;