From b37fad81d28aa4a89ef1d14443d15ffc49a17a8f Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Sun, 22 Jan 2017 12:50:35 -0200 Subject: [PATCH] Test files (#48) * Moved tests files to tests directory * fix in directory --- composer.lock | 125 +++++++++++++++++++++++++++++-- 60 => tests/60 | Bin faust.jpg => tests/faust.jpg | Bin lel.webp => tests/lel.webp | Bin mosconi.mp3 => tests/mosconi.mp3 | Bin pony.mp4 => tests/pony.mp4 | Bin swing.mp4 => tests/swing.mp4 | Bin testing.php => tests/testing.php | 30 ++++---- 8 files changed, 133 insertions(+), 22 deletions(-) rename 60 => tests/60 (100%) rename faust.jpg => tests/faust.jpg (100%) rename lel.webp => tests/lel.webp (100%) rename mosconi.mp3 => tests/mosconi.mp3 (100%) rename pony.mp4 => tests/pony.mp4 (100%) rename swing.mp4 => tests/swing.mp4 (100%) rename testing.php => tests/testing.php (73%) diff --git a/composer.lock b/composer.lock index b17a8122..951c4a31 100644 --- a/composer.lock +++ b/composer.lock @@ -61,21 +61,132 @@ "time": "2016-11-14 15:09:50" }, { - "name": "phpseclib/phpseclib", - "version": "2.0.x-dev", + "name": "paragonie/constant_time_encoding", + "version": "v2.0.3", "source": { "type": "git", - "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "00325a3050b320f1020aff42f8a44df6048013dd" + "url": "https://github.com/paragonie/constant_time_encoding.git", + "reference": "e085e08c939de49707dbf64315d178d90fbc708d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/00325a3050b320f1020aff42f8a44df6048013dd", - "reference": "00325a3050b320f1020aff42f8a44df6048013dd", + "url": "https://api.github.com/repos/paragonie/constant_time_encoding/zipball/e085e08c939de49707dbf64315d178d90fbc708d", + "reference": "e085e08c939de49707dbf64315d178d90fbc708d", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "ParagonIE\\ConstantTime\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com", + "role": "Maintainer" + }, + { + "name": "Steve 'Sc00bz' Thomas", + "email": "steve@tobtu.com", + "homepage": "https://www.tobtu.com", + "role": "Original Developer" + } + ], + "description": "Constant-time Implementations of RFC 4648 Encoding (Base-64, Base-32, Base-16)", + "keywords": [ + "base16", + "base32", + "base32_decode", + "base32_encode", + "base64", + "base64_decode", + "base64_encode", + "bin2hex", + "encoding", + "hex", + "hex2bin", + "rfc4648" + ], + "time": "2016-07-11 20:32:06" + }, + { + "name": "paragonie/random_compat", + "version": "v2.0.4", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e", + "reference": "a9b97968bcde1c4de2a5ec6cbd06a0f6c919b46e", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "autoload": { + "files": [ + "lib/random.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "pseudorandom", + "random" + ], + "time": "2016-11-07 23:38:38" + }, + { + "name": "phpseclib/phpseclib", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/phpseclib/phpseclib.git", + "reference": "74abcb45ed9de9508c61ab15371f1bc40292b9fd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/74abcb45ed9de9508c61ab15371f1bc40292b9fd", + "reference": "74abcb45ed9de9508c61ab15371f1bc40292b9fd", + "shasum": "" + }, + "require": { + "paragonie/constant_time_encoding": "^1|^2", + "paragonie/random_compat": "^1.4|^2.0", + "php": ">=7.0" }, "require-dev": { "phing/phing": "~2.7", diff --git a/60 b/tests/60 similarity index 100% rename from 60 rename to tests/60 diff --git a/faust.jpg b/tests/faust.jpg similarity index 100% rename from faust.jpg rename to tests/faust.jpg diff --git a/lel.webp b/tests/lel.webp similarity index 100% rename from lel.webp rename to tests/lel.webp diff --git a/mosconi.mp3 b/tests/mosconi.mp3 similarity index 100% rename from mosconi.mp3 rename to tests/mosconi.mp3 diff --git a/pony.mp4 b/tests/pony.mp4 similarity index 100% rename from pony.mp4 rename to tests/pony.mp4 diff --git a/swing.mp4 b/tests/swing.mp4 similarity index 100% rename from swing.mp4 rename to tests/swing.mp4 diff --git a/testing.php b/tests/testing.php similarity index 73% rename from testing.php rename to tests/testing.php index b8078bea..1d7fc193 100755 --- a/testing.php +++ b/tests/testing.php @@ -10,7 +10,7 @@ See the GNU Affero General Public License for more details. You should have received a copy of the GNU General Public License along with MadelineProto. If not, see . */ - +chdir(dirname(__FILE__).'/../'); require_once 'vendor/autoload.php'; if (file_exists('web_data.php')) { require_once 'web_data.php'; @@ -20,7 +20,7 @@ echo 'Deserializing MadelineProto from session.madeline...'.PHP_EOL; $MadelineProto = \danog\MadelineProto\Serialization::deserialize('session.madeline'); if (file_exists('.env')) { - $dotenv = new Dotenv\Dotenv(__DIR__); + $dotenv = new Dotenv\Dotenv(getcwd()); $dotenv->load(); } $settings = json_decode(getenv('MTPROTO_SETTINGS'), true) ?: []; @@ -52,34 +52,34 @@ $mention = $mention['user_id']; // Selects only the numeric user id $media = []; // Photo uploaded as document -$inputFile = $MadelineProto->upload('faust.jpg', 'fausticorn.jpg'); // This gets an inputFile object with file name magic -$media['document_photo'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('faust.jpg'), 'caption' => 'This file was uploaded using MadelineProto', 'attributes' => [['_' => 'documentAttributeImageSize', 'w' => 1280, 'h' => 914]]]; +$inputFile = $MadelineProto->upload('tests/faust.jpg', 'fausticorn.jpg'); // This gets an inputFile object with file name magic +$media['document_photo'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/faust.jpg'), 'caption' => 'This file was uploaded using MadelineProto', 'attributes' => [['_' => 'documentAttributeImageSize', 'w' => 1280, 'h' => 914]]]; // Photo -$media['photo'] = ['_' => 'inputMediaUploadedPhoto', 'file' => $inputFile, 'mime_type' => mime_content_type('faust.jpg'), 'caption' => 'This photo was uploaded using MadelineProto']; +$media['photo'] = ['_' => 'inputMediaUploadedPhoto', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/faust.jpg'), 'caption' => 'This photo was uploaded using MadelineProto']; // GIF -$inputFile = $MadelineProto->upload('pony.mp4'); -$media['gif'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('pony.mp4'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeAnimated']]]; +$inputFile = $MadelineProto->upload('tests/pony.mp4'); +$media['gif'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/pony.mp4'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeAnimated']]]; // Sticker -$inputFile = $MadelineProto->upload('lel.webp'); -$media['sticker'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('lel.webp'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeSticker', 'alt' => 'LEL', 'stickerset' => ['_' => 'inputStickerSetEmpty']]]]; +$inputFile = $MadelineProto->upload('tests/lel.webp'); +$media['sticker'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/lel.webp'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeSticker', 'alt' => 'LEL', 'stickerset' => ['_' => 'inputStickerSetEmpty']]]]; // Video -$inputFile = $MadelineProto->upload('swing.mp4'); -$media['video'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('swing.mp4'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeVideo', 'duration' => 5, 'w' => 1280, 'h' => 720]]]; +$inputFile = $MadelineProto->upload('tests/swing.mp4'); +$media['video'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/swing.mp4'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeVideo', 'duration' => 5, 'w' => 1280, 'h' => 720]]]; // audio -$inputFile = $MadelineProto->upload('mosconi.mp3'); -$media['audio'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('mosconi.mp3'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeAudio', 'voice' => false, 'duration' => 1, 'title' => 'AH NON LO SO', 'performer' => 'IL DIO GERARDO MOSCONI']]]; +$inputFile = $MadelineProto->upload('tests/mosconi.mp3'); +$media['audio'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/mosconi.mp3'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeAudio', 'voice' => false, 'duration' => 1, 'title' => 'AH NON LO SO', 'performer' => 'IL DIO GERARDO MOSCONI']]]; // voice -$media['voice'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('mosconi.mp3'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeAudio', 'voice' => true, 'duration' => 1, 'title' => 'AH NON LO SO', 'performer' => 'IL DIO GERARDO MOSCONI']]]; +$media['voice'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => mime_content_type('tests/mosconi.mp3'), 'caption' => 'test', 'attributes' => [['_' => 'documentAttributeAudio', 'voice' => true, 'duration' => 1, 'title' => 'AH NON LO SO', 'performer' => 'IL DIO GERARDO MOSCONI']]]; // Document $time = time(); -$inputFile = $MadelineProto->upload('60', 'magic'); // This gets an inputFile object with file name magic +$inputFile = $MadelineProto->upload('tests/60', 'magic'); // This gets an inputFile object with file name magic var_dump(time() - $time); $media['document'] = ['_' => 'inputMediaUploadedDocument', 'file' => $inputFile, 'mime_type' => 'magic/magic', 'caption' => 'This file was uploaded using MadelineProto', 'attributes' => [['_' => 'documentAttributeFilename', 'file_name' => 'magic.magic']]];