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
16 public function test_scopes_error_if_not_existing()
18 $this->expectException(BadMethodCallException::class);
19 $this->expectExceptionMessage('Call to undefined method BookStack\Entities\Models\Page::scopeNotfoundscope()');
20 Page::query()->scopes('notfoundscope');
23 public function test_scopes_applies_upon_existing()
25 // Page has SoftDeletes trait by default, so we apply our custom scope and ensure
26 // it stacks on the global scope to filter out deleted items.
27 $query = Page::query()->scopes('visible')->toSql();
28 $this->assertStringContainsString('joint_permissions', $query);
29 $this->assertStringContainsString('`deleted_at` is null', $query);