19 declare(strict_types=1);
31 $readable = $this->getMockBuilder(Readable::class)->disableOriginalConstructor()->getMock();
32 $this->assertInstanceOf(AccessQuestionImage::class,
new AccessQuestionImage($readable));
40 $readable = $this->getMockBuilder(Readable::class)->disableOriginalConstructor()->getMock();
42 $instance =
new AccessQuestionImage($readable);
44 $this->assertFalse($instance->isPermitted($path)->isOk());
51 [
'/assessment/12/images/foo.png'],
52 [
'/assessment/12/34/images/foo/bar.png'],
53 [
'/assessment/12/ab/images/foo.png'],
54 [
'/assessment/ab/12/images/foo.png'],
55 [
'assessment/12/34/images/foo.png'],
64 $readable = $this->getMockBuilder(Readable::class)->disableOriginalConstructor()->getMock();
66 $readable->method(
'objectId')->with(6709)->willReturn($is_readable);
68 $instance =
new AccessQuestionImage($readable);
69 $result = $instance->isPermitted(
'/assessment/6709/389/images/foo.png');
70 $this->assertTrue($result->isOk());
71 $this->assertSame($is_readable, $result->value());
77 'With readable object path.' => [
true],
78 'Without readable object path.' => [
false],
static isPermittedProvider()
testIsPermittedWithInvalidPath(string $path)
invalidPaths
testIsPermittedWithValidPath(bool $is_readable)
isPermittedProvider