function testDefaultAccept() { $c = new Configuration(); $c->setPriorities(['default', 'another', 'third']); $c->setAcceptFactory(function ($v) { return new AcceptCharset($v); }); $defaultAccept = $c->createDefaultAccept(); $this->assertInstanceOf('\\Negotiation\\AcceptCharset', $defaultAccept); $this->assertSame('default', $defaultAccept->getValue()); }
/** * Create an instance of Configuration. * * @param $headerName string name of accept header * @param $priorities array[string] list of accepted values sorted by * priority (first has highest) * @return Configuration */ public function create($headerName, array $priorities) { $negotiator = $this->createNegotiator($headerName); $acceptFactory = $this->createAcceptFactory($headerName); $c = new Configuration(); $c->setHeaderName($headerName); $c->setPriorities($priorities); $c->setNegotiator($negotiator); $c->setAcceptFactory($acceptFactory); return $c; }