From 3f52ee8bc54198579e08ca449c1b217fee348111 Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Thu, 29 Nov 2018 13:00:40 +0000 Subject: [PATCH] Add tests for TokenProcessor::getContextValues() --- tests/phpunit/Civi/Token/TokenProcessorTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/phpunit/Civi/Token/TokenProcessorTest.php b/tests/phpunit/Civi/Token/TokenProcessorTest.php index 362c465a17..aadb596f4d 100644 --- a/tests/phpunit/Civi/Token/TokenProcessorTest.php +++ b/tests/phpunit/Civi/Token/TokenProcessorTest.php @@ -58,6 +58,22 @@ class TokenProcessorTest extends \CiviUnitTestCase { } } + /** + * Check that getContextValues() returns the correct data + */ + public function testGetContextValues() { + $p = new TokenProcessor($this->dispatcher, array( + 'controller' => __CLASS__, + 'omega' => '99', + )); + $p->addRow()->context('id', 10)->context('omega', '98'); + $p->addRow()->context('id', 10)->context('contact', (object) ['cid' => 10]); + $p->addRow()->context('id', 11)->context('contact', (object) ['cid' => 11]); + $this->assertArrayValuesEqual([10, 11], $p->getContextValues('id')); + $this->assertArrayValuesEqual(['99', '98'], $p->getContextValues('omega')); + $this->assertArrayValuesEqual([10, 11], $p->getContextValues('contact', 'cid')); + } + /** * Check that the TokenRow helper can correctly read/update token * values. -- 2.25.1