Completed
Push — master ( bceccb...62c3ec )
by Aimeos
02:22
created
lib/custom/tests/Slim/RouterTest.php 2 patches
Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -10,140 +10,140 @@
 block discarded – undo
10 10
 
11 11
 class RouterTest extends \PHPUnit_Framework_TestCase
12 12
 {
13
-    /** @var Router */
14
-    protected $router;
13
+	/** @var Router */
14
+	protected $router;
15 15
 
16
-    public function setUp()
17
-    {
16
+	public function setUp()
17
+	{
18 18
 		if( !class_exists( '\Slim\Router', false ) ) {
19 19
 			$this->markTestSkipped( '\Slim\Router is not available' );
20 20
 		}
21 21
 
22
-        $this->router = new \Aimeos\Slim\Router;
23
-    }
24
-
25
-    public function testRelativePathFor()
26
-    {
27
-        $this->router->setBasePath('/base/path');
28
-
29
-        $methods = ['GET'];
30
-        $pattern = '/hello/{first:\w+}/{last}';
31
-        $callable = function ($request, $response, $args) {
32
-            echo sprintf('Hello %s %s', $args['first'], $args['last']);
33
-        };
34
-        $route = $this->router->map($methods, $pattern, $callable);
35
-        $route->setName('foo');
36
-
37
-        $this->assertEquals(
38
-            '/hello/josh/lockhart',
39
-            $this->router->relativePathFor('foo', ['first' => 'josh', 'last' => 'lockhart'])
40
-        );
41
-    }
42
-
43
-    public function testPathForWithNoBasePath()
44
-    {
45
-        $this->router->setBasePath('');
46
-
47
-        $methods = ['GET'];
48
-        $pattern = '/hello/{first:\w+}/{last}';
49
-        $callable = function ($request, $response, $args) {
50
-            echo sprintf('Hello %s %s', $args['first'], $args['last']);
51
-        };
52
-        $route = $this->router->map($methods, $pattern, $callable);
53
-        $route->setName('foo');
54
-
55
-        $this->assertEquals(
56
-            '/hello/josh/lockhart',
57
-            $this->router->pathFor('foo', ['first' => 'josh', 'last' => 'lockhart'])
58
-        );
59
-    }
60
-
61
-    public function testPathForWithBasePath()
62
-    {
63
-        $methods = ['GET'];
64
-        $pattern = '/hello/{first:\w+}/{last}';
65
-        $callable = function ($request, $response, $args) {
66
-            echo sprintf('Hello %s %s', $args['first'], $args['last']);
67
-        };
68
-        $this->router->setBasePath('/base/path');
69
-        $route = $this->router->map($methods, $pattern, $callable);
70
-        $route->setName('foo');
71
-
72
-        $this->assertEquals(
73
-            '/base/path/hello/josh/lockhart',
74
-            $this->router->pathFor('foo', ['first' => 'josh', 'last' => 'lockhart'])
75
-        );
76
-    }
77
-
78
-    public function testPathForWithOptionalParameters()
79
-    {
80
-        $methods = ['GET'];
81
-        $pattern = '/archive/{year}[/{month:[\d:{2}]}[/d/{day}]]';
82
-        $callable = function ($request, $response, $args) {
83
-            return $response;
84
-        };
85
-        $route = $this->router->map($methods, $pattern, $callable);
86
-        $route->setName('foo');
87
-
88
-        $this->assertEquals(
89
-            '/archive/2015',
90
-            $this->router->pathFor('foo', ['year' => '2015'])
91
-        );
92
-        $this->assertEquals(
93
-            '/archive/2015/07',
94
-            $this->router->pathFor('foo', ['year' => '2015', 'month' => '07'])
95
-        );
96
-        $this->assertEquals(
97
-            '/archive/2015/07/d/19',
98
-            $this->router->pathFor('foo', ['year' => '2015', 'month' => '07', 'day' => '19'])
99
-        );
100
-    }
101
-
102
-    public function testPathForWithSurplusRouteParameters()
103
-    {
104
-        $methods = ['GET'];
105
-        $pattern = '/hello/{name}';
106
-        $callable = function ($request, $response, $args) {
107
-            echo sprintf('Hello %s', $args['name']);
108
-        };
109
-        $route = $this->router->map($methods, $pattern, $callable);
110
-        $route->setName('foo');
111
-
112
-        $this->assertEquals(
113
-            '/hello/josh?a=b',
114
-            $this->router->pathFor('foo', ['name' => 'josh', 'a' => 'b'])
115
-        );
116
-    }
117
-
118
-    /**
119
-     * @expectedException \InvalidArgumentException
120
-     */
121
-    public function testPathForWithMissingSegmentData()
122
-    {
123
-        $methods = ['GET'];
124
-        $pattern = '/hello/{first}/{last}';
125
-        $callable = function ($request, $response, $args) {
126
-            echo sprintf('Hello %s %s', $args['first'], $args['last']);
127
-        };
128
-        $route = $this->router->map($methods, $pattern, $callable);
129
-        $route->setName('foo');
130
-
131
-        $this->router->pathFor('foo', ['last' => 'lockhart']);
132
-    }
133
-
134
-    /**
135
-     * @expectedException \RuntimeException
136
-     */
137
-    public function testPathForRouteNotExists()
138
-    {
139
-        $methods = ['GET'];
140
-        $pattern = '/hello/{first}/{last}';
141
-        $callable = function ($request, $response, $args) {
142
-            echo sprintf('Hello %s %s', $args['first'], $args['last']);
143
-        };
144
-        $route = $this->router->map($methods, $pattern, $callable);
145
-        $route->setName('foo');
146
-
147
-        $this->router->pathFor('bar', ['first' => 'josh', 'last' => 'lockhart']);
148
-    }
22
+		$this->router = new \Aimeos\Slim\Router;
23
+	}
24
+
25
+	public function testRelativePathFor()
26
+	{
27
+		$this->router->setBasePath('/base/path');
28
+
29
+		$methods = ['GET'];
30
+		$pattern = '/hello/{first:\w+}/{last}';
31
+		$callable = function ($request, $response, $args) {
32
+			echo sprintf('Hello %s %s', $args['first'], $args['last']);
33
+		};
34
+		$route = $this->router->map($methods, $pattern, $callable);
35
+		$route->setName('foo');
36
+
37
+		$this->assertEquals(
38
+			'/hello/josh/lockhart',
39
+			$this->router->relativePathFor('foo', ['first' => 'josh', 'last' => 'lockhart'])
40
+		);
41
+	}
42
+
43
+	public function testPathForWithNoBasePath()
44
+	{
45
+		$this->router->setBasePath('');
46
+
47
+		$methods = ['GET'];
48
+		$pattern = '/hello/{first:\w+}/{last}';
49
+		$callable = function ($request, $response, $args) {
50
+			echo sprintf('Hello %s %s', $args['first'], $args['last']);
51
+		};
52
+		$route = $this->router->map($methods, $pattern, $callable);
53
+		$route->setName('foo');
54
+
55
+		$this->assertEquals(
56
+			'/hello/josh/lockhart',
57
+			$this->router->pathFor('foo', ['first' => 'josh', 'last' => 'lockhart'])
58
+		);
59
+	}
60
+
61
+	public function testPathForWithBasePath()
62
+	{
63
+		$methods = ['GET'];
64
+		$pattern = '/hello/{first:\w+}/{last}';
65
+		$callable = function ($request, $response, $args) {
66
+			echo sprintf('Hello %s %s', $args['first'], $args['last']);
67
+		};
68
+		$this->router->setBasePath('/base/path');
69
+		$route = $this->router->map($methods, $pattern, $callable);
70
+		$route->setName('foo');
71
+
72
+		$this->assertEquals(
73
+			'/base/path/hello/josh/lockhart',
74
+			$this->router->pathFor('foo', ['first' => 'josh', 'last' => 'lockhart'])
75
+		);
76
+	}
77
+
78
+	public function testPathForWithOptionalParameters()
79
+	{
80
+		$methods = ['GET'];
81
+		$pattern = '/archive/{year}[/{month:[\d:{2}]}[/d/{day}]]';
82
+		$callable = function ($request, $response, $args) {
83
+			return $response;
84
+		};
85
+		$route = $this->router->map($methods, $pattern, $callable);
86
+		$route->setName('foo');
87
+
88
+		$this->assertEquals(
89
+			'/archive/2015',
90
+			$this->router->pathFor('foo', ['year' => '2015'])
91
+		);
92
+		$this->assertEquals(
93
+			'/archive/2015/07',
94
+			$this->router->pathFor('foo', ['year' => '2015', 'month' => '07'])
95
+		);
96
+		$this->assertEquals(
97
+			'/archive/2015/07/d/19',
98
+			$this->router->pathFor('foo', ['year' => '2015', 'month' => '07', 'day' => '19'])
99
+		);
100
+	}
101
+
102
+	public function testPathForWithSurplusRouteParameters()
103
+	{
104
+		$methods = ['GET'];
105
+		$pattern = '/hello/{name}';
106
+		$callable = function ($request, $response, $args) {
107
+			echo sprintf('Hello %s', $args['name']);
108
+		};
109
+		$route = $this->router->map($methods, $pattern, $callable);
110
+		$route->setName('foo');
111
+
112
+		$this->assertEquals(
113
+			'/hello/josh?a=b',
114
+			$this->router->pathFor('foo', ['name' => 'josh', 'a' => 'b'])
115
+		);
116
+	}
117
+
118
+	/**
119
+	 * @expectedException \InvalidArgumentException
120
+	 */
121
+	public function testPathForWithMissingSegmentData()
122
+	{
123
+		$methods = ['GET'];
124
+		$pattern = '/hello/{first}/{last}';
125
+		$callable = function ($request, $response, $args) {
126
+			echo sprintf('Hello %s %s', $args['first'], $args['last']);
127
+		};
128
+		$route = $this->router->map($methods, $pattern, $callable);
129
+		$route->setName('foo');
130
+
131
+		$this->router->pathFor('foo', ['last' => 'lockhart']);
132
+	}
133
+
134
+	/**
135
+	 * @expectedException \RuntimeException
136
+	 */
137
+	public function testPathForRouteNotExists()
138
+	{
139
+		$methods = ['GET'];
140
+		$pattern = '/hello/{first}/{last}';
141
+		$callable = function ($request, $response, $args) {
142
+			echo sprintf('Hello %s %s', $args['first'], $args['last']);
143
+		};
144
+		$route = $this->router->map($methods, $pattern, $callable);
145
+		$route->setName('foo');
146
+
147
+		$this->router->pathFor('bar', ['first' => 'josh', 'last' => 'lockhart']);
148
+	}
149 149
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 
16 16
     public function setUp()
17 17
     {
18
-		if( !class_exists( '\Slim\Router', false ) ) {
19
-			$this->markTestSkipped( '\Slim\Router is not available' );
18
+		if (!class_exists('\Slim\Router', false)) {
19
+			$this->markTestSkipped('\Slim\Router is not available');
20 20
 		}
21 21
 
22 22
         $this->router = new \Aimeos\Slim\Router;
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
         $methods = ['GET'];
30 30
         $pattern = '/hello/{first:\w+}/{last}';
31
-        $callable = function ($request, $response, $args) {
31
+        $callable = function($request, $response, $args) {
32 32
             echo sprintf('Hello %s %s', $args['first'], $args['last']);
33 33
         };
34 34
         $route = $this->router->map($methods, $pattern, $callable);
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
         $methods = ['GET'];
48 48
         $pattern = '/hello/{first:\w+}/{last}';
49
-        $callable = function ($request, $response, $args) {
49
+        $callable = function($request, $response, $args) {
50 50
             echo sprintf('Hello %s %s', $args['first'], $args['last']);
51 51
         };
52 52
         $route = $this->router->map($methods, $pattern, $callable);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $methods = ['GET'];
64 64
         $pattern = '/hello/{first:\w+}/{last}';
65
-        $callable = function ($request, $response, $args) {
65
+        $callable = function($request, $response, $args) {
66 66
             echo sprintf('Hello %s %s', $args['first'], $args['last']);
67 67
         };
68 68
         $this->router->setBasePath('/base/path');
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     {
80 80
         $methods = ['GET'];
81 81
         $pattern = '/archive/{year}[/{month:[\d:{2}]}[/d/{day}]]';
82
-        $callable = function ($request, $response, $args) {
82
+        $callable = function($request, $response, $args) {
83 83
             return $response;
84 84
         };
85 85
         $route = $this->router->map($methods, $pattern, $callable);
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
     {
104 104
         $methods = ['GET'];
105 105
         $pattern = '/hello/{name}';
106
-        $callable = function ($request, $response, $args) {
106
+        $callable = function($request, $response, $args) {
107 107
             echo sprintf('Hello %s', $args['name']);
108 108
         };
109 109
         $route = $this->router->map($methods, $pattern, $callable);
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
     {
123 123
         $methods = ['GET'];
124 124
         $pattern = '/hello/{first}/{last}';
125
-        $callable = function ($request, $response, $args) {
125
+        $callable = function($request, $response, $args) {
126 126
             echo sprintf('Hello %s %s', $args['first'], $args['last']);
127 127
         };
128 128
         $route = $this->router->map($methods, $pattern, $callable);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     {
139 139
         $methods = ['GET'];
140 140
         $pattern = '/hello/{first}/{last}';
141
-        $callable = function ($request, $response, $args) {
141
+        $callable = function($request, $response, $args) {
142 142
             echo sprintf('Hello %s %s', $args['first'], $args['last']);
143 143
         };
144 144
         $route = $this->router->map($methods, $pattern, $callable);
Please login to merge, or discard this patch.
lib/custom/tests/MW/View/Helper/Url/SlimTest.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,40 +17,40 @@
 block discarded – undo
17 17
 
18 18
 	protected function setUp()
19 19
 	{
20
-		if( !class_exists( 'Slim\Router', false ) ) {
21
-			$this->markTestSkipped( '\Slim\Router is not available' );
20
+		if (!class_exists('Slim\Router', false)) {
21
+			$this->markTestSkipped('\Slim\Router is not available');
22 22
 		}
23 23
 
24 24
 		$view = new \Aimeos\MW\View\Standard();
25 25
 		$this->router = new \Aimeos\Slim\Router();
26
-		$this->object = new \Aimeos\MW\View\Helper\Url\Slim( $view, $this->router, array( 'site' => 'default' ) );
26
+		$this->object = new \Aimeos\MW\View\Helper\Url\Slim($view, $this->router, array('site' => 'default'));
27 27
 	}
28 28
 
29 29
 
30 30
 	protected function tearDown()
31 31
 	{
32
-		unset( $this->object, $this->router );
32
+		unset($this->object, $this->router);
33 33
 	}
34 34
 
35 35
 
36 36
 	public function testTransform()
37 37
 	{
38
-		$this->router->map( array( 'GET' ), 'shop/{site}', null )->setName( 'route' );
39
-		$result = $this->object->transform( 'route', 'catalog', 'lists', array( 'key' => 'value' ) );
38
+		$this->router->map(array('GET'), 'shop/{site}', null)->setName('route');
39
+		$result = $this->object->transform('route', 'catalog', 'lists', array('key' => 'value'));
40 40
 
41
-		$this->assertEquals( 'shop/default?key=value', $result );
41
+		$this->assertEquals('shop/default?key=value', $result);
42 42
 	}
43 43
 
44 44
 
45 45
 	public function testTransformAbsolute()
46 46
 	{
47
-		$config = array( 'absoluteUri' => true );
47
+		$config = array('absoluteUri' => true);
48 48
 
49
-		$this->router->setBasePath( 'https://localhost/' );
50
-		$this->router->map( array( 'GET' ), 'shop/{site}', null )->setName( 'route' );
49
+		$this->router->setBasePath('https://localhost/');
50
+		$this->router->map(array('GET'), 'shop/{site}', null)->setName('route');
51 51
 
52
-		$result = $this->object->transform( 'route', 'catalog', 'lists', array( 'key' => 'value' ), array(), $config );
52
+		$result = $this->object->transform('route', 'catalog', 'lists', array('key' => 'value'), array(), $config);
53 53
 
54
-		$this->assertEquals( 'https://localhost/shop/default?key=value', $result );
54
+		$this->assertEquals('https://localhost/shop/default?key=value', $result);
55 55
 	}
56 56
 }
Please login to merge, or discard this patch.