Chris@13: getMockBuilder('Psy\\VersionUpdater\\GitHubChecker') Chris@13: ->setMethods(['fetchLatestRelease']) Chris@13: ->getMock(); Chris@13: $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input); Chris@13: $checker->isLatest(); Chris@13: } Chris@13: Chris@13: /** Chris@13: * @dataProvider jsonResults Chris@13: * Chris@13: * @param bool $assertion Chris@13: * @param mixed $input Chris@13: */ Chris@13: public function testDataSetResults($assertion, $input) Chris@13: { Chris@13: $checker = $this->getMockBuilder('Psy\\VersionUpdater\\GitHubChecker') Chris@13: ->setMethods(['fetchLatestRelease']) Chris@13: ->getMock(); Chris@13: $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input); Chris@13: $this->assertSame($assertion, $checker->isLatest()); Chris@13: } Chris@13: Chris@13: /** Chris@13: * @return array Chris@13: */ Chris@13: public function jsonResults() Chris@13: { Chris@13: return [ Chris@17: [false, \json_decode('{"tag_name":"v9.0.0"}')], Chris@17: [true, \json_decode('{"tag_name":"v' . Shell::VERSION . '"}')], Chris@17: [true, \json_decode('{"tag_name":"v0.0.1"}')], Chris@17: [true, \json_decode('{"tag_name":"v0.4.1-alpha"}')], Chris@17: [true, \json_decode('{"tag_name":"v0.4.2-beta3"}')], Chris@17: [true, \json_decode('{"tag_name":"v0.0.1"}')], Chris@17: [true, \json_decode('{"tag_name":""}')], Chris@13: ]; Chris@13: } Chris@13: Chris@13: /** Chris@13: * @return array Chris@13: */ Chris@13: public function malformedResults() Chris@13: { Chris@13: return [ Chris@13: [null], Chris@13: [false], Chris@13: [true], Chris@17: [\json_decode('{"foo":"bar"}')], Chris@17: [\json_decode('{}')], Chris@17: [\json_decode('[]')], Chris@13: [[]], Chris@17: [\json_decode('{"tag_name":false"}')], Chris@17: [\json_decode('{"tag_name":true"}')], Chris@13: ]; Chris@13: } Chris@13: }