annotate vendor/psy/psysh/test/VersionUpdater/GitHubCheckerTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 5fb285c0d0e3
children 129ea1e6d783
rev   line source
Chris@13 1 <?php
Chris@13 2
Chris@13 3 /*
Chris@13 4 * This file is part of Psy Shell.
Chris@13 5 *
Chris@13 6 * (c) 2012-2018 Justin Hileman
Chris@13 7 *
Chris@13 8 * For the full copyright and license information, please view the LICENSE
Chris@13 9 * file that was distributed with this source code.
Chris@13 10 */
Chris@13 11
Chris@13 12 namespace Psy\Test\VersionUpdater;
Chris@13 13
Chris@13 14 use Psy\Shell;
Chris@13 15
Chris@13 16 class GitHubCheckerTest extends \PHPUnit\Framework\TestCase
Chris@13 17 {
Chris@13 18 /**
Chris@13 19 * @dataProvider malformedResults
Chris@13 20 * @expectedException \InvalidArgumentException
Chris@13 21 * @expectedExceptionMessage Unable to check for updates
Chris@13 22 *
Chris@13 23 * @param mixed $input
Chris@13 24 */
Chris@13 25 public function testExceptionInvocation($input)
Chris@13 26 {
Chris@13 27 $checker = $this->getMockBuilder('Psy\\VersionUpdater\\GitHubChecker')
Chris@13 28 ->setMethods(['fetchLatestRelease'])
Chris@13 29 ->getMock();
Chris@13 30 $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input);
Chris@13 31 $checker->isLatest();
Chris@13 32 }
Chris@13 33
Chris@13 34 /**
Chris@13 35 * @dataProvider jsonResults
Chris@13 36 *
Chris@13 37 * @param bool $assertion
Chris@13 38 * @param mixed $input
Chris@13 39 */
Chris@13 40 public function testDataSetResults($assertion, $input)
Chris@13 41 {
Chris@13 42 $checker = $this->getMockBuilder('Psy\\VersionUpdater\\GitHubChecker')
Chris@13 43 ->setMethods(['fetchLatestRelease'])
Chris@13 44 ->getMock();
Chris@13 45 $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input);
Chris@13 46 $this->assertSame($assertion, $checker->isLatest());
Chris@13 47 }
Chris@13 48
Chris@13 49 /**
Chris@13 50 * @return array
Chris@13 51 */
Chris@13 52 public function jsonResults()
Chris@13 53 {
Chris@13 54 return [
Chris@13 55 [false, json_decode('{"tag_name":"v9.0.0"}')],
Chris@13 56 [true, json_decode('{"tag_name":"v' . Shell::VERSION . '"}')],
Chris@13 57 [true, json_decode('{"tag_name":"v0.0.1"}')],
Chris@13 58 [true, json_decode('{"tag_name":"v0.4.1-alpha"}')],
Chris@13 59 [true, json_decode('{"tag_name":"v0.4.2-beta3"}')],
Chris@13 60 [true, json_decode('{"tag_name":"v0.0.1"}')],
Chris@13 61 [true, json_decode('{"tag_name":""}')],
Chris@13 62 ];
Chris@13 63 }
Chris@13 64
Chris@13 65 /**
Chris@13 66 * @return array
Chris@13 67 */
Chris@13 68 public function malformedResults()
Chris@13 69 {
Chris@13 70 return [
Chris@13 71 [null],
Chris@13 72 [false],
Chris@13 73 [true],
Chris@13 74 [json_decode('{"foo":"bar"}')],
Chris@13 75 [json_decode('{}')],
Chris@13 76 [json_decode('[]')],
Chris@13 77 [[]],
Chris@13 78 [json_decode('{"tag_name":false"}')],
Chris@13 79 [json_decode('{"tag_name":true"}')],
Chris@13 80 ];
Chris@13 81 }
Chris@13 82 }