5 use BadMethodCallException;
6 use BookStack\Entities\Models\Page;
10 * This class tests assumptions we're relying upon in the framework.
11 * This is primarily to keep track of certain bits of functionality that
12 * may be used in important areas such as to enforce permissions.
14 class FrameworkAssumptionTest extends TestCase
17 public function test_scopes_error_if_not_existing()
19 $this->expectException(BadMethodCallException::class);
20 $this->expectExceptionMessage('Call to undefined method BookStack\Entities\Models\Page::scopeNotfoundscope()');
21 Page::query()->scopes('notfoundscope');
24 public function test_scopes_applies_upon_existing()
26 // Page has SoftDeletes trait by default, so we apply our custom scope and ensure
27 // it stacks on the global scope to filter out deleted items.
28 $query = Page::query()->scopes('visible')->toSql();
29 $this->assertStringContainsString('joint_permissions', $query);
30 $this->assertStringContainsString('`deleted_at` is null', $query);