These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace BringYourOwnIdeas\UpdateChecker\Tests\Tasks; |
||
4 | |||
5 | use BringYourOwnIdeas\Maintenance\Tasks\UpdatePackageInfo; |
||
6 | use BringYourOwnIdeas\UpdateChecker\UpdateChecker; |
||
7 | use CheckComposerUpdatesTask; |
||
8 | use Composer\Package\PackageInterface; |
||
9 | use Config; |
||
10 | use PHPUnit_Framework_TestCase; |
||
11 | use SapphireTest; |
||
12 | |||
13 | /** |
||
14 | * @mixin PHPUnit_Framework_TestCase |
||
15 | */ |
||
16 | class CheckComposerUpdatesTaskTest extends SapphireTest |
||
17 | { |
||
18 | /** |
||
19 | * @var CheckComposerUpdatesTask |
||
20 | */ |
||
21 | protected $task; |
||
22 | |||
23 | /** |
||
24 | * @var string[] |
||
25 | */ |
||
26 | protected $allowedTypes; |
||
27 | |||
28 | public function setUp() |
||
29 | { |
||
30 | parent::setUp(); |
||
31 | |||
32 | $this->task = CheckComposerUpdatesTask::create(); |
||
33 | |||
34 | $updateCheckerMock = $this->getMockBuilder(UpdateChecker::class)->setMethods(['checkForUpdates'])->getMock(); |
||
0 ignored issues
–
show
|
|||
35 | $this->task->setUpdateChecker($updateCheckerMock); |
||
36 | |||
37 | $this->allowedTypes = ['silverstripe-module', 'silverstripe-vendormodule', 'silverstripe-theme']; |
||
38 | Config::inst()->update(UpdatePackageInfo::class, 'allowed_types', $this->allowedTypes); |
||
39 | } |
||
40 | |||
41 | public function testRunPassesPackagesToUpdateChecker() |
||
42 | { |
||
43 | $this->task->getUpdateChecker()->expects($this->atLeastOnce()) |
||
0 ignored issues
–
show
The method
atLeastOnce() does not seem to exist on object<BringYourOwnIdeas...omposerUpdatesTaskTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
The method
expects() does not seem to exist on object<BringYourOwnIdeas...eChecker\UpdateChecker> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
44 | ->method('checkForUpdates') |
||
45 | ->with($this->isInstanceOf(PackageInterface::class), $this->isType('string')); |
||
0 ignored issues
–
show
The method
isInstanceOf() does not seem to exist on object<BringYourOwnIdeas...omposerUpdatesTaskTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
The method
isType() does not seem to exist on object<BringYourOwnIdeas...omposerUpdatesTaskTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
46 | |||
47 | $output = $this->runTask(); |
||
48 | $this->assertContains('The task finished running', $output); |
||
49 | } |
||
50 | |||
51 | public function testOnlyAllowedPackageTypesAreProcessed() |
||
52 | { |
||
53 | $this->task->getUpdateChecker()->expects($this->atLeastOnce()) |
||
0 ignored issues
–
show
The method
atLeastOnce() does not seem to exist on object<BringYourOwnIdeas...omposerUpdatesTaskTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
The method
expects() does not seem to exist on object<BringYourOwnIdeas...eChecker\UpdateChecker> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
54 | ->method('checkForUpdates') |
||
55 | ->with($this->callback(function ($argument) { |
||
0 ignored issues
–
show
The method
callback() does not seem to exist on object<BringYourOwnIdeas...omposerUpdatesTaskTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
56 | return in_array($argument->getType(), $this->allowedTypes); |
||
57 | })); |
||
58 | |||
59 | $this->runTask(); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * Runs the task and buffers the output (tasks output directly) |
||
64 | * |
||
65 | * @return string Task output |
||
66 | */ |
||
67 | protected function runTask() |
||
68 | { |
||
69 | ob_start(); |
||
70 | $this->task->run(null); |
||
0 ignored issues
–
show
null is of type null , but the function expects a object<SS_HTTPRequest> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
Loading history...
|
|||
71 | return ob_get_clean(); |
||
72 | } |
||
73 | } |
||
74 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.