dataMock = $this->getMockBuilder(DataInterface::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerHelper = new ObjectManagerHelper($this); $this->config = $this->objectManagerHelper->getObject( Config::class, [ 'data' => $this->dataMock, ] ); } public function testGet() { $queryName = 'query string'; $queryResult = [ 'query' => 1 ]; $this->dataMock ->expects($this->once()) ->method('get') ->with($queryName) ->willReturn($queryResult); $this->assertSame($queryResult, $this->config->get($queryName)); } }