Skip to content

Commit 3f5ae0d

Browse files
authored
Merge pull request #374 from dpalou/MDL-72048
MDL-72048: Disable lint on mobile app templates
2 parents 6951512 + 55a3be5 commit 3f5ae0d

File tree

3 files changed

+70
-3
lines changed

3 files changed

+70
-3
lines changed

src/Command/MustacheCommand.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6262

6363
$code = 0;
6464
foreach ($files as $file) {
65+
if (str_contains($file, '/templates/mobileapp/')) {
66+
// Skip app templates for now because they throw many warnings due to custom directives.
67+
// To be improved in the future.
68+
$this->outputSkip($output, 'Skipping mobile app template: ' . $file);
69+
continue;
70+
}
71+
6572
$cmd = [
6673
'env',
6774
'-u',

tests/Command/MustacheCommandTest.php

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
use MoodlePluginCI\Tests\Fake\Process\DummyExecute;
1818
use MoodlePluginCI\Tests\MoodleTestCase;
1919
use Symfony\Component\Console\Application;
20+
use Symfony\Component\Console\Output\OutputInterface;
2021
use Symfony\Component\Console\Tester\CommandTester;
2122

2223
class MustacheCommandTest extends MoodleTestCase
2324
{
24-
protected function executeCommand($pluginDir = null, $moodleDir = null)
25+
protected function executeCommand($pluginDir = null, $moodleDir = null, $command = null)
2526
{
2627
if ($pluginDir === null) {
2728
$pluginDir = $this->pluginDir;
@@ -30,7 +31,10 @@ protected function executeCommand($pluginDir = null, $moodleDir = null)
3031
$moodleDir = $this->moodleDir;
3132
}
3233

33-
$command = new MustacheCommand();
34+
if ($command === null) {
35+
$command = new MustacheCommand();
36+
}
37+
3438
$command->moodle = new DummyMoodle($moodleDir);
3539
$command->execute = new DummyExecute();
3640

@@ -48,7 +52,20 @@ protected function executeCommand($pluginDir = null, $moodleDir = null)
4852

4953
public function testExecute()
5054
{
51-
$commandTester = $this->executeCommand();
55+
// Assert that the mobile app template is skipped.
56+
$command = $this->getMockBuilder(MustacheCommand::class)
57+
->onlyMethods(['outputSkip'])
58+
->getMock();
59+
60+
$command->expects($this->once())
61+
->method('outputSkip')
62+
->with(
63+
$this->isInstanceOf(OutputInterface::class),
64+
$this->stringContains('/templates/mobileapp/item.mustache'),
65+
)
66+
->willReturn(0);
67+
68+
$commandTester = $this->executeCommand(null, null, $command);
5269
$this->assertSame(0, $commandTester->getStatusCode());
5370
}
5471

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{!
2+
This file is part of Moodle - http://moodle.org/
3+
4+
Moodle is free software: you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
Moodle is distributed in the hope that it will be useful,
10+
but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
GNU General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16+
}}
17+
{{!
18+
@template mobileapp/item
19+
20+
Template to render an item in the mobile app.
21+
22+
Classes required for JS:
23+
* none
24+
25+
Data attributes required for JS:
26+
* none
27+
28+
Context variables required for this template:
29+
*
30+
31+
Example context (json):
32+
{}
33+
}}
34+
{{=<% %>=}}
35+
<ion-item class="ion-text-wrap ion-text-center">
36+
<ion-label>
37+
{{ 'fake_string' | translate }}
38+
</ion-label>
39+
</ion-item>
40+
41+
42+
<!-- Call a WS when the template is loaded. -->
43+
<span core-site-plugins-call-ws-on-load name="my_fake_ws" [preSets]="{getFromCache: 0, saveToCache: 0}"></span>

0 commit comments

Comments
 (0)