@@ -15,31 +15,31 @@ |
||
15 | 15 | { |
16 | 16 | $target = '\\Aimeos\\Controller\\Frontend\\Cms\\Iface'; |
17 | 17 | |
18 | - $controller = \Aimeos\Controller\Frontend\Cms\Factory::create( \TestHelperFrontend::getContext() ); |
|
19 | - $this->assertInstanceOf( $target, $controller ); |
|
18 | + $controller = \Aimeos\Controller\Frontend\Cms\Factory::create(\TestHelperFrontend::getContext()); |
|
19 | + $this->assertInstanceOf($target, $controller); |
|
20 | 20 | |
21 | - $controller = \Aimeos\Controller\Frontend\Cms\Factory::create( \TestHelperFrontend::getContext(), 'Standard' ); |
|
22 | - $this->assertInstanceOf( $target, $controller ); |
|
21 | + $controller = \Aimeos\Controller\Frontend\Cms\Factory::create(\TestHelperFrontend::getContext(), 'Standard'); |
|
22 | + $this->assertInstanceOf($target, $controller); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
26 | 26 | public function testCreateControllerInvalidImplementation() |
27 | 27 | { |
28 | - $this->expectException( '\\Aimeos\\MW\\Common\\Exception' ); |
|
29 | - \Aimeos\Controller\Frontend\Cms\Factory::create( \TestHelperFrontend::getContext(), 'Invalid' ); |
|
28 | + $this->expectException('\\Aimeos\\MW\\Common\\Exception'); |
|
29 | + \Aimeos\Controller\Frontend\Cms\Factory::create(\TestHelperFrontend::getContext(), 'Invalid'); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | public function testCreateControllerInvalidName() |
34 | 34 | { |
35 | - $this->expectException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
36 | - \Aimeos\Controller\Frontend\Cms\Factory::create( \TestHelperFrontend::getContext(), '%^' ); |
|
35 | + $this->expectException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
36 | + \Aimeos\Controller\Frontend\Cms\Factory::create(\TestHelperFrontend::getContext(), '%^'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | 40 | public function testCreateControllerNotExisting() |
41 | 41 | { |
42 | - $this->expectException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
43 | - \Aimeos\Controller\Frontend\Cms\Factory::create( \TestHelperFrontend::getContext(), 'notexist' ); |
|
42 | + $this->expectException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
43 | + \Aimeos\Controller\Frontend\Cms\Factory::create(\TestHelperFrontend::getContext(), 'notexist'); |
|
44 | 44 | } |
45 | 45 | } |
@@ -20,145 +20,145 @@ |
||
20 | 20 | { |
21 | 21 | $this->context = \TestHelperFrontend::getContext(); |
22 | 22 | |
23 | - $this->stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Cms\Standard::class ) |
|
23 | + $this->stub = $this->getMockBuilder(\Aimeos\Controller\Frontend\Cms\Standard::class) |
|
24 | 24 | ->disableOriginalConstructor() |
25 | 25 | ->getMock(); |
26 | 26 | |
27 | - $this->object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Cms\Decorator\Base::class ) |
|
28 | - ->setConstructorArgs( [$this->stub, $this->context] ) |
|
27 | + $this->object = $this->getMockBuilder(\Aimeos\Controller\Frontend\Cms\Decorator\Base::class) |
|
28 | + ->setConstructorArgs([$this->stub, $this->context]) |
|
29 | 29 | ->getMockForAbstractClass(); |
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | protected function tearDown() : void |
34 | 34 | { |
35 | - unset( $this->context, $this->object, $this->stub ); |
|
35 | + unset($this->context, $this->object, $this->stub); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | public function testConstructException() |
40 | 40 | { |
41 | - $stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Iface::class )->getMock(); |
|
41 | + $stub = $this->getMockBuilder(\Aimeos\Controller\Frontend\Iface::class)->getMock(); |
|
42 | 42 | |
43 | - $this->expectException( \Aimeos\MW\Common\Exception::class ); |
|
43 | + $this->expectException(\Aimeos\MW\Common\Exception::class); |
|
44 | 44 | |
45 | - $this->getMockBuilder( \Aimeos\Controller\Frontend\Cms\Decorator\Base::class ) |
|
46 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
45 | + $this->getMockBuilder(\Aimeos\Controller\Frontend\Cms\Decorator\Base::class) |
|
46 | + ->setConstructorArgs([$stub, $this->context]) |
|
47 | 47 | ->getMockForAbstractClass(); |
48 | 48 | } |
49 | 49 | |
50 | 50 | |
51 | 51 | public function testCall() |
52 | 52 | { |
53 | - $stub = $this->getMockBuilder( \Aimeos\Controller\Frontend\Cms\Standard::class ) |
|
53 | + $stub = $this->getMockBuilder(\Aimeos\Controller\Frontend\Cms\Standard::class) |
|
54 | 54 | ->disableOriginalConstructor() |
55 | - ->setMethods( ['invalid'] ) |
|
55 | + ->setMethods(['invalid']) |
|
56 | 56 | ->getMock(); |
57 | 57 | |
58 | - $object = $this->getMockBuilder( \Aimeos\Controller\Frontend\Cms\Decorator\Base::class ) |
|
59 | - ->setConstructorArgs( [$stub, $this->context] ) |
|
58 | + $object = $this->getMockBuilder(\Aimeos\Controller\Frontend\Cms\Decorator\Base::class) |
|
59 | + ->setConstructorArgs([$stub, $this->context]) |
|
60 | 60 | ->getMockForAbstractClass(); |
61 | 61 | |
62 | - $stub->expects( $this->once() )->method( 'invalid' )->will( $this->returnValue( true ) ); |
|
62 | + $stub->expects($this->once())->method('invalid')->will($this->returnValue(true)); |
|
63 | 63 | |
64 | - $this->assertTrue( $object->invalid() ); |
|
64 | + $this->assertTrue($object->invalid()); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | 68 | public function testCompare() |
69 | 69 | { |
70 | - $this->assertSame( $this->object, $this->object->compare( '==', 'cms.status', 1 ) ); |
|
70 | + $this->assertSame($this->object, $this->object->compare('==', 'cms.status', 1)); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | 74 | public function testFind() |
75 | 75 | { |
76 | - $item = \Aimeos\MShop::create( $this->context, 'cms' )->create(); |
|
76 | + $item = \Aimeos\MShop::create($this->context, 'cms')->create(); |
|
77 | 77 | $expected = \Aimeos\MShop\Cms\Item\Iface::class; |
78 | 78 | |
79 | - $this->stub->expects( $this->once() )->method( 'find' ) |
|
80 | - ->will( $this->returnValue( $item ) ); |
|
79 | + $this->stub->expects($this->once())->method('find') |
|
80 | + ->will($this->returnValue($item)); |
|
81 | 81 | |
82 | - $this->assertInstanceOf( $expected, $this->object->find( 'test' ) ); |
|
82 | + $this->assertInstanceOf($expected, $this->object->find('test')); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | 86 | public function testFunction() |
87 | 87 | { |
88 | - $this->stub->expects( $this->once() )->method( 'function' ) |
|
89 | - ->will( $this->returnValue( 'cms:has("domain","type","refid")' ) ); |
|
88 | + $this->stub->expects($this->once())->method('function') |
|
89 | + ->will($this->returnValue('cms:has("domain","type","refid")')); |
|
90 | 90 | |
91 | - $str = $this->object->function( 'cms:has', ['domain', 'type', 'refid'] ); |
|
92 | - $this->assertEquals( 'cms:has("domain","type","refid")', $str ); |
|
91 | + $str = $this->object->function('cms:has', ['domain', 'type', 'refid']); |
|
92 | + $this->assertEquals('cms:has("domain","type","refid")', $str); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
96 | 96 | public function testGet() |
97 | 97 | { |
98 | - $item = \Aimeos\MShop::create( $this->context, 'cms' )->create(); |
|
98 | + $item = \Aimeos\MShop::create($this->context, 'cms')->create(); |
|
99 | 99 | $expected = \Aimeos\MShop\Cms\Item\Iface::class; |
100 | 100 | |
101 | - $this->stub->expects( $this->once() )->method( 'get' ) |
|
102 | - ->will( $this->returnValue( $item ) ); |
|
101 | + $this->stub->expects($this->once())->method('get') |
|
102 | + ->will($this->returnValue($item)); |
|
103 | 103 | |
104 | - $this->assertInstanceOf( $expected, $this->object->get( 1 ) ); |
|
104 | + $this->assertInstanceOf($expected, $this->object->get(1)); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | |
108 | 108 | public function testHas() |
109 | 109 | { |
110 | - $this->assertSame( $this->object, $this->object->has( 'product', 'default', -1 ) ); |
|
110 | + $this->assertSame($this->object, $this->object->has('product', 'default', -1)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
114 | 114 | public function testParse() |
115 | 115 | { |
116 | - $this->assertSame( $this->object, $this->object->parse( [] ) ); |
|
116 | + $this->assertSame($this->object, $this->object->parse([])); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | |
120 | 120 | public function testSearch() |
121 | 121 | { |
122 | - $item = \Aimeos\MShop::create( $this->context, 'cms' )->create(); |
|
122 | + $item = \Aimeos\MShop::create($this->context, 'cms')->create(); |
|
123 | 123 | |
124 | - $this->stub->expects( $this->once() )->method( 'search' ) |
|
125 | - ->will( $this->returnValue( map( [$item] ) ) ); |
|
124 | + $this->stub->expects($this->once())->method('search') |
|
125 | + ->will($this->returnValue(map([$item]))); |
|
126 | 126 | |
127 | - $this->assertEquals( [$item], $this->object->search()->toArray() ); |
|
127 | + $this->assertEquals([$item], $this->object->search()->toArray()); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | 131 | public function testSlice() |
132 | 132 | { |
133 | - $this->assertSame( $this->object, $this->object->slice( 0, 100 ) ); |
|
133 | + $this->assertSame($this->object, $this->object->slice(0, 100)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
137 | 137 | public function testSort() |
138 | 138 | { |
139 | - $this->assertSame( $this->object, $this->object->sort( 'cms.label' ) ); |
|
139 | + $this->assertSame($this->object, $this->object->sort('cms.label')); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | |
143 | 143 | public function testUses() |
144 | 144 | { |
145 | - $this->assertSame( $this->object, $this->object->uses( ['text'] ) ); |
|
145 | + $this->assertSame($this->object, $this->object->uses(['text'])); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
149 | 149 | public function testGetController() |
150 | 150 | { |
151 | - $result = $this->access( 'getController' )->invokeArgs( $this->object, [] ); |
|
151 | + $result = $this->access('getController')->invokeArgs($this->object, []); |
|
152 | 152 | |
153 | - $this->assertSame( $this->stub, $result ); |
|
153 | + $this->assertSame($this->stub, $result); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
157 | - protected function access( $name ) |
|
157 | + protected function access($name) |
|
158 | 158 | { |
159 | - $class = new \ReflectionClass( \Aimeos\Controller\Frontend\Cms\Decorator\Base::class ); |
|
160 | - $method = $class->getMethod( $name ); |
|
161 | - $method->setAccessible( true ); |
|
159 | + $class = new \ReflectionClass(\Aimeos\Controller\Frontend\Cms\Decorator\Base::class); |
|
160 | + $method = $class->getMethod($name); |
|
161 | + $method->setAccessible(true); |
|
162 | 162 | |
163 | 163 | return $method; |
164 | 164 | } |
@@ -18,104 +18,104 @@ |
||
18 | 18 | protected function setUp() : void |
19 | 19 | { |
20 | 20 | $this->context = \TestHelperFrontend::getContext(); |
21 | - $this->context->getLocale()->setLanguageId( 'en' ); |
|
21 | + $this->context->getLocale()->setLanguageId('en'); |
|
22 | 22 | |
23 | - $this->object = new \Aimeos\Controller\Frontend\Cms\Standard( $this->context ); |
|
23 | + $this->object = new \Aimeos\Controller\Frontend\Cms\Standard($this->context); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | |
27 | 27 | protected function tearDown() : void |
28 | 28 | { |
29 | - unset( $this->object, $this->context ); |
|
29 | + unset($this->object, $this->context); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | |
33 | 33 | public function testCompare() |
34 | 34 | { |
35 | - $this->assertEquals( 1, count( $this->object->compare( '=~', 'cms.label', 'Con' )->search() ) ); |
|
35 | + $this->assertEquals(1, count($this->object->compare('=~', 'cms.label', 'Con')->search())); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | public function testFind() |
40 | 40 | { |
41 | - $item = $this->object->uses( ['text'] )->find( '/contact' ); |
|
41 | + $item = $this->object->uses(['text'])->find('/contact'); |
|
42 | 42 | |
43 | - $this->assertInstanceOf( \Aimeos\MShop\Cms\Item\Iface::class, $item ); |
|
44 | - $this->assertEquals( 3, count( $item->getRefItems( 'text' ) ) ); |
|
43 | + $this->assertInstanceOf(\Aimeos\MShop\Cms\Item\Iface::class, $item); |
|
44 | + $this->assertEquals(3, count($item->getRefItems('text'))); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | |
48 | 48 | public function testFunction() |
49 | 49 | { |
50 | - $str = $this->object->function( 'cms:has', ['domain', 'type', 'refid'] ); |
|
51 | - $this->assertEquals( 'cms:has("domain","type","refid")', $str ); |
|
50 | + $str = $this->object->function('cms:has', ['domain', 'type', 'refid']); |
|
51 | + $this->assertEquals('cms:has("domain","type","refid")', $str); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function testGet() |
56 | 56 | { |
57 | - $item = \Aimeos\MShop::create( $this->context, 'cms' )->find( '/contact' ); |
|
58 | - $item = $this->object->uses( ['text'] )->get( $item->getId() ); |
|
57 | + $item = \Aimeos\MShop::create($this->context, 'cms')->find('/contact'); |
|
58 | + $item = $this->object->uses(['text'])->get($item->getId()); |
|
59 | 59 | |
60 | - $this->assertInstanceOf( \Aimeos\MShop\Cms\Item\Iface::class, $item ); |
|
61 | - $this->assertEquals( 3, count( $item->getRefItems( 'text' ) ) ); |
|
60 | + $this->assertInstanceOf(\Aimeos\MShop\Cms\Item\Iface::class, $item); |
|
61 | + $this->assertEquals(3, count($item->getRefItems('text'))); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | 65 | public function testHas() |
66 | 66 | { |
67 | - $manager = \Aimeos\MShop::create( $this->context, 'text' ); |
|
68 | - $textId = $manager->search( $manager->filter()->add( ['text.domain' => 'cms'] ) )->firstKey(); |
|
67 | + $manager = \Aimeos\MShop::create($this->context, 'text'); |
|
68 | + $textId = $manager->search($manager->filter()->add(['text.domain' => 'cms']))->firstKey(); |
|
69 | 69 | |
70 | - $this->assertEquals( 1, count( $this->object->has( 'text', 'default', $textId )->search() ) ); |
|
70 | + $this->assertEquals(1, count($this->object->has('text', 'default', $textId)->search())); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
74 | 74 | public function testParse() |
75 | 75 | { |
76 | 76 | $cond = ['&&' => [['==' => ['cms.status' => 1]], ['=~' => ['cms.label' => 'Con']]]]; |
77 | - $this->assertEquals( 1, count( $this->object->parse( $cond )->search() ) ); |
|
77 | + $this->assertEquals(1, count($this->object->parse($cond)->search())); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
81 | 81 | public function testSearch() |
82 | 82 | { |
83 | 83 | $total = 0; |
84 | - $items = $this->object->uses( ['text'] )->compare( '=~', 'cms.url', '/con' ) |
|
85 | - ->sort( 'cms.url' )->search( $total ); |
|
84 | + $items = $this->object->uses(['text'])->compare('=~', 'cms.url', '/con') |
|
85 | + ->sort('cms.url')->search($total); |
|
86 | 86 | |
87 | - $this->assertEquals( 1, count( $items ) ); |
|
88 | - $this->assertEquals( 1, $total ); |
|
89 | - $this->assertEquals( 3, count( $items->first()->getRefItems( 'text' ) ) ); |
|
87 | + $this->assertEquals(1, count($items)); |
|
88 | + $this->assertEquals(1, $total); |
|
89 | + $this->assertEquals(3, count($items->first()->getRefItems('text'))); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | |
93 | 93 | public function testSlice() |
94 | 94 | { |
95 | - $this->assertEquals( 1, count( $this->object->slice( 0, 1 )->search() ) ); |
|
95 | + $this->assertEquals(1, count($this->object->slice(0, 1)->search())); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
99 | 99 | public function testSort() |
100 | 100 | { |
101 | - $this->assertGreaterThanOrEqual( 1, count( $this->object->sort()->search() ) ); |
|
101 | + $this->assertGreaterThanOrEqual(1, count($this->object->sort()->search())); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
105 | 105 | public function testSortGeneric() |
106 | 106 | { |
107 | - $this->assertGreaterThanOrEqual( 1, count( $this->object->sort( 'cms.label' )->search() ) ); |
|
107 | + $this->assertGreaterThanOrEqual(1, count($this->object->sort('cms.label')->search())); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | |
111 | 111 | public function testSortMultiple() |
112 | 112 | { |
113 | - $this->assertGreaterThanOrEqual( 1, count( $this->object->sort( 'cms.label,-cms.id' )->search() ) ); |
|
113 | + $this->assertGreaterThanOrEqual(1, count($this->object->sort('cms.label,-cms.id')->search())); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
117 | 117 | public function testUses() |
118 | 118 | { |
119 | - $this->assertSame( $this->object, $this->object->uses( ['text'] ) ); |
|
119 | + $this->assertSame($this->object, $this->object->uses(['text'])); |
|
120 | 120 | } |
121 | 121 | } |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | * @return \Aimeos\Client\JsonApi\Iface JSON API client |
31 | 31 | * @throws \Aimeos\Client\JsonApi\Exception If requested client implementation couldn't be found or initialisation fails |
32 | 32 | */ |
33 | - public static function create( \Aimeos\MShop\Context\Item\Iface $context, string $path, string $name = null ) : \Aimeos\Client\JsonApi\Iface |
|
33 | + public static function create(\Aimeos\MShop\Context\Item\Iface $context, string $path, string $name = null) : \Aimeos\Client\JsonApi\Iface |
|
34 | 34 | { |
35 | - if( ctype_alnum( $path ) === false ) { |
|
36 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid client "%1$s"', $path ), 400 ); |
|
35 | + if (ctype_alnum($path) === false) { |
|
36 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid client "%1$s"', $path), 400); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** client/jsonapi/cms/name |
@@ -69,18 +69,18 @@ discard block |
||
69 | 69 | * @since 2017.03 |
70 | 70 | * @category Developer |
71 | 71 | */ |
72 | - if( $name === null ) { |
|
73 | - $name = $context->getConfig()->get( 'client/jsonapi/cms/name', 'Standard' ); |
|
72 | + if ($name === null) { |
|
73 | + $name = $context->getConfig()->get('client/jsonapi/cms/name', 'Standard'); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | $iface = '\\Aimeos\\Client\\JsonApi\\Iface'; |
77 | 77 | $classname = '\\Aimeos\\Client\\JsonApi\\Cms\\' . $name; |
78 | 78 | |
79 | - if( ctype_alnum( $name ) === false ) { |
|
80 | - throw new \Aimeos\Client\JsonApi\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
79 | + if (ctype_alnum($name) === false) { |
|
80 | + throw new \Aimeos\Client\JsonApi\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
81 | 81 | } |
82 | 82 | |
83 | - $client = self::createClient( $classname, $iface, $context, $path ); |
|
83 | + $client = self::createClient($classname, $iface, $context, $path); |
|
84 | 84 | |
85 | 85 | |
86 | 86 | /** client/jsonapi/cms/decorators/excludes |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * @see client/jsonapi/cms/decorators/global |
162 | 162 | */ |
163 | 163 | |
164 | - $client = self::addClientDecorators( $client, $context, $path ); |
|
164 | + $client = self::addClientDecorators($client, $context, $path); |
|
165 | 165 | |
166 | - return $client->setView( $context->getView() ); |
|
166 | + return $client->setView($context->getView()); |
|
167 | 167 | } |
168 | 168 | } |
@@ -31,29 +31,29 @@ discard block |
||
31 | 31 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
32 | 32 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
33 | 33 | */ |
34 | - public function get( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
|
34 | + public function get(ServerRequestInterface $request, ResponseInterface $response) : \Psr\Http\Message\ResponseInterface |
|
35 | 35 | { |
36 | 36 | $view = $this->getView(); |
37 | 37 | |
38 | 38 | try |
39 | 39 | { |
40 | - if( $view->param( 'id' ) != '' ) { |
|
41 | - $response = $this->getItem( $view, $request, $response ); |
|
40 | + if ($view->param('id') != '') { |
|
41 | + $response = $this->getItem($view, $request, $response); |
|
42 | 42 | } else { |
43 | - $response = $this->getItems( $view, $request, $response ); |
|
43 | + $response = $this->getItems($view, $request, $response); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | $status = 200; |
47 | 47 | } |
48 | - catch( \Aimeos\MShop\Exception $e ) |
|
48 | + catch (\Aimeos\MShop\Exception $e) |
|
49 | 49 | { |
50 | 50 | $status = 404; |
51 | - $view->errors = $this->getErrorDetails( $e, 'mshop' ); |
|
51 | + $view->errors = $this->getErrorDetails($e, 'mshop'); |
|
52 | 52 | } |
53 | - catch( \Exception $e ) |
|
53 | + catch (\Exception $e) |
|
54 | 54 | { |
55 | 55 | $status = $e->getCode() >= 100 && $e->getCode() < 600 ? $e->getCode() : 500; |
56 | - $view->errors = $this->getErrorDetails( $e ); |
|
56 | + $view->errors = $this->getErrorDetails($e); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** client/jsonapi/cms/template |
@@ -78,13 +78,13 @@ discard block |
||
78 | 78 | $tplconf = 'client/jsonapi/cms/template'; |
79 | 79 | $default = 'cms/standard'; |
80 | 80 | |
81 | - $body = $view->render( $view->config( $tplconf, $default ) ); |
|
81 | + $body = $view->render($view->config($tplconf, $default)); |
|
82 | 82 | |
83 | - return $response->withHeader( 'Allow', 'GET,OPTIONS' ) |
|
84 | - ->withHeader( 'Cache-Control', 'max-age=300' ) |
|
85 | - ->withHeader( 'Content-Type', 'application/vnd.api+json' ) |
|
86 | - ->withBody( $view->response()->createStreamFromString( $body ) ) |
|
87 | - ->withStatus( $status ); |
|
83 | + return $response->withHeader('Allow', 'GET,OPTIONS') |
|
84 | + ->withHeader('Cache-Control', 'max-age=300') |
|
85 | + ->withHeader('Content-Type', 'application/vnd.api+json') |
|
86 | + ->withBody($view->response()->createStreamFromString($body)) |
|
87 | + ->withStatus($status); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
@@ -95,9 +95,9 @@ discard block |
||
95 | 95 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
96 | 96 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
97 | 97 | */ |
98 | - public function options( ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
|
98 | + public function options(ServerRequestInterface $request, ResponseInterface $response) : \Psr\Http\Message\ResponseInterface |
|
99 | 99 | { |
100 | - return $this->getOptionsResponse( $request, $response, 'GET,OPTIONS' ); |
|
100 | + return $this->getOptionsResponse($request, $response, 'GET,OPTIONS'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -109,17 +109,17 @@ discard block |
||
109 | 109 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
110 | 110 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
111 | 111 | */ |
112 | - protected function getItem( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
|
112 | + protected function getItem(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) : \Psr\Http\Message\ResponseInterface |
|
113 | 113 | { |
114 | - $ref = $view->param( 'include', [] ); |
|
114 | + $ref = $view->param('include', []); |
|
115 | 115 | |
116 | - if( is_string( $ref ) ) { |
|
117 | - $ref = explode( ',', $ref ); |
|
116 | + if (is_string($ref)) { |
|
117 | + $ref = explode(',', $ref); |
|
118 | 118 | } |
119 | 119 | |
120 | - $cntl = \Aimeos\Controller\Frontend::create( $this->getContext(), 'cms' ); |
|
120 | + $cntl = \Aimeos\Controller\Frontend::create($this->getContext(), 'cms'); |
|
121 | 121 | |
122 | - $view->items = $cntl->uses( $ref )->get( $view->param( 'id' ) ); |
|
122 | + $view->items = $cntl->uses($ref)->get($view->param('id')); |
|
123 | 123 | $view->total = 1; |
124 | 124 | |
125 | 125 | return $response; |
@@ -134,19 +134,19 @@ discard block |
||
134 | 134 | * @param \Psr\Http\Message\ResponseInterface $response Response object |
135 | 135 | * @return \Psr\Http\Message\ResponseInterface Modified response object |
136 | 136 | */ |
137 | - protected function getItems( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response ) : \Psr\Http\Message\ResponseInterface |
|
137 | + protected function getItems(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request, ResponseInterface $response) : \Psr\Http\Message\ResponseInterface |
|
138 | 138 | { |
139 | 139 | $total = 0; |
140 | - $ref = $view->param( 'include', [] ); |
|
140 | + $ref = $view->param('include', []); |
|
141 | 141 | |
142 | - if( is_string( $ref ) ) { |
|
143 | - $ref = explode( ',', $ref ); |
|
142 | + if (is_string($ref)) { |
|
143 | + $ref = explode(',', $ref); |
|
144 | 144 | } |
145 | 145 | |
146 | - $cmss = \Aimeos\Controller\Frontend::create( $this->getContext(), 'cms' ) |
|
147 | - ->slice( $view->param( 'page/offset', 0 ), $view->param( 'page/limit', 25 ) ) |
|
148 | - ->sort( $view->param( 'sort' ) )->parse( $view->param( 'filter', [] ) ) |
|
149 | - ->uses( $ref )->search( $total ); |
|
146 | + $cmss = \Aimeos\Controller\Frontend::create($this->getContext(), 'cms') |
|
147 | + ->slice($view->param('page/offset', 0), $view->param('page/limit', 25)) |
|
148 | + ->sort($view->param('sort'))->parse($view->param('filter', [])) |
|
149 | + ->uses($ref)->search($total); |
|
150 | 150 | |
151 | 151 | $view->items = $cmss; |
152 | 152 | $view->total = $total; |
@@ -44,13 +44,11 @@ |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | $status = 200; |
47 | - } |
|
48 | - catch( \Aimeos\MShop\Exception $e ) |
|
47 | + } catch( \Aimeos\MShop\Exception $e ) |
|
49 | 48 | { |
50 | 49 | $status = 404; |
51 | 50 | $view->errors = $this->getErrorDetails( $e, 'mshop' ); |
52 | - } |
|
53 | - catch( \Exception $e ) |
|
51 | + } catch( \Exception $e ) |
|
54 | 52 | { |
55 | 53 | $status = $e->getCode() >= 100 && $e->getCode() < 600 ? $e->getCode() : 500; |
56 | 54 | $view->errors = $this->getErrorDetails( $e ); |
@@ -10,42 +10,42 @@ discard block |
||
10 | 10 | |
11 | 11 | $enc = $this->encoder(); |
12 | 12 | |
13 | -$target = $this->config( 'client/jsonapi/url/target' ); |
|
14 | -$cntl = $this->config( 'client/jsonapi/url/controller', 'jsonapi' ); |
|
15 | -$action = $this->config( 'client/jsonapi/url/action', 'get' ); |
|
16 | -$config = $this->config( 'client/jsonapi/url/config', [] ); |
|
13 | +$target = $this->config('client/jsonapi/url/target'); |
|
14 | +$cntl = $this->config('client/jsonapi/url/controller', 'jsonapi'); |
|
15 | +$action = $this->config('client/jsonapi/url/action', 'get'); |
|
16 | +$config = $this->config('client/jsonapi/url/config', []); |
|
17 | 17 | |
18 | 18 | |
19 | -$total = $this->get( 'total', 0 ); |
|
20 | -$offset = max( $this->param( 'page/offset', 0 ), 0 ); |
|
21 | -$limit = max( $this->param( 'page/limit', 100 ), 1 ); |
|
19 | +$total = $this->get('total', 0); |
|
20 | +$offset = max($this->param('page/offset', 0), 0); |
|
21 | +$limit = max($this->param('page/limit', 100), 1); |
|
22 | 22 | |
23 | -$first = ( $offset > 0 ? 0 : null ); |
|
24 | -$prev = ( $offset - $limit >= 0 ? $offset - $limit : null ); |
|
25 | -$next = ( $offset + $limit < $total ? $offset + $limit : null ); |
|
26 | -$last = ( ( (int) ( $total / $limit ) ) * $limit > $offset ? ( (int) ( $total / $limit ) ) * $limit : null ); |
|
23 | +$first = ($offset > 0 ? 0 : null); |
|
24 | +$prev = ($offset - $limit >= 0 ? $offset - $limit : null); |
|
25 | +$next = ($offset + $limit < $total ? $offset + $limit : null); |
|
26 | +$last = (((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null); |
|
27 | 27 | |
28 | 28 | |
29 | -$ref = array( 'resource', 'id', 'related', 'relatedid', 'filter', 'page', 'sort', 'include', 'fields' ); |
|
30 | -$params = array_intersect_key( $this->param(), array_flip( $ref ) ); |
|
29 | +$ref = array('resource', 'id', 'related', 'relatedid', 'filter', 'page', 'sort', 'include', 'fields'); |
|
30 | +$params = array_intersect_key($this->param(), array_flip($ref)); |
|
31 | 31 | |
32 | -$pretty = $this->param( 'pretty' ) ? JSON_PRETTY_PRINT : 0; |
|
33 | -$fields = $this->param( 'fields', [] ); |
|
32 | +$pretty = $this->param('pretty') ? JSON_PRETTY_PRINT : 0; |
|
33 | +$fields = $this->param('fields', []); |
|
34 | 34 | |
35 | -foreach( (array) $fields as $resource => $list ) { |
|
36 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
35 | +foreach ((array) $fields as $resource => $list) { |
|
36 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | |
40 | -$entryFcn = function( \Aimeos\MShop\Cms\Item\Iface $item ) use ( $fields, $target, $cntl, $action, $config ) |
|
40 | +$entryFcn = function(\Aimeos\MShop\Cms\Item\Iface $item) use ($fields, $target, $cntl, $action, $config) |
|
41 | 41 | { |
42 | 42 | $id = $item->getId(); |
43 | 43 | $type = $item->getResourceType(); |
44 | - $params = array( 'resource' => $type, 'id' => $id ); |
|
44 | + $params = array('resource' => $type, 'id' => $id); |
|
45 | 45 | $attributes = $item->toArray(); |
46 | 46 | |
47 | - if( isset( $fields[$type] ) ) { |
|
48 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
47 | + if (isset($fields[$type])) { |
|
48 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | $entry = array( |
@@ -53,26 +53,26 @@ discard block |
||
53 | 53 | 'type' => $type, |
54 | 54 | 'links' => array( |
55 | 55 | 'self' => array( |
56 | - 'href' => $this->url( $target, $cntl, $action, $params, [], $config ), |
|
57 | - 'allow' => array( 'GET' ), |
|
56 | + 'href' => $this->url($target, $cntl, $action, $params, [], $config), |
|
57 | + 'allow' => array('GET'), |
|
58 | 58 | ), |
59 | 59 | ), |
60 | 60 | 'attributes' => $attributes, |
61 | 61 | ); |
62 | 62 | |
63 | - foreach( $item->getListItems() as $listItem ) |
|
63 | + foreach ($item->getListItems() as $listItem) |
|
64 | 64 | { |
65 | - if( ( $refItem = $listItem->getRefItem() ) !== null && $refItem->isAvailable() ) |
|
65 | + if (($refItem = $listItem->getRefItem()) !== null && $refItem->isAvailable()) |
|
66 | 66 | { |
67 | 67 | $ltype = $listItem->getResourceType(); |
68 | 68 | $type = $refItem->getResourceType(); |
69 | 69 | $attributes = $listItem->toArray(); |
70 | 70 | |
71 | - if( isset( $fields[$ltype] ) ) { |
|
72 | - $attributes = array_intersect_key( $attributes, $fields[$ltype] ); |
|
71 | + if (isset($fields[$ltype])) { |
|
72 | + $attributes = array_intersect_key($attributes, $fields[$ltype]); |
|
73 | 73 | } |
74 | 74 | |
75 | - $data = array( 'id' => $refItem->getId(), 'type' => $type, 'attributes' => $attributes ); |
|
75 | + $data = array('id' => $refItem->getId(), 'type' => $type, 'attributes' => $attributes); |
|
76 | 76 | $entry['relationships'][$type]['data'][] = $data; |
77 | 77 | } |
78 | 78 | } |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | { |
86 | 86 | "meta": { |
87 | 87 | "total": <?= $total; ?>, |
88 | - "prefix": <?= json_encode( $this->get( 'prefix' ) ); ?>, |
|
89 | - "content-baseurl": "<?= $this->config( 'resource/fs/baseurl' ); ?>" |
|
90 | - <?php if( $this->csrf()->name() != '' ) : ?> |
|
88 | + "prefix": <?= json_encode($this->get('prefix')); ?>, |
|
89 | + "content-baseurl": "<?= $this->config('resource/fs/baseurl'); ?>" |
|
90 | + <?php if ($this->csrf()->name() != '') : ?> |
|
91 | 91 | , "csrf": { |
92 | 92 | "name": "<?= $this->csrf()->name(); ?>", |
93 | 93 | "value": "<?= $this->csrf()->value(); ?>" |
@@ -96,46 +96,46 @@ discard block |
||
96 | 96 | |
97 | 97 | }, |
98 | 98 | "links": { |
99 | - <?php if( is_map( $this->get( 'items' ) ) ) : ?> |
|
100 | - <?php if( $first !== null ) : ?> |
|
101 | - "first": "<?php $params['page']['offset'] = $first; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
99 | + <?php if (is_map($this->get('items'))) : ?> |
|
100 | + <?php if ($first !== null) : ?> |
|
101 | + "first": "<?php $params['page']['offset'] = $first; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
102 | 102 | <?php endif; ?> |
103 | - <?php if( $prev !== null ) : ?> |
|
104 | - "prev": "<?php $params['page']['offset'] = $prev; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
103 | + <?php if ($prev !== null) : ?> |
|
104 | + "prev": "<?php $params['page']['offset'] = $prev; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
105 | 105 | <?php endif; ?> |
106 | - <?php if( $next !== null ) : ?> |
|
107 | - "next": "<?php $params['page']['offset'] = $next; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
106 | + <?php if ($next !== null) : ?> |
|
107 | + "next": "<?php $params['page']['offset'] = $next; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
108 | 108 | <?php endif; ?> |
109 | - <?php if( $last !== null ) : ?> |
|
110 | - "last": "<?php $params['page']['offset'] = $last; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>", |
|
109 | + <?php if ($last !== null) : ?> |
|
110 | + "last": "<?php $params['page']['offset'] = $last; echo $this->url($target, $cntl, $action, $params, [], $config); ?>", |
|
111 | 111 | <?php endif; ?> |
112 | 112 | <?php endif; ?> |
113 | - "self": "<?php $params['page']['offset'] = $offset; echo $this->url( $target, $cntl, $action, $params, [], $config ); ?>" |
|
113 | + "self": "<?php $params['page']['offset'] = $offset; echo $this->url($target, $cntl, $action, $params, [], $config); ?>" |
|
114 | 114 | } |
115 | - <?php if( isset( $this->errors ) ) : ?> |
|
116 | - ,"errors": <?= json_encode( $this->errors, $pretty ); ?> |
|
115 | + <?php if (isset($this->errors)) : ?> |
|
116 | + ,"errors": <?= json_encode($this->errors, $pretty); ?> |
|
117 | 117 | |
118 | - <?php elseif( isset( $this->items ) ) : ?> |
|
118 | + <?php elseif (isset($this->items)) : ?> |
|
119 | 119 | <?php |
120 | 120 | $data = []; |
121 | - $items = $this->get( 'items', map() ); |
|
122 | - $included = $this->jincluded( $items, $fields ); |
|
121 | + $items = $this->get('items', map()); |
|
122 | + $included = $this->jincluded($items, $fields); |
|
123 | 123 | |
124 | - if( is_map( $items ) ) |
|
124 | + if (is_map($items)) |
|
125 | 125 | { |
126 | - foreach( $items as $item ) { |
|
127 | - $data[] = $entryFcn( $item ); |
|
126 | + foreach ($items as $item) { |
|
127 | + $data[] = $entryFcn($item); |
|
128 | 128 | } |
129 | 129 | } |
130 | 130 | else |
131 | 131 | { |
132 | - $data = $entryFcn( $items ); |
|
132 | + $data = $entryFcn($items); |
|
133 | 133 | } |
134 | 134 | ?> |
135 | 135 | |
136 | - ,"data": <?= json_encode( $data, $pretty ); ?> |
|
136 | + ,"data": <?= json_encode($data, $pretty); ?> |
|
137 | 137 | |
138 | - ,"included": <?= map( $included )->flat( 1 )->toJson( $pretty ) ?> |
|
138 | + ,"included": <?= map($included)->flat(1)->toJson($pretty) ?> |
|
139 | 139 | |
140 | 140 | <?php endif; ?> |
141 | 141 |
@@ -126,8 +126,7 @@ |
||
126 | 126 | foreach( $items as $item ) { |
127 | 127 | $data[] = $entryFcn( $item ); |
128 | 128 | } |
129 | - } |
|
130 | - else |
|
129 | + } else |
|
131 | 130 | { |
132 | 131 | $data = $entryFcn( $items ); |
133 | 132 | } |
@@ -15,8 +15,8 @@ discard block |
||
15 | 15 | { |
16 | 16 | $context = \TestHelperJapi::getContext(); |
17 | 17 | |
18 | - $client = \Aimeos\Client\JsonApi\Cms\Factory::create( $context, 'cms' ); |
|
19 | - $this->assertInstanceOf( \Aimeos\Client\JsonApi\Iface::class, $client ); |
|
18 | + $client = \Aimeos\Client\JsonApi\Cms\Factory::create($context, 'cms'); |
|
19 | + $this->assertInstanceOf(\Aimeos\Client\JsonApi\Iface::class, $client); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -24,8 +24,8 @@ discard block |
||
24 | 24 | { |
25 | 25 | $context = \TestHelperJapi::getContext(); |
26 | 26 | |
27 | - $this->expectException( \Aimeos\Client\JsonApi\Exception::class ); |
|
28 | - \Aimeos\Client\JsonApi\Cms\Factory::create( $context, '' ); |
|
27 | + $this->expectException(\Aimeos\Client\JsonApi\Exception::class); |
|
28 | + \Aimeos\Client\JsonApi\Cms\Factory::create($context, ''); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | { |
34 | 34 | $context = \TestHelperJapi::getContext(); |
35 | 35 | |
36 | - $this->expectException( \Aimeos\Client\JsonApi\Exception::class ); |
|
37 | - \Aimeos\Client\JsonApi\Cms\Factory::create( $context, '%^' ); |
|
36 | + $this->expectException(\Aimeos\Client\JsonApi\Exception::class); |
|
37 | + \Aimeos\Client\JsonApi\Cms\Factory::create($context, '%^'); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $context = \TestHelperJapi::getContext(); |
44 | 44 | |
45 | - $this->expectException( \Aimeos\Client\JsonApi\Exception::class ); |
|
46 | - \Aimeos\Client\JsonApi\Cms\Factory::create( $context, 'cms', '%^' ); |
|
45 | + $this->expectException(\Aimeos\Client\JsonApi\Exception::class); |
|
46 | + \Aimeos\Client\JsonApi\Cms\Factory::create($context, 'cms', '%^'); |
|
47 | 47 | } |
48 | 48 | } |
@@ -19,18 +19,18 @@ discard block |
||
19 | 19 | protected function setUp() : void |
20 | 20 | { |
21 | 21 | $this->context = \TestHelperJapi::getContext(); |
22 | - $this->context->getLocale()->setLanguageId( 'en' ); |
|
22 | + $this->context->getLocale()->setLanguageId('en'); |
|
23 | 23 | $this->view = $this->context->getView(); |
24 | 24 | |
25 | - $this->object = new \Aimeos\Client\JsonApi\Cms\Standard( $this->context, 'cms' ); |
|
26 | - $this->object->setView( $this->view ); |
|
25 | + $this->object = new \Aimeos\Client\JsonApi\Cms\Standard($this->context, 'cms'); |
|
26 | + $this->object->setView($this->view); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
30 | 30 | public function testGetItem() |
31 | 31 | { |
32 | - $manager = \Aimeos\MShop::create( $this->context, 'cms' ); |
|
33 | - $pageId = $manager->find( '/contact' )->getId(); |
|
32 | + $manager = \Aimeos\MShop::create($this->context, 'cms'); |
|
33 | + $pageId = $manager->find('/contact')->getId(); |
|
34 | 34 | |
35 | 35 | $params = array( |
36 | 36 | 'id' => $pageId, |
@@ -41,22 +41,22 @@ discard block |
||
41 | 41 | 'include' => 'text' |
42 | 42 | ); |
43 | 43 | |
44 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
45 | - $this->view->addHelper( 'param', $helper ); |
|
44 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
45 | + $this->view->addHelper('param', $helper); |
|
46 | 46 | |
47 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
48 | - $result = json_decode( (string) $response->getBody(), true ); |
|
47 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
48 | + $result = json_decode((string) $response->getBody(), true); |
|
49 | 49 | |
50 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
51 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
52 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
50 | + $this->assertEquals(200, $response->getStatusCode()); |
|
51 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
52 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
53 | 53 | |
54 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
55 | - $this->assertEquals( 'cms', $result['data']['type'] ); |
|
56 | - $this->assertEquals( 3, count( $result['data']['relationships']['text']['data'] ) ); |
|
57 | - $this->assertEquals( 3, count( $result['included'] ) ); |
|
54 | + $this->assertEquals(1, $result['meta']['total']); |
|
55 | + $this->assertEquals('cms', $result['data']['type']); |
|
56 | + $this->assertEquals(3, count($result['data']['relationships']['text']['data'])); |
|
57 | + $this->assertEquals(3, count($result['included'])); |
|
58 | 58 | |
59 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
59 | + $this->assertArrayNotHasKey('errors', $result); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | { |
65 | 65 | $params = array( |
66 | 66 | 'filter' => array( |
67 | - '=~' => array( 'cms.url' => '/cont' ), |
|
67 | + '=~' => array('cms.url' => '/cont'), |
|
68 | 68 | ), |
69 | 69 | 'fields' => array( |
70 | 70 | 'cms' => 'cms.id,cms.label,cms.url' |
@@ -72,23 +72,23 @@ discard block |
||
72 | 72 | 'include' => 'text', |
73 | 73 | 'sort' => 'cms.label,-cms.id', |
74 | 74 | ); |
75 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
76 | - $this->view->addHelper( 'param', $helper ); |
|
75 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
76 | + $this->view->addHelper('param', $helper); |
|
77 | 77 | |
78 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
79 | - $result = json_decode( (string) $response->getBody(), true ); |
|
78 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
79 | + $result = json_decode((string) $response->getBody(), true); |
|
80 | 80 | |
81 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
82 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
83 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
81 | + $this->assertEquals(200, $response->getStatusCode()); |
|
82 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
83 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
84 | 84 | |
85 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
86 | - $this->assertEquals( 1, count( $result['data'] ) ); |
|
87 | - $this->assertEquals( 'cms', $result['data'][0]['type'] ); |
|
88 | - $this->assertEquals( 3, count( $result['data'][0]['attributes'] ) ); |
|
89 | - $this->assertEquals( 3, count( $result['included'] ) ); |
|
85 | + $this->assertEquals(1, $result['meta']['total']); |
|
86 | + $this->assertEquals(1, count($result['data'])); |
|
87 | + $this->assertEquals('cms', $result['data'][0]['type']); |
|
88 | + $this->assertEquals(3, count($result['data'][0]['attributes'])); |
|
89 | + $this->assertEquals(3, count($result['included'])); |
|
90 | 90 | |
91 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
91 | + $this->assertArrayNotHasKey('errors', $result); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -96,78 +96,78 @@ discard block |
||
96 | 96 | { |
97 | 97 | $params = array( |
98 | 98 | 'filter' => array( |
99 | - '=~' => array( 'cms.url' => '/contact' ), |
|
99 | + '=~' => array('cms.url' => '/contact'), |
|
100 | 100 | ), |
101 | 101 | 'sort' => 'cms.label', |
102 | 102 | ); |
103 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $this->view, $params ); |
|
104 | - $this->view->addHelper( 'param', $helper ); |
|
103 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($this->view, $params); |
|
104 | + $this->view->addHelper('param', $helper); |
|
105 | 105 | |
106 | - $response = $this->object->get( $this->view->request(), $this->view->response() ); |
|
107 | - $result = json_decode( (string) $response->getBody(), true ); |
|
106 | + $response = $this->object->get($this->view->request(), $this->view->response()); |
|
107 | + $result = json_decode((string) $response->getBody(), true); |
|
108 | 108 | |
109 | 109 | |
110 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
111 | - $this->assertEquals( 1, $result['meta']['total'] ); |
|
112 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
110 | + $this->assertEquals(200, $response->getStatusCode()); |
|
111 | + $this->assertEquals(1, $result['meta']['total']); |
|
112 | + $this->assertArrayNotHasKey('errors', $result); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | 116 | public function testGetMShopException() |
117 | 117 | { |
118 | - $object = $this->getMockBuilder( \Aimeos\Client\JsonApi\Cms\Standard::class ) |
|
119 | - ->setConstructorArgs( [$this->context, 'cms'] ) |
|
120 | - ->setMethods( ['getItems'] ) |
|
118 | + $object = $this->getMockBuilder(\Aimeos\Client\JsonApi\Cms\Standard::class) |
|
119 | + ->setConstructorArgs([$this->context, 'cms']) |
|
120 | + ->setMethods(['getItems']) |
|
121 | 121 | ->getMock(); |
122 | 122 | |
123 | - $object->expects( $this->once() )->method( 'getItems' ) |
|
124 | - ->will( $this->throwException( new \Aimeos\MShop\Exception() ) ); |
|
123 | + $object->expects($this->once())->method('getItems') |
|
124 | + ->will($this->throwException(new \Aimeos\MShop\Exception())); |
|
125 | 125 | |
126 | - $object->setView( $this->view ); |
|
126 | + $object->setView($this->view); |
|
127 | 127 | |
128 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
129 | - $result = json_decode( (string) $response->getBody(), true ); |
|
128 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
129 | + $result = json_decode((string) $response->getBody(), true); |
|
130 | 130 | |
131 | 131 | |
132 | - $this->assertEquals( 404, $response->getStatusCode() ); |
|
133 | - $this->assertArrayHasKey( 'errors', $result ); |
|
132 | + $this->assertEquals(404, $response->getStatusCode()); |
|
133 | + $this->assertArrayHasKey('errors', $result); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | |
137 | 137 | public function testGetException() |
138 | 138 | { |
139 | - $object = $this->getMockBuilder( \Aimeos\Client\JsonApi\Cms\Standard::class ) |
|
140 | - ->setConstructorArgs( [$this->context, 'cms'] ) |
|
141 | - ->setMethods( ['getItems'] ) |
|
139 | + $object = $this->getMockBuilder(\Aimeos\Client\JsonApi\Cms\Standard::class) |
|
140 | + ->setConstructorArgs([$this->context, 'cms']) |
|
141 | + ->setMethods(['getItems']) |
|
142 | 142 | ->getMock(); |
143 | 143 | |
144 | - $object->expects( $this->once() )->method( 'getItems' ) |
|
145 | - ->will( $this->throwException( new \Exception() ) ); |
|
144 | + $object->expects($this->once())->method('getItems') |
|
145 | + ->will($this->throwException(new \Exception())); |
|
146 | 146 | |
147 | - $object->setView( $this->view ); |
|
147 | + $object->setView($this->view); |
|
148 | 148 | |
149 | - $response = $object->get( $this->view->request(), $this->view->response() ); |
|
150 | - $result = json_decode( (string) $response->getBody(), true ); |
|
149 | + $response = $object->get($this->view->request(), $this->view->response()); |
|
150 | + $result = json_decode((string) $response->getBody(), true); |
|
151 | 151 | |
152 | 152 | |
153 | - $this->assertEquals( 500, $response->getStatusCode() ); |
|
154 | - $this->assertArrayHasKey( 'errors', $result ); |
|
153 | + $this->assertEquals(500, $response->getStatusCode()); |
|
154 | + $this->assertArrayHasKey('errors', $result); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | |
158 | 158 | public function testOptions() |
159 | 159 | { |
160 | - $response = $this->object->options( $this->view->request(), $this->view->response() ); |
|
161 | - $result = json_decode( (string) $response->getBody(), true ); |
|
162 | - |
|
163 | - $this->assertEquals( 200, $response->getStatusCode() ); |
|
164 | - $this->assertEquals( 1, count( $response->getHeader( 'Allow' ) ) ); |
|
165 | - $this->assertEquals( 1, count( $response->getHeader( 'Content-Type' ) ) ); |
|
166 | - |
|
167 | - $this->assertEquals( null, $result['meta']['prefix'] ); |
|
168 | - $this->assertArrayNotHasKey( 'attributes', $result['meta'] ); |
|
169 | - $this->assertArrayNotHasKey( 'filter', $result['meta'] ); |
|
170 | - $this->assertArrayNotHasKey( 'sort', $result['meta'] ); |
|
171 | - $this->assertArrayNotHasKey( 'errors', $result ); |
|
160 | + $response = $this->object->options($this->view->request(), $this->view->response()); |
|
161 | + $result = json_decode((string) $response->getBody(), true); |
|
162 | + |
|
163 | + $this->assertEquals(200, $response->getStatusCode()); |
|
164 | + $this->assertEquals(1, count($response->getHeader('Allow'))); |
|
165 | + $this->assertEquals(1, count($response->getHeader('Content-Type'))); |
|
166 | + |
|
167 | + $this->assertEquals(null, $result['meta']['prefix']); |
|
168 | + $this->assertArrayNotHasKey('attributes', $result['meta']); |
|
169 | + $this->assertArrayNotHasKey('filter', $result['meta']); |
|
170 | + $this->assertArrayNotHasKey('sort', $result['meta']); |
|
171 | + $this->assertArrayNotHasKey('errors', $result); |
|
172 | 172 | } |
173 | 173 | } |
@@ -13,16 +13,16 @@ discard block |
||
13 | 13 | |
14 | 14 | $includepaths = $aimeos->getIncludePaths(); |
15 | 15 | $includepaths[] = get_include_path(); |
16 | - set_include_path( implode( PATH_SEPARATOR, $includepaths ) ); |
|
16 | + set_include_path(implode(PATH_SEPARATOR, $includepaths)); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | |
20 | 20 | private static function getAimeos() |
21 | 21 | { |
22 | - if( !isset( self::$aimeos ) ) |
|
22 | + if (!isset(self::$aimeos)) |
|
23 | 23 | { |
24 | 24 | require_once 'Bootstrap.php'; |
25 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
25 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
26 | 26 | |
27 | 27 | self::$aimeos = new \Aimeos\Bootstrap(); |
28 | 28 | } |
@@ -31,43 +31,43 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | |
34 | - public static function getContext( $site = 'unittest' ) |
|
34 | + public static function getContext($site = 'unittest') |
|
35 | 35 | { |
36 | - if( !isset( self::$context[$site] ) ) { |
|
37 | - self::$context[$site] = self::createContext( $site ); |
|
38 | - self::$context[$site]->setView( self::getView( self::$context[$site]->getConfig() ) ); |
|
36 | + if (!isset(self::$context[$site])) { |
|
37 | + self::$context[$site] = self::createContext($site); |
|
38 | + self::$context[$site]->setView(self::getView(self::$context[$site]->getConfig())); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return clone self::$context[$site]; |
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - public static function getView( \Aimeos\MW\Config\Iface $config ) |
|
45 | + public static function getView(\Aimeos\MW\Config\Iface $config) |
|
46 | 46 | { |
47 | - $view = new \Aimeos\MW\View\Standard( self::getTemplatePaths() ); |
|
47 | + $view = new \Aimeos\MW\View\Standard(self::getTemplatePaths()); |
|
48 | 48 | |
49 | - $trans = new \Aimeos\MW\Translation\None( 'en' ); |
|
50 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $trans ); |
|
51 | - $view->addHelper( 'translate', $helper ); |
|
49 | + $trans = new \Aimeos\MW\Translation\None('en'); |
|
50 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $trans); |
|
51 | + $view->addHelper('translate', $helper); |
|
52 | 52 | |
53 | - $helper = new \Aimeos\MW\View\Helper\Url\Standard( $view, 'baseurl' ); |
|
54 | - $view->addHelper( 'url', $helper ); |
|
53 | + $helper = new \Aimeos\MW\View\Helper\Url\Standard($view, 'baseurl'); |
|
54 | + $view->addHelper('url', $helper); |
|
55 | 55 | |
56 | - $helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, '.', '' ); |
|
57 | - $view->addHelper( 'number', $helper ); |
|
56 | + $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, '.', ''); |
|
57 | + $view->addHelper('number', $helper); |
|
58 | 58 | |
59 | - $helper = new \Aimeos\MW\View\Helper\Date\Standard( $view, 'Y-m-d' ); |
|
60 | - $view->addHelper( 'date', $helper ); |
|
59 | + $helper = new \Aimeos\MW\View\Helper\Date\Standard($view, 'Y-m-d'); |
|
60 | + $view->addHelper('date', $helper); |
|
61 | 61 | |
62 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
63 | - $view->addHelper( 'config', $helper ); |
|
62 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config); |
|
63 | + $view->addHelper('config', $helper); |
|
64 | 64 | |
65 | 65 | $psr17Factory = new \Nyholm\Psr7\Factory\Psr17Factory(); |
66 | - $helper = new \Aimeos\MW\View\Helper\Request\Standard( $view, $psr17Factory->createServerRequest( 'GET', 'https://aimeos.org' ) ); |
|
67 | - $view->addHelper( 'request', $helper ); |
|
66 | + $helper = new \Aimeos\MW\View\Helper\Request\Standard($view, $psr17Factory->createServerRequest('GET', 'https://aimeos.org')); |
|
67 | + $view->addHelper('request', $helper); |
|
68 | 68 | |
69 | - $helper = new \Aimeos\MW\View\Helper\Response\Standard( $view, $psr17Factory->createResponse() ); |
|
70 | - $view->addHelper( 'response', $helper ); |
|
69 | + $helper = new \Aimeos\MW\View\Helper\Response\Standard($view, $psr17Factory->createResponse()); |
|
70 | + $view->addHelper('response', $helper); |
|
71 | 71 | |
72 | 72 | return $view; |
73 | 73 | } |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | |
76 | 76 | public static function getTemplatePaths() |
77 | 77 | { |
78 | - return self::getAimeos()->getCustomPaths( 'client/jsonapi/templates' ); |
|
78 | + return self::getAimeos()->getCustomPaths('client/jsonapi/templates'); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
82 | - private static function createContext( $site ) |
|
82 | + private static function createContext($site) |
|
83 | 83 | { |
84 | 84 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
85 | 85 | $aimeos = self::getAimeos(); |
@@ -88,36 +88,36 @@ discard block |
||
88 | 88 | $paths = $aimeos->getConfigPaths(); |
89 | 89 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
90 | 90 | |
91 | - $conf = new \Aimeos\MW\Config\PHPArray( array(), $paths ); |
|
92 | - $ctx->setConfig( $conf ); |
|
91 | + $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths); |
|
92 | + $ctx->setConfig($conf); |
|
93 | 93 | |
94 | 94 | |
95 | - $dbm = new \Aimeos\MW\DB\Manager\DBAL( $conf ); |
|
96 | - $ctx->setDatabaseManager( $dbm ); |
|
95 | + $dbm = new \Aimeos\MW\DB\Manager\DBAL($conf); |
|
96 | + $ctx->setDatabaseManager($dbm); |
|
97 | 97 | |
98 | 98 | |
99 | - $logger = new \Aimeos\MW\Logger\File( $site . '.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
100 | - $ctx->setLogger( $logger ); |
|
99 | + $logger = new \Aimeos\MW\Logger\File($site . '.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
100 | + $ctx->setLogger($logger); |
|
101 | 101 | |
102 | 102 | |
103 | 103 | $cache = new \Aimeos\MW\Cache\None(); |
104 | - $ctx->setCache( $cache ); |
|
104 | + $ctx->setCache($cache); |
|
105 | 105 | |
106 | 106 | |
107 | - $i18n = new \Aimeos\MW\Translation\None( 'en' ); |
|
108 | - $ctx->setI18n( array( 'en' => $i18n ) ); |
|
107 | + $i18n = new \Aimeos\MW\Translation\None('en'); |
|
108 | + $ctx->setI18n(array('en' => $i18n)); |
|
109 | 109 | |
110 | 110 | |
111 | 111 | $session = new \Aimeos\MW\Session\None(); |
112 | - $ctx->setSession( $session ); |
|
112 | + $ctx->setSession($session); |
|
113 | 113 | |
114 | 114 | |
115 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create( $ctx ); |
|
116 | - $locale = $localeManager->bootstrap( $site, '', '', false ); |
|
117 | - $ctx->setLocale( $locale ); |
|
115 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::create($ctx); |
|
116 | + $locale = $localeManager->bootstrap($site, '', '', false); |
|
117 | + $ctx->setLocale($locale); |
|
118 | 118 | |
119 | 119 | |
120 | - $ctx->setEditor( 'ai-cms-grapesjs:client/jsonapi' ); |
|
120 | + $ctx->setEditor('ai-cms-grapesjs:client/jsonapi'); |
|
121 | 121 | |
122 | 122 | return $ctx; |
123 | 123 | } |