public function testApply() { $filter = '10-150'; $requestVar = 'test_request_var'; $this->target->setRequestVar($requestVar); $this->request->expects($this->exactly(1))->method('getParam')->will($this->returnCallback(function ($field) use($requestVar, $filter) { $this->assertTrue(in_array($field, [$requestVar, 'id'])); return $filter; })); $attributeCode = 'AttributeCode'; $this->attribute->expects($this->any())->method('getAttributeCode')->will($this->returnValue($attributeCode)); $this->fulltextCollection->expects($this->once())->method('addFieldToFilter')->with($attributeCode)->will($this->returnSelf()); $this->target->apply($this->request); }