/** * @dataProvider getData */ public function testGetData($point, $getter, $stored, $expected) { $this->_mockPersistence->shouldReceive('fetch')->once()->with(tubepress_api_options_Names::OAUTH2_CLIENT_DETAILS)->andReturn(json_encode($stored)); $this->_mockArrayReader->shouldReceive('getAsString')->once()->with($stored, 'name.' . $point, null)->andReturnUsing(function ($arr, $path, $default) { $reader = new tubepress_array_impl_ArrayReader(); return $reader->getAsString($arr, $path, $default); }); $mockProvider = $this->mock(tubepress_spi_http_oauth2_Oauth2ProviderInterface::_); $mockProvider->shouldReceive('getName')->once()->andReturn('name'); $getter = 'get' . ucfirst($getter); $actual = $this->_sut->{$getter}($mockProvider); $this->assertEquals($expected, $actual); }
/** * @dataProvider dataGetAsString */ public function testGetAsString($path, $expectedResult, $default) { $x = array('foo' => array('bar' => 'hi'), 'x' => 'y'); $actual = $this->_sut->getAsString($x, $path, $default); $this->assertEquals($expectedResult, $actual); }