2017-06-15 04:53:24 +00:00
|
|
|
<?php
|
2017-09-26 02:43:01 +00:00
|
|
|
/**
|
2017-06-15 04:53:24 +00:00
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-06-15 04:53:24 +00:00
|
|
|
*/
|
|
|
|
|
2017-09-15 05:16:03 +00:00
|
|
|
namespace Tests\Unit\Services\Locations;
|
2017-06-15 04:53:24 +00:00
|
|
|
|
2017-09-15 05:16:03 +00:00
|
|
|
use Mockery as m;
|
|
|
|
use Tests\TestCase;
|
|
|
|
use Pterodactyl\Models\Location;
|
|
|
|
use Pterodactyl\Services\Locations\LocationCreationService;
|
2017-07-03 02:29:58 +00:00
|
|
|
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
2017-06-15 04:53:24 +00:00
|
|
|
|
2017-09-15 05:16:03 +00:00
|
|
|
class LocationCreationServiceTest extends TestCase
|
2017-06-15 04:53:24 +00:00
|
|
|
{
|
|
|
|
/**
|
2017-07-03 02:29:58 +00:00
|
|
|
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
|
2017-06-15 04:53:24 +00:00
|
|
|
*/
|
2017-07-03 02:29:58 +00:00
|
|
|
protected $repository;
|
2017-06-15 04:53:24 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-15 05:16:03 +00:00
|
|
|
* @var \Pterodactyl\Services\Locations\LocationCreationService
|
2017-06-15 04:53:24 +00:00
|
|
|
*/
|
2017-09-15 05:16:03 +00:00
|
|
|
protected $service;
|
2017-06-15 04:53:24 +00:00
|
|
|
|
|
|
|
/**
|
2017-09-15 05:16:03 +00:00
|
|
|
* Setup tests.
|
2017-06-15 04:53:24 +00:00
|
|
|
*/
|
2017-09-15 05:16:03 +00:00
|
|
|
public function setUp()
|
2017-06-15 04:53:24 +00:00
|
|
|
{
|
2017-09-15 05:16:03 +00:00
|
|
|
parent::setUp();
|
2017-06-15 04:53:24 +00:00
|
|
|
|
2017-09-15 05:16:03 +00:00
|
|
|
$this->repository = m::mock(LocationRepositoryInterface::class);
|
|
|
|
|
|
|
|
$this->service = new LocationCreationService($this->repository);
|
2017-06-15 04:53:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2017-09-15 05:16:03 +00:00
|
|
|
* Test that a location is created.
|
2017-06-15 04:53:24 +00:00
|
|
|
*/
|
2017-09-15 05:16:03 +00:00
|
|
|
public function testLocationIsCreated()
|
2017-06-15 04:53:24 +00:00
|
|
|
{
|
2017-09-15 05:16:03 +00:00
|
|
|
$location = factory(Location::class)->make();
|
|
|
|
|
|
|
|
$this->repository->shouldReceive('create')->with(['test_data' => 'test_value'])->once()->andReturn($location);
|
|
|
|
|
|
|
|
$response = $this->service->handle(['test_data' => 'test_value']);
|
|
|
|
$this->assertNotEmpty($response);
|
|
|
|
$this->assertInstanceOf(Location::class, $response);
|
|
|
|
$this->assertEquals($location, $response);
|
2017-06-15 04:53:24 +00:00
|
|
|
}
|
|
|
|
}
|