. */ namespace Tests\Feature; use App\Account; use App\Space; use Carbon\Carbon; use Tests\TestCase; class ApiSpaceEmailServerTest extends TestCase { protected $method = 'POST'; protected $route = '/api/spaces'; public function testEmailServer() { $admin = Account::factory()->superAdmin()->create(); $admin->generateUserApiKey(); $emailHost = 'email.domain'; $route = $this->route . '/' . $admin->space->host . '/email'; $this->keyAuthenticated($admin) ->json($this->method, $route, [ 'host' => $emailHost, 'port' => 22 ]) ->assertStatus(201); $this->keyAuthenticated($admin) ->json('GET', $route) ->assertJsonFragment([ 'host' => $emailHost, 'port' => 22 ]) ->assertStatus(200); $this->keyAuthenticated($admin) ->json($this->method, $route, [ 'host' => $emailHost, 'port' => 23 ]) ->assertStatus(200); $this->keyAuthenticated($admin) ->json('GET', $route) ->assertJsonFragment([ 'port' => 23 ]) ->assertStatus(200); $this->keyAuthenticated($admin) ->json('DELETE', $route) ->assertStatus(200); $this->keyAuthenticated($admin) ->json('GET', $route) ->assertStatus(404); } }