Skip to content

Commit 7233e2a

Browse files
committed
Test repair and documentation styling upgrades
1 parent 7ada616 commit 7233e2a

File tree

6 files changed

+180
-188
lines changed

6 files changed

+180
-188
lines changed

README.md

Lines changed: 23 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,29 @@ If you're looking for bundle for older version of Symfony, please use [version 3
88

99
1. Add Composer dependency and install the bundle.
1010

11-
```bash
12-
composer require ckfinder/ckfinder-symfony-bundle
13-
```
14-
15-
2. Enable the bundle in `AppKernel.php`.
11+
```bash
12+
composer require ckfinder/ckfinder-symfony-bundle
13+
```
1614

17-
**Note:** This step is required only for Symfony 3. If you use Symfony 4+
18-
the bundle will be registered automatically.
15+
2. Run the command to download the CKFinder distribution package.
1916

20-
``` php
21-
// app/AppKernel.php
22-
23-
public function registerBundles()
24-
{
25-
$bundles = [
26-
// ...
27-
new CKSource\Bundle\CKFinderBundle\CKSourceCKFinderBundle(),
28-
];
29-
}
30-
```
31-
32-
3. Run the command to download the CKFinder distribution package.
33-
34-
After installing the bundle you need to download CKFinder distribution package. It is not shipped
35-
with the bundle due to different license terms. To install it, run the following Symfony command:
17+
After installing the bundle you need to download CKFinder distribution package. It is not shipped
18+
with the bundle due to different license terms. To install it, run the following Symfony command:
3619

37-
```bash
38-
php bin/console ckfinder:download
39-
```
20+
```bash
21+
php bin/console ckfinder:download
22+
```
4023

41-
It will download the code and place it in the `Resource/public` directory of the bundle. After that you may also want to install
42-
assets, so the public directory will be updated with CKFinder code.
24+
It will download the code and place it in the `Resource/public` directory of the bundle. After that you may also want to install
25+
assets, so the public directory will be updated with CKFinder code.
4326

44-
```bash
45-
php bin/console assets:install
46-
```
27+
```bash
28+
php bin/console assets:install
29+
```
4730

48-
4. Enable bundle routing.
31+
3. Enable bundle routing.
4932

50-
Create `config/routes/ckfinder.yaml` with following contents:
33+
Create `config/routes/ckfinder.yaml` with following contents:
5134

5235
```yaml
5336
# config/routes/ckfinder.yaml
@@ -58,14 +41,14 @@ If you're looking for bundle for older version of Symfony, please use [version 3
5841
```
5942

6043

61-
5. Create a directory for CKFinder files and allow for write access to it. By default CKFinder expects it to be placed in `<public folder>/userfiles` (this can be altered in configuration).
62-
44+
4. Create a directory for CKFinder files and allow for write access to it. By default CKFinder expects it to be placed in `<public folder>/userfiles` (this can be altered in configuration).
45+
6346
```bash
64-
mkdir -m 777 public/userfiles
65-
```
66-
47+
mkdir -m 777 public/userfiles
48+
```
49+
50+
**NOTE:** Since usually setting permissions to 0777 is insecure, it is advisable to change the group ownership of the directory to the same user as Apache and add group write permissions instead. Please contact your system administrator in case of any doubts.
6751

68-
**NOTE:** Since usually setting permissions to 0777 is insecure, it is advisable to change the group ownership of the directory to the same user as Apache and add group write permissions instead. Please contact your system administrator in case of any doubts.
6952

7053
At this point you should see the connector JSON response after navigating to the `/ckfinder/connector?command=Init` route.
7154
Authentication for CKFinder is not configured yet, so you will see an error response saying that CKFinder is not enabled.
@@ -91,7 +74,7 @@ use CKSource\Bundle\CKFinderBundle\Authentication\Authentication as Authenticati
9174
9275
class CustomCKFinderAuth extends AuthenticationBase
9376
{
94-
public function authenticate()
77+
public function authenticate(): bool
9578
{
9679
return true;
9780
}

Resources/config/ckfinder_config.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,22 +73,11 @@
7373
'root' => '%kernel.logs_dir%'
7474
);
7575

76-
//For Symfony 3
77-
$root = '%kernel.root_dir%/../web/userfiles';
78-
if (\Symfony\Component\HttpKernel\Kernel::MAJOR_VERSION >= 4) {
79-
//For Symfony 4
80-
$root = '%kernel.root_dir%/../public/userfiles';
81-
}
82-
if (\Symfony\Component\HttpKernel\Kernel::MAJOR_VERSION >= 5) {
83-
//For Symfony 5
84-
$root = '%kernel.project_dir%/public/userfiles';
85-
}
86-
8776
$config['backends']['default'] = array(
8877
'name' => 'default',
8978
'adapter' => 'local',
9079
'baseUrl' => '/userfiles/',
91-
'root' => $root,
80+
'root' => '%kernel.project_dir%/public/userfiles',
9281
'chmodFiles' => 0777,
9382
'chmodFolders' => 0755,
9483
'filesystemEncoding' => 'UTF-8',

Tests/Config/Definition/VariableArrayNodeTest.php

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,29 @@
1313

1414
use CKSource\Bundle\CKFinderBundle\Config\Definition\VariableArrayNode;
1515
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16+
use PHPUnit\Framework\TestCase;
17+
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
18+
use Symfony\Component\Config\Definition\Exception\InvalidTypeException;
1619

1720
/**
1821
* ExtraValuesArrayNode test.
1922
*/
20-
class VariableArrayNodeTest extends \PHPUnit_Framework_TestCase
23+
class VariableArrayNodeTest extends TestCase
2124
{
2225
/**
23-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidTypeException
26+
* Test node if value is not an array
2427
*/
25-
public function testNormalizeThrowsExceptionIfValueIsNotArray()
28+
public function testNormalizeThrowsExceptionIfValueIsNotArray(): void
2629
{
2730
$node = new VariableArrayNode('root');
31+
$this->expectException(InvalidTypeException::class);
2832
$node->normalize('foo');
2933
}
3034

3135
/**
3236
* Test merging
3337
*/
34-
public function testMerge()
38+
public function testMerge(): void
3539
{
3640
if (method_exists(TreeBuilder::class, 'getRootNode')) {
3741
$builder = new TreeBuilder('root');
@@ -51,40 +55,40 @@ public function testMerge()
5155
->end()
5256
->buildTree();
5357

54-
$a = array(
58+
$a = [
5559
'foo' => 'bar',
56-
'extra' => array(
60+
'extra' => [
5761
'foo' => 'a',
5862
'bar' => 'b'
59-
)
60-
);
63+
]
64+
];
6165

62-
$b = array(
66+
$b = [
6367
'foo' => 'moo',
6468
'bar' => 'b',
65-
'extra' => array(
69+
'extra' => [
6670
'foo' => 'c',
6771
'baz' => 'd'
68-
),
69-
);
72+
],
73+
];
7074

71-
$expected = array(
75+
$expected = [
7276
'foo' => 'moo',
7377
'bar' => 'b',
74-
'extra' => array(
78+
'extra' => [
7579
'foo' => 'c',
7680
'bar' => 'b',
7781
'baz' => 'd'
78-
)
79-
);
82+
]
83+
];
8084

8185
$this->assertEquals($expected, $tree->merge($a, $b));
8286
}
8387

8488
/**
8589
* Test merging when used as a prototype
8690
*/
87-
public function testMergeWhenUsedAsAPrototype()
91+
public function testMergeWhenUsedAsAPrototype(): void
8892
{
8993
if (method_exists(TreeBuilder::class, 'getRootNode')) {
9094
$builder = new TreeBuilder('root');
@@ -108,79 +112,78 @@ public function testMergeWhenUsedAsAPrototype()
108112
->end()
109113
->buildTree();
110114

111-
$a = array(
115+
$a = [
112116
'foo' => 'bar',
113-
'backends' => array(
114-
'cache' => array(
117+
'backends' => [
118+
'cache' => [
115119
'name' => 'cache',
116120
'adapter' => 'local',
117121
'root' => '/foo'
118-
),
119-
'default' => array(
122+
],
123+
'default' => [
120124
'name' => 'default',
121125
'adapter' => 'local',
122126
'root' => '/bar'
123-
)
124-
)
125-
);
127+
]
128+
]
129+
];
126130

127-
$b = array(
131+
$b = [
128132
'foo' => 'moo',
129-
'backends' => array(
130-
'cache' => array(
133+
'backends' => [
134+
'cache' => [
131135
'adapter' => 's3'
132-
),
133-
'default' => array(
136+
],
137+
'default' => [
134138
'root' => '/bar/baz'
135-
),
136-
'another' => array(
139+
],
140+
'another' => [
137141
'name' => 'another',
138142
'adapter' => 's3'
139-
)
140-
),
141-
);
143+
]
144+
],
145+
];
142146

143-
$expected = array(
147+
$expected = [
144148
'foo' => 'moo',
145-
'backends' => array(
146-
'cache' => array(
149+
'backends' => [
150+
'cache' => [
147151
'name' => 'cache',
148152
'adapter' => 's3',
149153
'root' => '/foo'
150-
),
151-
'default' => array(
154+
],
155+
'default' => [
152156
'name' => 'default',
153157
'adapter' => 'local',
154158
'root' => '/bar/baz'
155-
),
156-
'another' => array(
159+
],
160+
'another' => [
157161
'name' => 'another',
158162
'adapter' => 's3'
159-
)
160-
)
161-
);
163+
]
164+
]
165+
];
162166

163167
$this->assertEquals($expected, $tree->merge($a, $b));
164168
}
165169

166170
/**
167171
* Test node finalization
168172
*/
169-
public function testFinalizeValue()
173+
public function testFinalizeValue(): void
170174
{
171175
$node = new VariableArrayNode('foo', null);
172-
$this->assertSame(array('a' => 'b'), $node->finalize(array('a' => 'b')));
176+
$this->assertSame(['a' => 'b'], $node->finalize(['a' => 'b']));
173177
}
174178

175179
/**
176180
* Test node finalization without required keys present
177-
*
178-
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
179-
* @expectedExceptionMessage The key "bar" at path "foo" must be configured.
180181
*/
181-
public function testFinalizeValueWithoutRequiredKeys()
182+
public function testFinalizeValueWithoutRequiredKeys(): void
182183
{
183-
$node = new VariableArrayNode('foo', null, array('bar'));
184-
$node->finalize(array('a' => 'b'));
184+
$node = new VariableArrayNode('foo', null, ['bar']);
185+
$this->expectException(InvalidConfigurationException::class);
186+
$this->expectExceptionMessage('The key "bar" at path "foo" must be configured.');
187+
$node->finalize(['a' => 'b']);
185188
}
186189
}

0 commit comments

Comments
 (0)