Optimize testing
This commit is contained in:
parent
c036e72642
commit
d45d287d93
|
|
@ -34,5 +34,5 @@ REDIS_HOST = 127.0.0.1
|
||||||
REDIS_PASSWORD = null
|
REDIS_PASSWORD = null
|
||||||
REDIS_PORT = 6379
|
REDIS_PORT = 6379
|
||||||
|
|
||||||
PLUGINS_DIR = null
|
PLUGINS_DIR = plugins
|
||||||
PLUGINS_URL = null
|
PLUGINS_URL = null
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@
|
||||||
"phpunit/phpunit": "~7.0",
|
"phpunit/phpunit": "~7.0",
|
||||||
"laravel/browser-kit-testing": "~4.0",
|
"laravel/browser-kit-testing": "~4.0",
|
||||||
"league/flysystem-memory": "^1.0",
|
"league/flysystem-memory": "^1.0",
|
||||||
"mikey179/vfsstream": "^1.6.5",
|
|
||||||
"barryvdh/laravel-ide-helper": "^2.6",
|
"barryvdh/laravel-ide-helper": "^2.6",
|
||||||
"laravel/tinker": "^1.0"
|
"laravel/tinker": "^1.0"
|
||||||
},
|
},
|
||||||
|
|
@ -46,5 +45,11 @@
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"preferred-install": "dist"
|
"preferred-install": "dist"
|
||||||
|
},
|
||||||
|
"repositories": {
|
||||||
|
"packagist": {
|
||||||
|
"type": "composer",
|
||||||
|
"url": "https://packagist.org/"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
48
composer.lock
generated
48
composer.lock
generated
|
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "425b8e682534d97b800252cf1ec95152",
|
"content-hash": "4856faf86e559b07bc74419914ed0a2c",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "composer/semver",
|
"name": "composer/semver",
|
||||||
|
|
@ -3979,52 +3979,6 @@
|
||||||
],
|
],
|
||||||
"time": "2016-06-04T03:57:11+00:00"
|
"time": "2016-06-04T03:57:11+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "mikey179/vfsStream",
|
|
||||||
"version": "v1.6.5",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/mikey179/vfsStream.git",
|
|
||||||
"reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/mikey179/vfsStream/zipball/d5fec95f541d4d71c4823bb5e30cf9b9e5b96145",
|
|
||||||
"reference": "d5fec95f541d4d71c4823bb5e30cf9b9e5b96145",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": ">=5.3.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"phpunit/phpunit": "~4.5"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.6.x-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-0": {
|
|
||||||
"org\\bovigo\\vfs\\": "src/main/php"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"BSD-3-Clause"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "Frank Kleine",
|
|
||||||
"homepage": "http://frankkleine.de/",
|
|
||||||
"role": "Developer"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Virtual file system to mock the real file system in unit tests.",
|
|
||||||
"homepage": "http://vfs.bovigo.org/",
|
|
||||||
"time": "2017-08-01T08:02:14+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "mockery/mockery",
|
"name": "mockery/mockery",
|
||||||
"version": "1.2.2",
|
"version": "1.2.2",
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ trait GeneratesFakePlugins
|
||||||
*/
|
*/
|
||||||
protected function generateFakePlugin($info)
|
protected function generateFakePlugin($info)
|
||||||
{
|
{
|
||||||
$plugin_dir = base_path("plugins/{$info['name']}");
|
$plugin_dir = config('plugins.directory').DIRECTORY_SEPARATOR.$info['name'];
|
||||||
|
|
||||||
if (! is_dir($plugin_dir)) {
|
if (! is_dir($plugin_dir)) {
|
||||||
mkdir($plugin_dir);
|
mkdir($plugin_dir);
|
||||||
|
|
|
||||||
|
|
@ -79,8 +79,10 @@ class MarketControllerTest extends TestCase
|
||||||
'errno' => 0,
|
'errno' => 0,
|
||||||
'msg' => trans('admin.plugins.market.install-success'),
|
'msg' => trans('admin.plugins.market.install-success'),
|
||||||
]);
|
]);
|
||||||
$this->assertTrue(is_dir(base_path('plugins/fake-test-download')));
|
$this->assertTrue(is_dir(config('plugins.directory').DIRECTORY_SEPARATOR.'fake-test-download'));
|
||||||
$this->assertTrue(empty(glob(base_path('plugins/fake-test-download_*.zip'))));
|
$this->assertTrue(
|
||||||
|
empty(glob(config('plugins.directory').DIRECTORY_SEPARATOR.'plugins/fake-test-download_*.zip'))
|
||||||
|
);
|
||||||
|
|
||||||
// Broken archive
|
// Broken archive
|
||||||
file_put_contents($fakeArchive, 'broken');
|
file_put_contents($fakeArchive, 'broken');
|
||||||
|
|
@ -174,9 +176,9 @@ class MarketControllerTest extends TestCase
|
||||||
protected function tearDown(): void
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
// Clean fake plugins
|
// Clean fake plugins
|
||||||
File::deleteDirectory(base_path('plugins/fake-test-download'));
|
File::deleteDirectory(config('plugins.directory').DIRECTORY_SEPARATOR.'fake-test-download');
|
||||||
File::deleteDirectory(base_path('plugins/fake-test-update'));
|
File::deleteDirectory(config('plugins.directory').DIRECTORY_SEPARATOR.'fake-test-update');
|
||||||
File::delete(base_path('plugins/whatever'));
|
File::delete(config('plugins.directory').DIRECTORY_SEPARATOR.'whatever');
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,8 +142,8 @@ class PluginControllerTest extends TestCase
|
||||||
protected function tearDown(): void
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
// Clean fake plugins
|
// Clean fake plugins
|
||||||
File::deleteDirectory(base_path('plugins/fake-plugin-for-test'));
|
File::deleteDirectory(config('plugins.directory').DIRECTORY_SEPARATOR.'fake-plugin-for-test');
|
||||||
File::deleteDirectory(base_path('plugins/fake-plugin-with-config-view'));
|
File::deleteDirectory(config('plugins.directory').DIRECTORY_SEPARATOR.'plugins/fake-plugin-with-config-view');
|
||||||
|
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,14 @@ class HookTest extends TestCase
|
||||||
public function testRegisterPluginTransScripts()
|
public function testRegisterPluginTransScripts()
|
||||||
{
|
{
|
||||||
$this->generateFakePlugin(['name' => 'fake-plugin-with-i18n', 'version' => '0.0.1']);
|
$this->generateFakePlugin(['name' => 'fake-plugin-with-i18n', 'version' => '0.0.1']);
|
||||||
@mkdir($path = base_path('plugins/fake-plugin-with-i18n/lang/en'), 0755, true);
|
@mkdir($path = config('plugins.directory').DIRECTORY_SEPARATOR.'fake-plugin-with-i18n/lang/en', 0755, true);
|
||||||
file_put_contents("$path/locale.js", '');
|
file_put_contents("$path/locale.js", '');
|
||||||
|
|
||||||
Hook::registerPluginTransScripts('fake-plugin-with-i18n');
|
Hook::registerPluginTransScripts('fake-plugin-with-i18n');
|
||||||
$this->get('/')
|
$this->get('/')
|
||||||
->assertSee('fake-plugin-with-i18n/lang/en/locale.js');
|
->assertSee('fake-plugin-with-i18n/lang/en/locale.js');
|
||||||
|
|
||||||
File::deleteDirectory(base_path('plugins/fake-plugin-with-i18n'));
|
File::deleteDirectory(config('plugins.directory').DIRECTORY_SEPARATOR.'plugins/fake-plugin-with-i18n');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAddStyleFileToPage()
|
public function testAddStyleFileToPage()
|
||||||
|
|
|
||||||
|
|
@ -3,26 +3,30 @@
|
||||||
namespace Tests;
|
namespace Tests;
|
||||||
|
|
||||||
use App\Services\Minecraft;
|
use App\Services\Minecraft;
|
||||||
use org\bovigo\vfs\vfsStream;
|
use Illuminate\Http\Testing\FileFactory;
|
||||||
use App\Http\Controllers\TextureController;
|
use App\Http\Controllers\TextureController;
|
||||||
|
|
||||||
class MinecraftTest extends TestCase
|
class MinecraftTest extends TestCase
|
||||||
{
|
{
|
||||||
|
private $fileFactory;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
vfsStream::setup();
|
$this->fileFactory = new FileFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGenerateAvatarFromSkin()
|
public function testGenerateAvatarFromSkin()
|
||||||
{
|
{
|
||||||
imagepng(imagecreatetruecolor(64, 32), vfsStream::url('root/skin.png'));
|
$file = $this->fileFactory->image('skin.png');
|
||||||
$avatar = Minecraft::generateAvatarFromSkin(file_get_contents(vfsStream::url('root/skin.png')), 50);
|
|
||||||
|
imagepng(imagecreatetruecolor(64, 32), $file->path());
|
||||||
|
$avatar = Minecraft::generateAvatarFromSkin(file_get_contents($file->path()), 50);
|
||||||
$this->assertEquals(50, imagesx($avatar));
|
$this->assertEquals(50, imagesx($avatar));
|
||||||
$this->assertEquals(50, imagesy($avatar));
|
$this->assertEquals(50, imagesy($avatar));
|
||||||
|
|
||||||
imagepng(imagecreatetruecolor(128, 64), vfsStream::url('root/skin.png'));
|
imagepng(imagecreatetruecolor(128, 64), $file->path());
|
||||||
$avatar = Minecraft::generateAvatarFromSkin(file_get_contents(vfsStream::url('root/skin.png')), 50);
|
$avatar = Minecraft::generateAvatarFromSkin(file_get_contents($file->path()), 50);
|
||||||
$this->assertEquals(50, imagesx($avatar));
|
$this->assertEquals(50, imagesx($avatar));
|
||||||
$this->assertEquals(50, imagesy($avatar));
|
$this->assertEquals(50, imagesy($avatar));
|
||||||
|
|
||||||
|
|
@ -35,16 +39,18 @@ class MinecraftTest extends TestCase
|
||||||
|
|
||||||
public function testGeneratePreviewFromSkin()
|
public function testGeneratePreviewFromSkin()
|
||||||
{
|
{
|
||||||
imagepng(imagecreatetruecolor(64, 32), vfsStream::url('root/skin.png'));
|
$file = $this->fileFactory->image('skin.png');
|
||||||
|
|
||||||
|
imagepng(imagecreatetruecolor(64, 32), $file->path());
|
||||||
$preview = Minecraft::generatePreviewFromSkin(
|
$preview = Minecraft::generatePreviewFromSkin(
|
||||||
file_get_contents(vfsStream::url('root/skin.png')), 50, false, 'front'
|
file_get_contents($file->path()), 50, false, 'front'
|
||||||
);
|
);
|
||||||
$this->assertEquals(25, imagesx($preview));
|
$this->assertEquals(25, imagesx($preview));
|
||||||
$this->assertEquals(50, imagesy($preview));
|
$this->assertEquals(50, imagesy($preview));
|
||||||
|
|
||||||
imagepng(imagecreatetruecolor(64, 32), vfsStream::url('root/skin.png'));
|
imagepng(imagecreatetruecolor(64, 32), $file->path());
|
||||||
$preview = Minecraft::generatePreviewFromSkin(
|
$preview = Minecraft::generatePreviewFromSkin(
|
||||||
file_get_contents(vfsStream::url('root/skin.png')),
|
file_get_contents($file->path()),
|
||||||
50,
|
50,
|
||||||
true, // Alex model
|
true, // Alex model
|
||||||
'both',
|
'both',
|
||||||
|
|
@ -53,9 +59,9 @@ class MinecraftTest extends TestCase
|
||||||
$this->assertEquals(56, imagesx($preview));
|
$this->assertEquals(56, imagesx($preview));
|
||||||
$this->assertEquals(50, imagesy($preview));
|
$this->assertEquals(50, imagesy($preview));
|
||||||
|
|
||||||
imagepng(imagecreatetruecolor(64, 64), vfsStream::url('root/skin.png'));
|
imagepng(imagecreatetruecolor(64, 64), $file->path());
|
||||||
$preview = Minecraft::generatePreviewFromSkin(
|
$preview = Minecraft::generatePreviewFromSkin(
|
||||||
file_get_contents(vfsStream::url('root/skin.png')),
|
file_get_contents($file->path()),
|
||||||
100,
|
100,
|
||||||
true, // Alex model
|
true, // Alex model
|
||||||
'both',
|
'both',
|
||||||
|
|
@ -64,13 +70,13 @@ class MinecraftTest extends TestCase
|
||||||
$this->assertEquals(125, imagesx($preview));
|
$this->assertEquals(125, imagesx($preview));
|
||||||
$this->assertEquals(100, imagesy($preview));
|
$this->assertEquals(100, imagesy($preview));
|
||||||
|
|
||||||
imagepng(imagecreatetruecolor(128, 64), vfsStream::url('root/skin.png'));
|
imagepng(imagecreatetruecolor(128, 64), $file->path());
|
||||||
$preview = Minecraft::generatePreviewFromSkin(file_get_contents(vfsStream::url('root/skin.png')), 50);
|
$preview = Minecraft::generatePreviewFromSkin(file_get_contents($file->path()), 50);
|
||||||
$this->assertEquals(56, imagesx($preview));
|
$this->assertEquals(56, imagesx($preview));
|
||||||
$this->assertEquals(50, imagesy($preview));
|
$this->assertEquals(50, imagesy($preview));
|
||||||
|
|
||||||
imagepng(imagecreatetruecolor(128, 128), vfsStream::url('root/skin.png'));
|
imagepng(imagecreatetruecolor(128, 128), $file->path());
|
||||||
$preview = Minecraft::generatePreviewFromSkin(file_get_contents(vfsStream::url('root/skin.png')), 50);
|
$preview = Minecraft::generatePreviewFromSkin(file_get_contents($file->path()), 50);
|
||||||
$this->assertEquals(56, imagesx($preview));
|
$this->assertEquals(56, imagesx($preview));
|
||||||
$this->assertEquals(50, imagesy($preview));
|
$this->assertEquals(50, imagesy($preview));
|
||||||
|
|
||||||
|
|
@ -86,14 +92,16 @@ class MinecraftTest extends TestCase
|
||||||
|
|
||||||
public function testGeneratePreviewFromCape()
|
public function testGeneratePreviewFromCape()
|
||||||
{
|
{
|
||||||
imagepng(imagecreatetruecolor(128, 64), vfsStream::url('root/cape.png'));
|
$file = $this->fileFactory->image('cape.png');
|
||||||
$preview = Minecraft::generatePreviewFromCape(file_get_contents(vfsStream::url('root/cape.png')), 64);
|
|
||||||
|
imagepng(imagecreatetruecolor(128, 64), $file->path());
|
||||||
|
$preview = Minecraft::generatePreviewFromCape(file_get_contents($file->path()), 64);
|
||||||
$this->assertEquals(40, imagesx($preview));
|
$this->assertEquals(40, imagesx($preview));
|
||||||
$this->assertEquals(64, imagesy($preview));
|
$this->assertEquals(64, imagesy($preview));
|
||||||
|
|
||||||
imagepng(imagecreatetruecolor(128, 64), vfsStream::url('root/cape.png'));
|
imagepng(imagecreatetruecolor(128, 64), $file->path());
|
||||||
$preview = Minecraft::generatePreviewFromCape(
|
$preview = Minecraft::generatePreviewFromCape(
|
||||||
file_get_contents(vfsStream::url('root/cape.png')),
|
file_get_contents($file->path()),
|
||||||
64,
|
64,
|
||||||
281,
|
281,
|
||||||
250
|
250
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@ use App\Models\Closet;
|
||||||
use App\Models\Player;
|
use App\Models\Player;
|
||||||
use App\Models\Texture;
|
use App\Models\Texture;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use org\bovigo\vfs\vfsStream;
|
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
@ -16,17 +15,6 @@ class SkinlibControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
use DatabaseTransactions;
|
use DatabaseTransactions;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var \org\bovigo\vfs\vfsStreamDirectory
|
|
||||||
*/
|
|
||||||
private $vfs_root;
|
|
||||||
|
|
||||||
protected function setUp(): void
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
$this->vfs_root = vfsStream::setup();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function serializeTextures($textures)
|
protected function serializeTextures($textures)
|
||||||
{
|
{
|
||||||
return $textures
|
return $textures
|
||||||
|
|
@ -311,6 +299,8 @@ class SkinlibControllerTest extends TestCase
|
||||||
|
|
||||||
public function testShow()
|
public function testShow()
|
||||||
{
|
{
|
||||||
|
Storage::fake('textures');
|
||||||
|
|
||||||
// Cannot find texture
|
// Cannot find texture
|
||||||
$this->get('/skinlib/show/1')
|
$this->get('/skinlib/show/1')
|
||||||
->assertSee(trans('skinlib.show.deleted'));
|
->assertSee(trans('skinlib.show.deleted'));
|
||||||
|
|
@ -394,11 +384,10 @@ class SkinlibControllerTest extends TestCase
|
||||||
Storage::fake('textures');
|
Storage::fake('textures');
|
||||||
|
|
||||||
// Some error occurred when uploading file
|
// Some error occurred when uploading file
|
||||||
$file = vfsStream::newFile('test.png')
|
$file = UploadedFile::fake()->image('test.png');
|
||||||
->at($this->vfs_root);
|
|
||||||
$upload = new UploadedFile(
|
$upload = new UploadedFile(
|
||||||
$file->url(),
|
$file->path(),
|
||||||
$file->getName(),
|
'test.png',
|
||||||
'image/png',
|
'image/png',
|
||||||
50,
|
50,
|
||||||
UPLOAD_ERR_NO_TMP_DIR,
|
UPLOAD_ERR_NO_TMP_DIR,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user