Overview

Namespaces

  • Composer
    • Autoload
  • Guzzle
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
        • Header
      • QueryAggregator
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Mock
    • Stream
  • Mockery
    • Adapter
      • Phpunit
    • CountValidator
    • Exception
    • Generator
      • StringManipulation
        • Pass
    • Loader
    • Matcher
  • None
  • Omnipay
    • Common
      • Exception
      • Message
    • Dummy
      • Message
    • Fatzebra
      • Message
  • PHP
  • Symfony
    • Component
      • EventDispatcher
        • Debug
        • DependencyInjection
        • Tests
          • Debug
          • DependencyInjection
      • HttpFoundation
        • File
          • Exception
          • MimeType
        • Session
          • Attribute
          • Flash
          • Storage
            • Handler
            • Proxy
        • Tests
          • File
            • MimeType
          • Session
            • Attribute
            • Flash
            • Storage
              • Handler
              • Proxy
      • Yaml
        • Exception
        • Tests

Classes

  • Symfony\Component\Yaml\Tests\A
  • Symfony\Component\Yaml\Tests\B
  • Symfony\Component\Yaml\Tests\DumperTest
  • Symfony\Component\Yaml\Tests\InlineTest
  • Symfony\Component\Yaml\Tests\ParseExceptionTest
  • Symfony\Component\Yaml\Tests\ParserTest
  • Symfony\Component\Yaml\Tests\YamlTest
  • Overview
  • Namespace
  • Function
  • Tree
  1: <?php
  2: 
  3: /*
  4:  * This file is part of the Symfony package.
  5:  *
  6:  * (c) Fabien Potencier <fabien@symfony.com>
  7:  *
  8:  * For the full copyright and license information, please view the LICENSE
  9:  * file that was distributed with this source code.
 10:  */
 11: 
 12: namespace Symfony\Component\HttpFoundation\Tests;
 13: 
 14: use Symfony\Component\HttpFoundation\AcceptHeader;
 15: use Symfony\Component\HttpFoundation\AcceptHeaderItem;
 16: 
 17: class AcceptHeaderTest extends \PHPUnit_Framework_TestCase
 18: {
 19:     public function testFirst()
 20:     {
 21:         $header = AcceptHeader::fromString('text/plain; q=0.5, text/html, text/x-dvi; q=0.8, text/x-c');
 22:         $this->assertSame('text/html', $header->first()->getValue());
 23:     }
 24: 
 25:     /**
 26:      * @dataProvider provideFromStringData
 27:      */
 28:     public function testFromString($string, array $items)
 29:     {
 30:         $header = AcceptHeader::fromString($string);
 31:         $parsed = array_values($header->all());
 32:         // reset index since the fixtures don't have them set
 33:         foreach ($parsed as $item) {
 34:             $item->setIndex(0);
 35:         }
 36:         $this->assertEquals($items, $parsed);
 37:     }
 38: 
 39:     public function provideFromStringData()
 40:     {
 41:         return array(
 42:             array('', array()),
 43:             array('gzip', array(new AcceptHeaderItem('gzip'))),
 44:             array('gzip,deflate,sdch', array(new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch'))),
 45:             array("gzip, deflate\t,sdch", array(new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch'))),
 46:             array('"this;should,not=matter"', array(new AcceptHeaderItem('this;should,not=matter'))),
 47:         );
 48:     }
 49: 
 50:     /**
 51:      * @dataProvider provideToStringData
 52:      */
 53:     public function testToString(array $items, $string)
 54:     {
 55:         $header = new AcceptHeader($items);
 56:         $this->assertEquals($string, (string) $header);
 57:     }
 58: 
 59:     public function provideToStringData()
 60:     {
 61:         return array(
 62:             array(array(), ''),
 63:             array(array(new AcceptHeaderItem('gzip')), 'gzip'),
 64:             array(array(new AcceptHeaderItem('gzip'), new AcceptHeaderItem('deflate'), new AcceptHeaderItem('sdch')), 'gzip,deflate,sdch'),
 65:             array(array(new AcceptHeaderItem('this;should,not=matter')), 'this;should,not=matter'),
 66:         );
 67:     }
 68: 
 69:     /**
 70:      * @dataProvider provideFilterData
 71:      */
 72:     public function testFilter($string, $filter, array $values)
 73:     {
 74:         $header = AcceptHeader::fromString($string)->filter($filter);
 75:         $this->assertEquals($values, array_keys($header->all()));
 76:     }
 77: 
 78:     public function provideFilterData()
 79:     {
 80:         return array(
 81:             array('fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4', '/fr.*/', array('fr-FR', 'fr')),
 82:         );
 83:     }
 84: 
 85:     /**
 86:      * @dataProvider provideSortingData
 87:      */
 88:     public function testSorting($string, array $values)
 89:     {
 90:         $header = AcceptHeader::fromString($string);
 91:         $this->assertEquals($values, array_keys($header->all()));
 92:     }
 93: 
 94:     public function provideSortingData()
 95:     {
 96:         return array(
 97:             'quality has priority' => array('*;q=0.3,ISO-8859-1,utf-8;q=0.7',  array('ISO-8859-1', 'utf-8', '*')),
 98:             'order matters when q is equal' => array('*;q=0.3,ISO-8859-1;q=0.7,utf-8;q=0.7',  array('ISO-8859-1', 'utf-8', '*')),
 99:             'order matters when q is equal2' => array('*;q=0.3,utf-8;q=0.7,ISO-8859-1;q=0.7',  array('utf-8', 'ISO-8859-1', '*')),
100:         );
101:     }
102: }
103: 
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen