- {% if extra.canUpdate %}
-
- {{ trans('admin.update.info.available') }}
-
-
-
-
- | {{ trans('admin.update.info.versions.latest') }} |
-
- v{{ info.latest }}
- |
-
-
- | {{ trans('admin.update.info.versions.current') }} |
-
- v{{ info.current }}
- |
-
-
-
+ {% if can_update %}
+
+ {{ trans('admin.update.info.available') }}
+
+
+
+
+ | {{ trans('admin.update.info.versions.latest') }} |
+
+ v{{ info.latest }}
+ |
+
+
+ | {{ trans('admin.update.info.versions.current') }} |
+
+ v{{ info.current }}
+ |
+
+
+
{% else %}
- {% if error is not empty %}
+ {% if error %}
{{ trans('admin.update.errors.connection', {error: error}) }}
@@ -54,7 +54,15 @@
{% endif %}
- {% for text in trans('admin.update.cautions.text')|split('\n') %}
-
{{ text }}
- {% endfor %}
+ {{ trans('admin.update.cautions.text')|nl2br }}
{{ trans('admin.update.cautions.link') }}
@@ -84,9 +90,3 @@
{% endblock %}
-
-{% block before_foot %}
-
-{% endblock %}
diff --git a/tests/HttpTest/ControllersTest/UpdateControllerTest.php b/tests/HttpTest/ControllersTest/UpdateControllerTest.php
index 2190c1ca..fea90590 100644
--- a/tests/HttpTest/ControllersTest/UpdateControllerTest.php
+++ b/tests/HttpTest/ControllersTest/UpdateControllerTest.php
@@ -36,8 +36,6 @@ class UpdateControllerTest extends TestCase
// Missing `spec` field
$this->appendToGuzzleQueue([
new Response(200, [], $this->mockFakeUpdateInfo('8.9.3', ['spec' => 0])),
- // Weird. Don't remove the following line, or the tests will fail.
- new Response(200, [], $this->mockFakeUpdateInfo('8.9.3', ['php' => '100.0.0'])),
]);
$this->get('/admin/update')->assertSee(trans('admin.update.errors.spec'));
@@ -59,8 +57,14 @@ class UpdateControllerTest extends TestCase
$this->setupGuzzleClientMock();
// Already up-to-date
+ $this->appendToGuzzleQueue([
+ new Response(200, [], $this->mockFakeUpdateInfo('1.2.3')),
+ ]);
$this->getJson('/admin/update/download')
- ->assertDontSee(trans('general.illegal-parameters'));
+ ->assertJson([
+ 'code' => 1,
+ 'message' => trans('admin.update.info.up-to-date'),
+ ]);
// Download
$this->appendToGuzzleQueue([
@@ -70,31 +74,17 @@ class UpdateControllerTest extends TestCase
$this->mock(PackageManager::class, function ($mock) {
$mock->shouldReceive('download')->andThrow(new \Exception('ddd'));
});
- $this->getJson('/admin/update/download?action=download')
- ->assertJson(['code' => 1]);
+ $this->getJson('/admin/update/download')->assertJson(['code' => 1]);
$this->mock(PackageManager::class, function ($mock) {
$mock->shouldReceive('download')->andReturnSelf();
$mock->shouldReceive('extract')->andReturn(true);
- $mock->shouldReceive('progress');
});
$this->mock(\Illuminate\Filesystem\Filesystem::class, function ($mock) {
$mock->shouldReceive('delete')->with(storage_path('options.php'))->once();
$mock->shouldReceive('exists')->with(storage_path('install.lock'))->andReturn(true);
});
- $this->getJson('/admin/update/download?action=download')
+ $this->getJson('/admin/update/download')
->assertJson(['code' => 0, 'message' => trans('admin.update.complete')]);
-
- // Get download progress
- $this->getJson('/admin/update/download?action=progress')
- ->assertSee('0');
-
- // Invalid action
- $this->appendToGuzzleQueue(200, [], $this->mockFakeUpdateInfo('8.9.3'));
- $this->getJson('/admin/update/download?action=no')
- ->assertJson([
- 'code' => 1,
- 'message' => trans('general.illegal-parameters'),
- ]);
}
public function testUpdate()
diff --git a/tests/ServicesTest/PackageManagerTest.php b/tests/ServicesTest/PackageManagerTest.php
index c22450c8..270a349d 100644
--- a/tests/ServicesTest/PackageManagerTest.php
+++ b/tests/ServicesTest/PackageManagerTest.php
@@ -3,7 +3,6 @@
namespace Tests;
use App\Services\PackageManager;
-use Cache;
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\RequestException;
@@ -12,7 +11,6 @@ use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Illuminate\Filesystem\Filesystem;
-use ReflectionClass;
use ZipArchive;
class PackageManagerTest extends TestCase
@@ -74,33 +72,4 @@ class PackageManagerTest extends TestCase
$this->expectException(Exception::class);
$package->extract('dest');
}
-
- public function testProgress()
- {
- $package = resolve(PackageManager::class);
- $reflect = new ReflectionClass($package);
- $property = $reflect->getProperty('cacheKey');
- $property->setAccessible(true);
- $property->setValue($package, 'key');
-
- Cache::put('key', serialize(['total' => 0, 'done' => 0]));
- $this->assertEquals(0, $package->progress());
-
- Cache::put('key', serialize(['total' => 2, 'done' => 1]));
- $this->assertEquals(0.5, $package->progress());
- }
-
- public function testOnProgress()
- {
- $package = resolve(PackageManager::class);
- $reflect = new ReflectionClass($package);
- $property = $reflect->getProperty('cacheKey');
- $property->setAccessible(true);
- $property->setValue($package, 'key');
- $closure = $reflect->getProperty('onProgress');
- $closure->setAccessible(true);
-
- Cache::shouldReceive('put')->with('key', serialize(['total' => 5, 'done' => 4]));
- call_user_func($closure->getValue($package), 5, 4);
- }
}