public function testAvailableFormats()
 {
     $availableFormats = Format::getAvailable();
     $this->assertCount(2, $availableFormats);
     $this->assertContains('json', $availableFormats);
     $this->assertContains('xml', $availableFormats);
 }
 public function testTransformChangesRequestFormatUnknown()
 {
     $subject = $this->getSubject();
     $request = $this->getRequest([]);
     $request->initialize(['_format' => 'csv']);
     $subject->transform($request);
     $this->assertEquals(Format::getDefault(), $request->getRequestFormat());
 }
 /**
  * @param Request $request
  */
 protected function setRequestFormat(Request $request)
 {
     $default = Format::getDefault();
     $format = $request->getRequestFormat($request->query->get('_format', $default));
     if (!in_array($format, $this->outputFormats)) {
         $format = $default;
     }
     $request->setRequestFormat($format);
 }
 /**
  * @param ArrayNodeDefinition $node
  */
 private function addOutputFormatNode(ArrayNodeDefinition $node)
 {
     $node->children()->arrayNode('output_formats')->defaultValue([Format::getDefault()])->prototype('scalar')->validate()->ifNotInArray(Format::getAvailable())->thenInvalid('Formats can only contain "' . implode('"', Format::getAvailable()) . '", not "%s"')->end()->end()->end();
 }