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\IpUtils;
15: 
16: class IpUtilsTest extends \PHPUnit_Framework_TestCase
17: {
18:     /**
19:      * @dataProvider testIpv4Provider
20:      */
21:     public function testIpv4($matches, $remoteAddr, $cidr)
22:     {
23:         $this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr));
24:     }
25: 
26:     public function testIpv4Provider()
27:     {
28:         return array(
29:             array(true, '192.168.1.1', '192.168.1.1'),
30:             array(true, '192.168.1.1', '192.168.1.1/1'),
31:             array(true, '192.168.1.1', '192.168.1.0/24'),
32:             array(false, '192.168.1.1', '1.2.3.4/1'),
33:             array(false, '192.168.1.1', '192.168.1/33'),
34:             array(true, '192.168.1.1', array('1.2.3.4/1', '192.168.1.0/24')),
35:             array(true, '192.168.1.1', array('192.168.1.0/24', '1.2.3.4/1')),
36:             array(false, '192.168.1.1', array('1.2.3.4/1', '4.3.2.1/1')),
37:         );
38:     }
39: 
40:     /**
41:      * @dataProvider testIpv6Provider
42:      */
43:     public function testIpv6($matches, $remoteAddr, $cidr)
44:     {
45:         if (!defined('AF_INET6')) {
46:             $this->markTestSkipped('Only works when PHP is compiled without the option "disable-ipv6".');
47:         }
48: 
49:         $this->assertSame($matches, IpUtils::checkIp($remoteAddr, $cidr));
50:     }
51: 
52:     public function testIpv6Provider()
53:     {
54:         return array(
55:             array(true, '2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'),
56:             array(false, '2a00:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65'),
57:             array(false, '2a01:198:603:0:396e:4789:8e99:890f', '::1'),
58:             array(true, '0:0:0:0:0:0:0:1', '::1'),
59:             array(false, '0:0:603:0:396e:4789:8e99:0001', '::1'),
60:             array(true, '2a01:198:603:0:396e:4789:8e99:890f', array('::1', '2a01:198:603:0::/65')),
61:             array(true, '2a01:198:603:0:396e:4789:8e99:890f', array('2a01:198:603:0::/65', '::1')),
62:             array(false, '2a01:198:603:0:396e:4789:8e99:890f', array('::1', '1a01:198:603:0::/65')),
63:         );
64:     }
65: 
66:     /**
67:      * @expectedException \RuntimeException
68:      */
69:     public function testAnIpv6WithOptionDisabledIpv6()
70:     {
71:         if (!extension_loaded('sockets')) {
72:             $this->markTestSkipped('Only works when the socket extension is enabled');
73:         }
74: 
75:         if (defined('AF_INET6')) {
76:             $this->markTestSkipped('Only works when PHP is compiled with the option "disable-ipv6".');
77:         }
78: 
79:         IpUtils::checkIp('2a01:198:603:0:396e:4789:8e99:890f', '2a01:198:603:0::/65');
80:     }
81: }
82: 
Omnipay Fat Zebra / Paystream Gateway Module API Documentation API documentation generated by ApiGen