Skip to content

Commit 196b5c4

Browse files
authored
Merge pull request #37 from tattersoftware/refactor-tests
Refactor Tests
2 parents e9abd4d + 6005f39 commit 196b5c4

File tree

21 files changed

+139
-267
lines changed

21 files changed

+139
-267
lines changed

.github/workflows/rector.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ jobs:
6464
6565
- name: Analyze for refactoring
6666
run: |
67-
composer global require --dev rector/rector:^0.12.10
67+
composer global require --dev rector/rector:dev-main
6868
rector process --dry-run --no-progress-bar

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
vendor/
1+
/vendor/
22
build/
33
phpunit*.xml
44
phpunit

UPGRADING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
* Switches to `Tatter\Preferences` for managing persistent settings; read more below
77
* Drops `Tatter\Audits` as a dependency and adds it as a suggestion; read more below
8+
* Access rights are now handled via Config file; see [Tatter\Permits](https://github.com/tattersoftware/codeigniter4-permits) for more information
89

910
### `Settings` Migration
1011

@@ -29,7 +30,7 @@ php spark migrate --all
2930
```
3031

3132
Example model file in **app/Models/FileModel.php**:
32-
```
33+
```php
3334
<?php
3435

3536
namespace App\Models;

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@
2626
"tatter/alerts": "^2.0",
2727
"tatter/exports": "^2.0",
2828
"tatter/frontend": "^1.0",
29-
"tatter/permits": "^2.0",
29+
"tatter/permits": "^3.0",
3030
"tatter/preferences": "^1.0",
3131
"tatter/thumbnails": "^1.2"
3232
},
3333
"require-dev": {
34-
"antecedent/patchwork": "^2.1",
3534
"codeigniter4/devkit": "^1.0",
3635
"codeigniter4/framework": "^4.1",
3736
"tatter/imposter": "^1.0"

phpunit.xml.dist

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
convertErrorsToExceptions="true"
1111
convertNoticesToExceptions="true"
1212
convertWarningsToExceptions="true"
13-
executionOrder="random"
1413
failOnRisky="true"
1514
failOnWarning="true"
1615
stopOnError="false"

rector.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@
7777
__DIR__ . '/tests',
7878
],
7979

80+
// Ignore files that should not be namespaced
81+
NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [
82+
__DIR__ . '/src/Helpers',
83+
],
84+
8085
// May load view files directly when detecting classes
8186
StringClassNameToClassConstantRector::class,
8287

src/Config/Registrar.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,21 @@ public static function Pager()
1717
],
1818
];
1919
}
20+
21+
/**
22+
* Adds necessary configuration values for Permits
23+
* to identify the owner(s) of files.
24+
*
25+
* @return array<string,mixed>
26+
*/
27+
public static function Permits()
28+
{
29+
return [
30+
'files' => [
31+
'userKey' => 'user_id',
32+
'pivotKey' => 'file_id',
33+
'pivotTable' => 'files_users',
34+
],
35+
];
36+
}
2037
}

src/Controllers/Files.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Files extends Controller
2323
protected FilesConfig $config;
2424

2525
/**
26-
* The model to use, may be a child of this library's.
26+
* The model to use.
2727
*/
2828
protected FileModel $model;
2929

@@ -156,7 +156,6 @@ public function user($userId = null)
156156
}
157157

158158
$this->setData([
159-
'access' => $this->model->mayAdmin() ? 'manage' : 'display',
160159
'title' => 'User Files',
161160
'userName' => 'User',
162161
]);

src/Entities/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class File extends Entity
1818
/**
1919
* Resolved path to the default thumbnail
2020
*/
21-
protected static ?string $defaultThumbnail;
21+
protected static ?string $defaultThumbnail = null;
2222

2323
/**
2424
* Returns the absolute path to the configured default thumbnail

src/Models/FileModel.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@ class FileModel extends Model
3434
'size' => 'permit_empty|is_natural',
3535
];
3636

37-
// Permits
38-
protected $mode = 04660;
39-
protected $userKey = 'user_id';
40-
protected $pivotKey = 'file_id';
41-
protected $usersPivot = 'files_users';
42-
4337
//--------------------------------------------------------------------
4438

4539
/**

0 commit comments

Comments
 (0)