1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 16:40:05 +01:00
Files
laravel-valet/tests/NgrokTest.php
Dries Vints a0e1e02a47 Test Valet commands (#1256)
* First attempt at testing CLI commands

* Apply fixes from StyleCI

* Protect from running locally

* Fix test

* wip

* wip

* wip

* wip

* wip

* Update app.php

* Create config folder and files for CLI tests

* Apply fixes from StyleCI

* Fix some formatting

* Fix imports

* Update all output() calls to use the writer passed in by the command

Ugly capture of all $outputs from commands, by passing them into `writer()` to be bound into the container, where they can then be pulled out from calls to `output()` and its buddies `info()`, `table()`, and `warning()`.

* Apply fixes from StyleCI

* Flesh out park command test

* Apply fixes from StyleCI

* Drop php 7.0 and 7.1

Co-authored-by: StyleCI Bot <bot@styleci.io>
Co-authored-by: Matt Stauffer <matt@tighten.co>
2022-12-02 09:32:28 +01:00

70 lines
1.9 KiB
PHP

<?php
use Illuminate\Container\Container;
use Valet\Ngrok;
use function Valet\user;
class NgrokTest extends Yoast\PHPUnitPolyfills\TestCases\TestCase
{
use UsesNullWriter;
public function set_up()
{
$_SERVER['SUDO_USER'] = user();
Container::setInstance(new Container);
$this->setNullWriter();
}
public function tear_down()
{
Mockery::close();
}
public function test_it_matches_correct_share_tunnel()
{
$tunnels = [
(object) [
'proto' => 'https',
'config' => (object) [
'addr' => 'http://mysite.test:80',
],
'public_url' => 'http://bad-proto.ngrok.io/',
],
(object) [
'proto' => 'http',
'config' => (object) [
'addr' => 'http://nottherightone.test:80',
],
'public_url' => 'http://bad-site.ngrok.io/',
],
(object) [
'proto' => 'http',
'config' => (object) [
'addr' => 'http://mysite.test:80',
],
'public_url' => 'http://right-one.ngrok.io/',
],
];
$ngrok = new Ngrok;
$this->assertEquals('http://right-one.ngrok.io/', $ngrok->findHttpTunnelUrl($tunnels, 'mysite'));
}
public function test_it_checks_against_lowercased_domain()
{
$tunnels = [
(object) [
'proto' => 'http',
'config' => (object) [
'addr' => 'http://mysite.test:80',
],
'public_url' => 'http://right-one.ngrok.io/',
],
];
$ngrok = new Ngrok;
$this->assertEquals('http://right-one.ngrok.io/', $ngrok->findHttpTunnelUrl($tunnels, 'MySite'));
}
}