selectMock = $this->getMockBuilder(Select::class) ->disableOriginalConstructor() ->getMock(); $this->selectHydratorMock = $this->getMockBuilder(selectHydrator::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->query = $this->objectManagerHelper->getObject( Query::class, [ 'select' => $this->selectMock, 'connectionName' => $this->connectionName, 'selectHydrator' => $this->selectHydratorMock, 'config' => [] ] ); } /** * @return void */ public function testJsonSerialize() { $selectParts = ['part' => 1]; $this->selectHydratorMock ->expects($this->once()) ->method('extract') ->with($this->selectMock) ->willReturn($selectParts); $expectedResult = [ 'connectionName' => $this->connectionName, 'select_parts' => $selectParts, 'config' => [] ]; $this->assertSame($expectedResult, $this->query->jsonSerialize()); } }