Issue/327 versioning (#345)
* Switch to semver format * Rewrite new version check to use Github Releases and cron * Styling * Remove v from in front of version * New version check test fix * Uncomment test case
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
<?php
|
||||
|
||||
use App\Repositories\SettingRepository;
|
||||
use App\Services\DatabaseService;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Psr7\Response;
|
||||
use Tests\TestData;
|
||||
|
||||
/**
|
||||
@@ -103,6 +108,60 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a file from the data directory
|
||||
*
|
||||
* @param $filename
|
||||
*
|
||||
* @return false|string
|
||||
*/
|
||||
public function readDataFile($filename)
|
||||
{
|
||||
$paths = [
|
||||
'data/'.$filename,
|
||||
'tests/data/'.$filename,
|
||||
];
|
||||
|
||||
foreach ($paths as $p) {
|
||||
if (file_exists($p)) {
|
||||
return file_get_contents($p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a mock Guzzle Client with a response loaded from $mockFile
|
||||
*
|
||||
* @param $mockFile
|
||||
*/
|
||||
public function mockGuzzleClient($mockFile): void
|
||||
{
|
||||
$mock = new MockHandler([
|
||||
new Response(200,
|
||||
[
|
||||
'Content-Type' => 'application/json; charset=utf-8',
|
||||
],
|
||||
$this->readDataFile($mockFile)
|
||||
),
|
||||
]);
|
||||
|
||||
$handler = HandlerStack::create($mock);
|
||||
$guzzleClient = new Client(['handler' => $handler]);
|
||||
app()->instance(Client::class, $guzzleClient);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a setting
|
||||
*
|
||||
* @param $key
|
||||
* @param $value
|
||||
*/
|
||||
public function updateSetting($key, $value)
|
||||
{
|
||||
$settingsRepo = app(SettingRepository::class);
|
||||
$settingsRepo->store($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* So we can test private/protected methods
|
||||
* http://bit.ly/1mr5hMq
|
||||
|
||||
Reference in New Issue
Block a user