Skip to content

Commit 58cc0a7

Browse files
committed
route test fixes
1 parent c594327 commit 58cc0a7

File tree

4 files changed

+24
-57
lines changed

4 files changed

+24
-57
lines changed

config/canvas.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
|--------------------------------------------------------------------------
99
|
1010
| This is the subdomain where Canvas will be accessible from. If the
11-
| setting is null, Canvas will reside under the same domain as the
12-
| application. Otherwise, this will be used as the subdomain.
11+
| domain is set to null, Canvas will reside under the defined base
12+
| path below. Otherwise, this will be used as the subdomain.
1313
|
1414
*/
1515

@@ -20,9 +20,9 @@
2020
| Base Path
2121
|--------------------------------------------------------------------------
2222
|
23-
| This is the URI path where Canvas will be accessible from. You are free
24-
| to change this path to anything you like. Note that the URI will not
25-
| affect the paths of its internal API that aren't exposed to users.
23+
| This is the URI where Canvas will be accessible from. If the path
24+
| is set to null, Canvas will reside under the same path name as
25+
| the application. Otherwise, this is used as the base path.
2626
|
2727
*/
2828

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ Canvas exposes its UI at `/canvas` by default. This can be changed by updating e
8181
|--------------------------------------------------------------------------
8282
|
8383
| This is the URI where Canvas will be accessible from. If the path
84-
| is set to null, Canvas will reside under the path name as the
85-
| application. Otherwise, this will be used as the base path.
84+
| is set to null, Canvas will reside under the same path name as
85+
| the application. Otherwise, this is used as the base path.
8686
|
8787
*/
8888

tests/Http/RouteTest.php

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,59 +18,36 @@ public function testNamedRoute(): void
1818

1919
public function testRouteWithDefaultBasePath(): void
2020
{
21-
$this->markTestSkipped();
22-
2321
$this->actingAs($this->admin)
24-
->get(sprintf('%s', config('canvas.path')))
22+
->get(route('canvas'))
2523
->assertRedirect(route('canvas.login'))
2624
->assertLocation('http://laravel.test/canvas/login');
2725

28-
$this->assertSame(Canvas::basePath(), '/'.config('canvas.path'));
26+
$this->assertSame(Canvas::basePath(), '/canvas');
2927
}
3028

3129
public function testRouteWithSubdomainAndDefaultBasePath(): void
3230
{
33-
$this->markTestSkipped();
34-
3531
Config::set('canvas.domain', 'http://canvas.laravel.test');
3632

3733
$this->actingAs($this->admin)
38-
->get(sprintf('%s/%s', config('canvas.domain'), config('canvas.path')))
34+
->get(config('canvas.domain') . '/canvas')
3935
->assertRedirect(route('canvas.login'))
4036
->assertLocation('http://canvas.laravel.test/canvas/login');
4137

42-
$this->assertSame(Canvas::basePath(), '/'.config('canvas.path'));
38+
$this->assertSame(Canvas::basePath(), '/canvas');
4339
}
4440

4541
public function testRouteWithSubdomainAndNullBasePath(): void
4642
{
47-
$this->markTestSkipped();
48-
4943
Config::set('canvas.path', null);
5044

5145
Config::set('canvas.domain', 'http://canvas.laravel.test');
5246

5347
$this->actingAs($this->admin)
54-
->get(config('canvas.domain'))
55-
->assertRedirect(route('canvas.login'))
56-
->assertLocation('http://canvas.laravel.test/login');
48+
->get(config('canvas.domain') . '/canvas')
49+
->assertRedirect(route('canvas.login'));
5750

5851
$this->assertSame(Canvas::basePath(), '/');
5952
}
60-
61-
public function testBasePathWithSubdomain(): void
62-
{
63-
$this->markTestSkipped();
64-
65-
Config::set('canvas.path', 'admin');
66-
67-
Config::set('canvas.domain', 'http://canvas.laravel.test');
68-
69-
$this->actingAs($this->admin)
70-
->get(sprintf('%s/%s', config('canvas.domain'), config('canvas.path')))
71-
->assertRedirect(route('canvas.login'))
72-
->assertLocation('http://canvas.laravel.test/blog/login');
73-
74-
$this->assertSame(Canvas::basePath(), '/admin');
75-
}
7653
}

tests/TestCase.php

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,17 @@ protected function setUp(): void
4444

4545
$this->setUpDatabase($this->app);
4646

47-
$this->createTestUsers();
47+
$this->contributor = factory(User::class)->create([
48+
'role' => User::CONTRIBUTOR,
49+
]);
50+
51+
$this->editor = factory(User::class)->create([
52+
'role' => User::EDITOR,
53+
]);
54+
55+
$this->admin = factory(User::class)->create([
56+
'role' => User::ADMIN,
57+
]);
4858
}
4959

5060
/**
@@ -113,24 +123,4 @@ protected function setUpDatabase($app): void
113123

114124
$this->artisan('migrate');
115125
}
116-
117-
/**
118-
* Create role-based users for testing.
119-
*
120-
* @void
121-
*/
122-
protected function createTestUsers(): void
123-
{
124-
$this->contributor = factory(User::class)->create([
125-
'role' => User::CONTRIBUTOR,
126-
]);
127-
128-
$this->editor = factory(User::class)->create([
129-
'role' => User::EDITOR,
130-
]);
131-
132-
$this->admin = factory(User::class)->create([
133-
'role' => User::ADMIN,
134-
]);
135-
}
136126
}

0 commit comments

Comments
 (0)