4 * This file is part of Psy Shell.
6 * (c) 2012-2017 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(array('fetchLatestRelease'))
30 $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input);
35 * @dataProvider jsonResults
40 public function testDataSetResults($assertion, $input)
42 $checker = $this->getMockBuilder('Psy\\VersionUpdater\\GitHubChecker')
43 ->setMethods(array('fetchLatestRelease'))
45 $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input);
46 $this->assertSame($assertion, $checker->isLatest());
52 public function jsonResults()
55 array(false, json_decode('{"tag_name":"v9.0.0"}')),
56 array(true, json_decode('{"tag_name":"v' . Shell::VERSION . '"}')),
57 array(true, json_decode('{"tag_name":"v0.0.1"}')),
58 array(true, json_decode('{"tag_name":"v0.4.1-alpha"}')),
59 array(true, json_decode('{"tag_name":"v0.4.2-beta3"}')),
60 array(true, json_decode('{"tag_name":"v0.0.1"}')),
61 array(true, json_decode('{"tag_name":""}')),
68 public function malformedResults()
74 array(json_decode('{"foo":"bar"}')),
75 array(json_decode('{}')),
76 array(json_decode('[]')),
78 array(json_decode('{"tag_name":false"}')),
79 array(json_decode('{"tag_name":true"}')),