From: Aidan Saunders Date: Thu, 29 Nov 2018 13:00:40 +0000 (+0000) Subject: Add tests for TokenProcessor::getContextValues() X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=3f52ee8bc54198579e08ca449c1b217fee348111;p=civicrm-core.git Add tests for TokenProcessor::getContextValues() --- 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.