Skip to content

Commit 0f04b86

Browse files
committed
Ignore Mailer classes and possible docblocks.
1 parent d15ef8d commit 0f04b86

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

src/Annotator/ClassAnnotatorTask/MailerClassAnnotatorTask.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ public function shouldRun(string $path, string $content): bool {
2323
return false;
2424
}
2525

26+
if (preg_match('#namespace \w+\\\\Mailer;#', $content)) {
27+
return false;
28+
}
29+
2630
preg_match('#\buse (\w+)\\\\Mailer\\\\(\w+)Mailer\b#', $content, $useMatches);
2731
preg_match('#\$\w+\s*=\s*\$this-\>getMailer\(\'([\w\.]+)\'\)#', $content, $callMatches);
2832
$singleLine = false;

tests/TestCase/Annotator/ClassAnnotatorTask/MailerClassAnnotatorTaskTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ public function testAnnotateExisting() {
144144
$this->assertSame('', $output);
145145
}
146146

147+
/**
148+
* @return void
149+
*/
150+
public function testShouldRunInvalid() {
151+
$content = file_get_contents(TEST_FILES . 'MailerAnnotation' . DS . 'MailerAnnotation.invalid.php');
152+
$task = $this->getTask($content);
153+
$path = '/src/Foo/Foo.php';
154+
155+
$result = $task->shouldRun($path, $content);
156+
$this->assertFalse($result);
157+
}
158+
147159
/**
148160
* @param string $content
149161
* @param array $params
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
namespace TestApp\Mailer;
3+
4+
class DebugMailer {
5+
6+
/**
7+
* Usage: $this->getMailer('Debug')->send('test');
8+
*
9+
* @return self
10+
*/
11+
public function test(): self {
12+
$this->setTransport('gmail')
13+
->setTo('[email protected]')
14+
->setSubject('Debug Email')
15+
->setEmailFormat('html')
16+
->viewBuilder()
17+
->setTemplate('default');
18+
19+
return $this;
20+
}
21+
22+
}

0 commit comments

Comments
 (0)