public function __construct(Service $service) { $this->filters = array(); if ($service->hasParameter("filter")) { $tmp = json_decode($service->getParameter("filter"), true); foreach ($tmp as $item) { if (array_key_exists("property", $item) && array_key_exists("value", $item)) { $this->filters[$item['property']] = $item["value"]; } } } }
/** * Tests injection of service parameters via the constructor. */ public function testConstructorParameterPassing() { $service = new Service(array("foo" => "bar")); $this->assertEquals($service->getParameter("foo"), "bar"); }