Mercurial > hg > isophonics-drupal-site
comparison vendor/psy/psysh/test/VersionUpdater/GitHubCheckerTest.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | |
children | 129ea1e6d783 |
comparison
equal
deleted
inserted
replaced
12:7a779792577d | 13:5fb285c0d0e3 |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of Psy Shell. | |
5 * | |
6 * (c) 2012-2018 Justin Hileman | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Psy\Test\VersionUpdater; | |
13 | |
14 use Psy\Shell; | |
15 | |
16 class GitHubCheckerTest extends \PHPUnit\Framework\TestCase | |
17 { | |
18 /** | |
19 * @dataProvider malformedResults | |
20 * @expectedException \InvalidArgumentException | |
21 * @expectedExceptionMessage Unable to check for updates | |
22 * | |
23 * @param mixed $input | |
24 */ | |
25 public function testExceptionInvocation($input) | |
26 { | |
27 $checker = $this->getMockBuilder('Psy\\VersionUpdater\\GitHubChecker') | |
28 ->setMethods(['fetchLatestRelease']) | |
29 ->getMock(); | |
30 $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input); | |
31 $checker->isLatest(); | |
32 } | |
33 | |
34 /** | |
35 * @dataProvider jsonResults | |
36 * | |
37 * @param bool $assertion | |
38 * @param mixed $input | |
39 */ | |
40 public function testDataSetResults($assertion, $input) | |
41 { | |
42 $checker = $this->getMockBuilder('Psy\\VersionUpdater\\GitHubChecker') | |
43 ->setMethods(['fetchLatestRelease']) | |
44 ->getMock(); | |
45 $checker->expects($this->once())->method('fetchLatestRelease')->willReturn($input); | |
46 $this->assertSame($assertion, $checker->isLatest()); | |
47 } | |
48 | |
49 /** | |
50 * @return array | |
51 */ | |
52 public function jsonResults() | |
53 { | |
54 return [ | |
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":""}')], | |
62 ]; | |
63 } | |
64 | |
65 /** | |
66 * @return array | |
67 */ | |
68 public function malformedResults() | |
69 { | |
70 return [ | |
71 [null], | |
72 [false], | |
73 [true], | |
74 [json_decode('{"foo":"bar"}')], | |
75 [json_decode('{}')], | |
76 [json_decode('[]')], | |
77 [[]], | |
78 [json_decode('{"tag_name":false"}')], | |
79 [json_decode('{"tag_name":true"}')], | |
80 ]; | |
81 } | |
82 } |