1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\Uri; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehlerclass SplitTest extends \PHPUnit_Framework_TestCase{ 6*a1a3b679SAndreas Boehler 7*a1a3b679SAndreas Boehler function testSplit() { 8*a1a3b679SAndreas Boehler 9*a1a3b679SAndreas Boehler $strings = [ 10*a1a3b679SAndreas Boehler 11*a1a3b679SAndreas Boehler // input // expected result 12*a1a3b679SAndreas Boehler '/foo/bar' => ['/foo','bar'], 13*a1a3b679SAndreas Boehler '/foo/bar/' => ['/foo','bar'], 14*a1a3b679SAndreas Boehler 'foo/bar/' => ['foo','bar'], 15*a1a3b679SAndreas Boehler 'foo/bar' => ['foo','bar'], 16*a1a3b679SAndreas Boehler 'foo/bar/baz' => ['foo/bar','baz'], 17*a1a3b679SAndreas Boehler 'foo/bar/baz/' => ['foo/bar','baz'], 18*a1a3b679SAndreas Boehler 'foo' => ['','foo'], 19*a1a3b679SAndreas Boehler 'foo/' => ['','foo'], 20*a1a3b679SAndreas Boehler '/foo/' => ['','foo'], 21*a1a3b679SAndreas Boehler '/foo' => ['','foo'], 22*a1a3b679SAndreas Boehler '' => [null,null], 23*a1a3b679SAndreas Boehler 24*a1a3b679SAndreas Boehler // UTF-8 25*a1a3b679SAndreas Boehler "/\xC3\xA0fo\xC3\xB3/bar" => ["/\xC3\xA0fo\xC3\xB3",'bar'], 26*a1a3b679SAndreas Boehler "/\xC3\xA0foo/b\xC3\xBCr/" => ["/\xC3\xA0foo","b\xC3\xBCr"], 27*a1a3b679SAndreas Boehler "foo/\xC3\xA0\xC3\xBCr" => ["foo","\xC3\xA0\xC3\xBCr"], 28*a1a3b679SAndreas Boehler 29*a1a3b679SAndreas Boehler ]; 30*a1a3b679SAndreas Boehler 31*a1a3b679SAndreas Boehler foreach($strings as $input => $expected) { 32*a1a3b679SAndreas Boehler 33*a1a3b679SAndreas Boehler $output = split($input); 34*a1a3b679SAndreas Boehler $this->assertEquals($expected, $output, 'The expected output for \'' . $input . '\' was incorrect'); 35*a1a3b679SAndreas Boehler 36*a1a3b679SAndreas Boehler 37*a1a3b679SAndreas Boehler } 38*a1a3b679SAndreas Boehler 39*a1a3b679SAndreas Boehler } 40*a1a3b679SAndreas Boehler 41*a1a3b679SAndreas Boehler} 42