4 * This file is part of Psy Shell.
6 * (c) 2012-2018 Justin Hileman
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Psy\Test\VersionUpdater;
16 class GitHubCheckerTest extends \PHPUnit\Framework\TestCase
19 * @dataProvider malformedResults
20 * @expectedException \InvalidArgumentException
21 * @expectedExceptionMessage Unable to check for updates
25 public function testExceptionInvocation($input)
27 $checker = $this->getMockBuilder('Psy\\VersionUpdater\\GitHubChecker')
28 ->setMethods(['fetchLatestRelease'])
30 $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input);
35 * @dataProvider jsonResults
37 * @param bool $assertion
40 public function testDataSetResults($assertion, $input)
42 $checker = $this->getMockBuilder('Psy\\VersionUpdater\\GitHubChecker')
43 ->setMethods(['fetchLatestRelease'])
45 $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input);
46 $this->assertSame($assertion, $checker->isLatest());
52 public function jsonResults()
55 [false, \json_decode('{"tag_name":"v9.0.0"}')],
56 [true, \json_decode('{"tag_name":"v' . Shell::VERSION . '"}')],
57 [true, \json_decode('{"tag_name":"v0.0.1"}')],
58 [true, \json_decode('{"tag_name":"v0.4.1-alpha"}')],
59 [true, \json_decode('{"tag_name":"v0.4.2-beta3"}')],
60 [true, \json_decode('{"tag_name":"v0.0.1"}')],
61 [true, \json_decode('{"tag_name":""}')],
68 public function malformedResults()
74 [\json_decode('{"foo":"bar"}')],
78 [\json_decode('{"tag_name":false"}')],
79 [\json_decode('{"tag_name":true"}')],