],
],
],
- $this->res->getSettings()
+ $this->res->getSettings('html-header')
);
}
->addSetting(['fruit' => ['yours' => 'orange']]);
$this->assertTreeEquals(
['fruit' => ['yours' => 'orange', 'mine' => 'apple']],
- $this->res->getSettings()
+ $this->res->getSettings('html-header')
);
$actual = CRM_Core_Region::instance('html-header')->render('');
- $expected = json_encode(['fruit' => ['yours' => 'orange', 'mine' => 'apple']]);
+ $expected = 'var CRM = ' . json_encode(['fruit' => ['yours' => 'orange', 'mine' => 'apple']]) . ';';
+ $this->assertTrue(strpos($actual, $expected) !== FALSE);
+ }
+
+ public function testAddSettingToBillingBlock() {
+ $this->res
+ ->addSetting(['cheese' => ['cheddar' => 'yellow']], 'billing-block')
+ ->addSetting(['cheese' => ['edam' => 'red']], 'billing-block');
+ $this->assertTreeEquals(
+ ['cheese' => ['edam' => 'red', 'cheddar' => 'yellow']],
+ $this->res->getSettings('billing-block')
+ );
+ $actual = CRM_Core_Region::instance('billing-block')->render('');
+ $expected = 'CRM.$.extend(true, CRM, ' . json_encode(['cheese' => ['edam' => 'red', 'cheddar' => 'yellow']]) . ');';
$this->assertTrue(strpos($actual, $expected) !== FALSE);
}
$event->data['fruit']['mine'] = 'banana';
});
$this->res->addSetting(['fruit' => ['mine' => 'apple']]);
- $settings = $this->res->getSettings();
+ $settings = $this->res->getSettings('html-header');
$this->assertTreeEquals(['fruit' => ['mine' => 'banana']], $settings);
}
return ['fruit' => ['mine' => 'apple']];
});
- $actual = $this->res->getSettings();
+ $actual = $this->res->getSettings('html-header');
$expected = ['fruit' => ['yours' => 'orange', 'mine' => 'apple']];
$this->assertTreeEquals($expected, $actual);
}
$this->res->addSettingsFactory(function () use (&$muckableValue) {
return $muckableValue;
});
- $actual = $this->res->getSettings();
+ $actual = $this->res->getSettings('html-header');
$expected = ['fruit' => ['mine' => 'apple', 'yours' => 'orange', 'theirs' => 'apricot']];
$this->assertTreeEquals($expected, $actual);
// note: the setting is not fixed based on what the factory returns when registered; it's based
// on what the factory returns when getSettings is called
$muckableValue = ['fruit' => ['yours' => 'banana']];
- $actual = $this->res->getSettings();
+ $actual = $this->res->getSettings('html-header');
$expected = ['fruit' => ['mine' => 'apple', 'yours' => 'banana']];
$this->assertTreeEquals($expected, $actual);
}