X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=vendor%2Fpsy%2Fpsysh%2Ftest%2FPsy%2FTest%2FVersionUpdater%2FGitHubCheckerTest.php;fp=vendor%2Fpsy%2Fpsysh%2Ftest%2FPsy%2FTest%2FVersionUpdater%2FGitHubCheckerTest.php;h=32a7e534ffd6bedfe19f7cca0ee92e19ff742742;hb=eba34333e3c89f208d2f72fa91351ad019a71583;hp=0000000000000000000000000000000000000000;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/psy/psysh/test/Psy/Test/VersionUpdater/GitHubCheckerTest.php b/vendor/psy/psysh/test/Psy/Test/VersionUpdater/GitHubCheckerTest.php new file mode 100644 index 000000000..32a7e534f --- /dev/null +++ b/vendor/psy/psysh/test/Psy/Test/VersionUpdater/GitHubCheckerTest.php @@ -0,0 +1,82 @@ +getMockBuilder('Psy\\VersionUpdater\\GitHubChecker') + ->setMethods(array('fetchLatestRelease')) + ->getMock(); + $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input); + $checker->isLatest(); + } + + /** + * @dataProvider jsonResults + * + * @param $assertion + * @param $input + */ + public function testDataSetResults($assertion, $input) + { + $checker = $this->getMockBuilder('Psy\\VersionUpdater\\GitHubChecker') + ->setMethods(array('fetchLatestRelease')) + ->getMock(); + $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input); + $this->assertSame($assertion, $checker->isLatest()); + } + + /** + * @return array + */ + public function jsonResults() + { + return array( + array(false, json_decode('{"tag_name":"v9.0.0"}')), + array(true, json_decode('{"tag_name":"v' . Shell::VERSION . '"}')), + array(true, json_decode('{"tag_name":"v0.0.1"}')), + array(true, json_decode('{"tag_name":"v0.4.1-alpha"}')), + array(true, json_decode('{"tag_name":"v0.4.2-beta3"}')), + array(true, json_decode('{"tag_name":"v0.0.1"}')), + array(true, json_decode('{"tag_name":""}')), + ); + } + + /** + * @return array + */ + public function malformedResults() + { + return array( + array(null), + array(false), + array(true), + array(json_decode('{"foo":"bar"}')), + array(json_decode('{}')), + array(json_decode('[]')), + array(array()), + array(json_decode('{"tag_name":false"}')), + array(json_decode('{"tag_name":true"}')), + ); + } +}