forked from laravel/valet
-
Notifications
You must be signed in to change notification settings - Fork 160
/
Copy pathSecureTest.php
46 lines (36 loc) · 1.26 KB
/
SecureTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace Valet\Tests\Functional;
use Filesystem;
use Httpful\Exception\ConnectionErrorException;
/**
* @group functional
* @group acceptance
*/
class SecureTest extends FunctionalTestCase
{
protected function setUp(): void
{
// Create filesystem structure
mkdir($_SERVER['HOME'] . '/valet-site');
file_put_contents($_SERVER['HOME'] . '/valet-site/index.html', 'Valet site');
$this->valetCommand('link', $_SERVER['HOME'] . '/valet-site');
}
protected function tearDown(): void
{
$this->valetCommand('unlink', $_SERVER['HOME'] . '/valet-site');
Filesystem::remove($_SERVER['HOME'] . '/valet-site');
}
public function test_valet_can_enable_https()
{
$this->valetCommand('secure', $_SERVER['HOME'] . '/valet-site');
$response = \Httpful\Request::get('https://valet-site.test')->send();
$this->assertEquals(200, $response->code);
$this->assertContains('Valet site', $response->body);
}
public function test_valet_can_disable_https()
{
$this->expectException(ConnectionErrorException::class);
$this->valetCommand('unsecure', $_SERVER['HOME'] . '/valet-site');
\Httpful\Request::get('https://valet-site.test')->send();
}
}