-
-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dev/core#2814 fix tokenCompat to be consistent with unresolved tokens #21568
Changes from all commits
7237967
8d4c4d6
03946c1
e1281f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
<?php | ||
namespace Civi\Token; | ||
|
||
use Civi\Test\Invasive; | ||
use Civi\Token\Event\TokenRegisterEvent; | ||
use Civi\Token\Event\TokenValueEvent; | ||
use Symfony\Component\EventDispatcher\EventDispatcher; | ||
|
@@ -45,19 +44,23 @@ public function testVisitTokens() { | |
'{foo.bar}' => ['foo', 'bar', NULL], | ||
'{foo.bar|whiz}' => ['foo', 'bar', ['whiz']], | ||
'{foo.bar|whiz:"bang"}' => ['foo', 'bar', ['whiz', 'bang']], | ||
'{love.shack|place:"bang":"b@ng, on +he/([do0r])?!"}' => ['love', 'shack', ['place', 'bang', 'b@ng, on +he/([do0r])?!']], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you didn't like this one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, I wouldn't want anyone to accuse of desecrating the art of the B-52s... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol |
||
'{FoO.bAr|whiz:"bang"}' => ['FoO', 'bAr', ['whiz', 'bang']], | ||
'{oo_f.ra_b|b_52:"bang":"b@ng, on +he/([do0r])?!"}' => ['oo_f', 'ra_b', ['b_52', 'bang', 'b@ng, on +he/([do0r])?!']], | ||
'{foo.bar.whiz}' => ['foo', 'bar.whiz', NULL], | ||
'{foo.bar.whiz|bang}' => ['foo', 'bar.whiz', ['bang']], | ||
'{foo.bar:label}' => ['foo', 'bar:label', NULL], | ||
'{foo.bar:label|truncate:"10"}' => ['foo', 'bar:label', ['truncate', '10']], | ||
]; | ||
foreach ($examples as $input => $expected) { | ||
array_unshift($expected, $input); | ||
$log = []; | ||
Invasive::call([$p, 'visitTokens'], [ | ||
$input, | ||
function (?string $fullToken, ?string $entity, ?string $field, ?array $modifier) use (&$log) { | ||
$log[] = [$fullToken, $entity, $field, $modifier]; | ||
}, | ||
]); | ||
$filtered = $p->visitTokens($input, function (?string $fullToken, ?string $entity, ?string $field, ?array $modifier) use (&$log) { | ||
$log[] = [$fullToken, $entity, $field, $modifier]; | ||
return 'Replaced!'; | ||
}); | ||
$this->assertEquals(1, count($log), "Should receive one callback on expression: $input"); | ||
$this->assertEquals($expected, $log[0]); | ||
$this->assertEquals('Replaced!', $filtered); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this testing now without an unknown token in the input message? How about:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh dang - did I remove from the wrong line!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#21585 puts it back