-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed lock issue on own accounts (#1910)
- Loading branch information
1 parent
eced1b9
commit 13f6dca
Showing
2 changed files
with
74 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -214,4 +214,48 @@ public function testAuthenticationWithoutUser() | |
|
||
$function->call($api); | ||
} | ||
|
||
public function testParent() | ||
{ | ||
$app = $this->app->clone([ | ||
'site' => [ | ||
'files' => [ | ||
['filename' => 'sitefile.jpg'] | ||
] | ||
], | ||
'users' => [ | ||
[ | ||
'email' => '[email protected]', | ||
], | ||
[ | ||
'email' => '[email protected]', | ||
'files' => [ | ||
['filename' => 'userfile.jpg'] | ||
] | ||
] | ||
], | ||
]); | ||
|
||
$app->impersonate('[email protected]'); | ||
|
||
$api = $app->api(); | ||
|
||
$this->assertInstanceOf(User::class, $api->parent('account')); | ||
$this->assertInstanceOf(User::class, $api->parent('users/[email protected]')); | ||
$this->assertInstanceOf(Site::class, $api->parent('site')); | ||
$this->assertInstanceOf(Page::class, $api->parent('pages/a+aa')); | ||
$this->assertInstanceOf(File::class, $api->parent('site/files/sitefile.jpg')); | ||
$this->assertInstanceOf(File::class, $api->parent('pages/a/files/a-regular-file.jpg')); | ||
$this->assertInstanceOf(File::class, $api->parent('users/[email protected]/files/userfile.jpg')); | ||
|
||
// model type is not recognized | ||
$this->expectException('Kirby\Exception\InvalidArgumentException'); | ||
$this->expectExceptionMessage('Invalid file model type: something'); | ||
$this->assertNull($api->parent('something/something')); | ||
|
||
// model cannot be found | ||
$this->expectException('Kirby\Exception\NotFoundException'); | ||
$this->expectExceptionMessage('The page cannot be found'); | ||
$this->assertNull($api->parent('pages/does-not-exist')); | ||
} | ||
} |