Skip to content

Commit

Permalink
Fix plugin detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Nov 21, 2021
1 parent 66a7852 commit a6459de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Annotator/ClassAnnotatorTask/MailerClassAnnotatorTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function shouldRun(string $path, string $content): bool {
}

preg_match('#\buse (\w+)\\\\Mailer\\\\(\w+)Mailer\b#', $content, $useMatches);
preg_match('#\$\w+\s*=\s*\$this-\>getMailer\(\'(\w+)\'\)#', $content, $callMatches);
preg_match('#\$\w+\s*=\s*\$this-\>getMailer\(\'([\w\.]+)\'\)#', $content, $callMatches);
if (!$useMatches && !$callMatches) {
return false;
}
Expand All @@ -50,7 +50,7 @@ public function shouldRun(string $path, string $content): bool {
public function annotate(string $path): bool {
preg_match('#\buse (\w+)\\\\Mailer\\\\(\w+)Mailer\b#', $this->content, $useMatches);
if (!$useMatches) {
preg_match('#\$\w+\s*=\s*\$this->getMailer\(\'(\w+)\'\)#', $this->content, $callMatches);
preg_match('#\$\w+\s*=\s*\$this->getMailer\(\'([\w\.]+)\'\)#', $this->content, $callMatches);
if (!$callMatches) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,20 @@ public function testShouldRunViaCall() {
$this->assertFalse($result);
}

/**
* @return void
*/
public function testShouldRunViaCallPlugin() {
$task = $this->getTask('');

$content = 'namespace TestApp\\Foo' . PHP_EOL . '$notificationMailer = $this->getMailer(\'FooBar.Notification\')' . PHP_EOL . '$notificationMailer->send(\'notify\')';
$result = $task->shouldRun('/src/Foo.php', $content);
$this->assertTrue($result);

$result = $task->shouldRun('/tests/Foo.php', $content);
$this->assertFalse($result);
}

/**
* @return void
*/
Expand Down

0 comments on commit a6459de

Please sign in to comment.