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\AcceptHeaderItem;
 15: 
 16: class AcceptHeaderItemTest extends \PHPUnit_Framework_TestCase
 17: {
 18:     /**
 19:      * @dataProvider provideFromStringData
 20:      */
 21:     public function testFromString($string, $value, array $attributes)
 22:     {
 23:         $item = AcceptHeaderItem::fromString($string);
 24:         $this->assertEquals($value, $item->getValue());
 25:         $this->assertEquals($attributes, $item->getAttributes());
 26:     }
 27: 
 28:     public function provideFromStringData()
 29:     {
 30:         return array(
 31:             array(
 32:                 'text/html',
 33:                 'text/html', array(),
 34:             ),
 35:             array(
 36:                 '"this;should,not=matter"',
 37:                 'this;should,not=matter', array(),
 38:             ),
 39:             array(
 40:                 "text/plain; charset=utf-8;param=\"this;should,not=matter\";\tfootnotes=true",
 41:                 'text/plain', array('charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true'),
 42:             ),
 43:             array(
 44:                 '"this;should,not=matter";charset=utf-8',
 45:                 'this;should,not=matter', array('charset' => 'utf-8'),
 46:             ),
 47:         );
 48:     }
 49: 
 50:     /**
 51:      * @dataProvider provideToStringData
 52:      */
 53:     public function testToString($value, array $attributes, $string)
 54:     {
 55:         $item = new AcceptHeaderItem($value, $attributes);
 56:         $this->assertEquals($string, (string) $item);
 57:     }
 58: 
 59:     public function provideToStringData()
 60:     {
 61:         return array(
 62:             array(
 63:                 'text/html', array(),
 64:                 'text/html',
 65:             ),
 66:             array(
 67:                 'text/plain', array('charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true'),
 68:                 'text/plain;charset=utf-8;param="this;should,not=matter";footnotes=true',
 69:             ),
 70:         );
 71:     }
 72: 
 73:     public function testValue()
 74:     {
 75:         $item = new AcceptHeaderItem('value', array());
 76:         $this->assertEquals('value', $item->getValue());
 77: 
 78:         $item->setValue('new value');
 79:         $this->assertEquals('new value', $item->getValue());
 80: 
 81:         $item->setValue(1);
 82:         $this->assertEquals('1', $item->getValue());
 83:     }
 84: 
 85:     public function testQuality()
 86:     {
 87:         $item = new AcceptHeaderItem('value', array());
 88:         $this->assertEquals(1.0, $item->getQuality());
 89: 
 90:         $item->setQuality(0.5);
 91:         $this->assertEquals(0.5, $item->getQuality());
 92: 
 93:         $item->setAttribute('q', 0.75);
 94:         $this->assertEquals(0.75, $item->getQuality());
 95:         $this->assertFalse($item->hasAttribute('q'));
 96:     }
 97: 
 98:     public function testAttribute()
 99:     {
100:         $item = new AcceptHeaderItem('value', array());
101:         $this->assertEquals(array(), $item->getAttributes());
102:         $this->assertFalse($item->hasAttribute('test'));
103:         $this->assertNull($item->getAttribute('test'));
104:         $this->assertEquals('default', $item->getAttribute('test', 'default'));
105: 
106:         $item->setAttribute('test', 'value');
107:         $this->assertEquals(array('test' => 'value'), $item->getAttributes());
108:         $this->assertTrue($item->hasAttribute('test'));
109:         $this->assertEquals('value', $item->getAttribute('test'));
110:         $this->assertEquals('value', $item->getAttribute('test', 'default'));
111:     }
112: }
113: 
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen