File
2 years ago
Fixtures
2 years ago
Session
2 years ago
schema
2 years ago
AcceptHeaderItemTest.php
2 years ago
AcceptHeaderTest.php
2 years ago
ApacheRequestTest.php
2 years ago
BinaryFileResponseTest.php
2 years ago
CookieTest.php
2 years ago
ExpressionRequestMatcherTest.php
2 years ago
FileBagTest.php
2 years ago
HeaderBagTest.php
2 years ago
IpUtilsTest.php
2 years ago
JsonResponseTest.php
2 years ago
ParameterBagTest.php
2 years ago
RedirectResponseTest.php
2 years ago
RequestMatcherTest.php
2 years ago
RequestStackTest.php
2 years ago
RequestTest.php
2 years ago
ResponseFunctionalTest.php
2 years ago
ResponseHeaderBagTest.php
2 years ago
ResponseTest.php
2 years ago
ResponseTestCase.php
2 years ago
ServerBagTest.php
2 years ago
StreamedResponseTest.php
2 years ago
AcceptHeaderItemTest.php
117 lines
| 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 | * Modified by impress-org on 23-January-2024 using Strauss. |
| 12 | * @see https://github.com/BrianHenryIE/strauss |
| 13 | */ |
| 14 | |
| 15 | namespace Give\Vendors\Symfony\Component\HttpFoundation\Tests; |
| 16 | |
| 17 | use PHPUnit\Framework\TestCase; |
| 18 | use Give\Vendors\Symfony\Component\HttpFoundation\AcceptHeaderItem; |
| 19 | |
| 20 | class AcceptHeaderItemTest extends TestCase |
| 21 | { |
| 22 | /** |
| 23 | * @dataProvider provideFromStringData |
| 24 | */ |
| 25 | public function testFromString($string, $value, array $attributes) |
| 26 | { |
| 27 | $item = AcceptHeaderItem::fromString($string); |
| 28 | $this->assertEquals($value, $item->getValue()); |
| 29 | $this->assertEquals($attributes, $item->getAttributes()); |
| 30 | } |
| 31 | |
| 32 | public function provideFromStringData() |
| 33 | { |
| 34 | return [ |
| 35 | [ |
| 36 | 'text/html', |
| 37 | 'text/html', [], |
| 38 | ], |
| 39 | [ |
| 40 | '"this;should,not=matter"', |
| 41 | 'this;should,not=matter', [], |
| 42 | ], |
| 43 | [ |
| 44 | "text/plain; charset=utf-8;param=\"this;should,not=matter\";\tfootnotes=true", |
| 45 | 'text/plain', ['charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true'], |
| 46 | ], |
| 47 | [ |
| 48 | '"this;should,not=matter";charset=utf-8', |
| 49 | 'this;should,not=matter', ['charset' => 'utf-8'], |
| 50 | ], |
| 51 | ]; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * @dataProvider provideToStringData |
| 56 | */ |
| 57 | public function testToString($value, array $attributes, $string) |
| 58 | { |
| 59 | $item = new AcceptHeaderItem($value, $attributes); |
| 60 | $this->assertEquals($string, (string) $item); |
| 61 | } |
| 62 | |
| 63 | public function provideToStringData() |
| 64 | { |
| 65 | return [ |
| 66 | [ |
| 67 | 'text/html', [], |
| 68 | 'text/html', |
| 69 | ], |
| 70 | [ |
| 71 | 'text/plain', ['charset' => 'utf-8', 'param' => 'this;should,not=matter', 'footnotes' => 'true'], |
| 72 | 'text/plain;charset=utf-8;param="this;should,not=matter";footnotes=true', |
| 73 | ], |
| 74 | ]; |
| 75 | } |
| 76 | |
| 77 | public function testValue() |
| 78 | { |
| 79 | $item = new AcceptHeaderItem('value', []); |
| 80 | $this->assertEquals('value', $item->getValue()); |
| 81 | |
| 82 | $item->setValue('new value'); |
| 83 | $this->assertEquals('new value', $item->getValue()); |
| 84 | |
| 85 | $item->setValue(1); |
| 86 | $this->assertEquals('1', $item->getValue()); |
| 87 | } |
| 88 | |
| 89 | public function testQuality() |
| 90 | { |
| 91 | $item = new AcceptHeaderItem('value', []); |
| 92 | $this->assertEquals(1.0, $item->getQuality()); |
| 93 | |
| 94 | $item->setQuality(0.5); |
| 95 | $this->assertEquals(0.5, $item->getQuality()); |
| 96 | |
| 97 | $item->setAttribute('q', 0.75); |
| 98 | $this->assertEquals(0.75, $item->getQuality()); |
| 99 | $this->assertFalse($item->hasAttribute('q')); |
| 100 | } |
| 101 | |
| 102 | public function testAttribute() |
| 103 | { |
| 104 | $item = new AcceptHeaderItem('value', []); |
| 105 | $this->assertEquals([], $item->getAttributes()); |
| 106 | $this->assertFalse($item->hasAttribute('test')); |
| 107 | $this->assertNull($item->getAttribute('test')); |
| 108 | $this->assertEquals('default', $item->getAttribute('test', 'default')); |
| 109 | |
| 110 | $item->setAttribute('test', 'value'); |
| 111 | $this->assertEquals(['test' => 'value'], $item->getAttributes()); |
| 112 | $this->assertTrue($item->hasAttribute('test')); |
| 113 | $this->assertEquals('value', $item->getAttribute('test')); |
| 114 | $this->assertEquals('value', $item->getAttribute('test', 'default')); |
| 115 | } |
| 116 | } |
| 117 |