Compare commits
81 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba5c859d85 | ||
|
|
a731a1143c | ||
|
|
46013df620 | ||
|
|
f0bbf99306 | ||
|
|
c44b252aa8 | ||
|
|
34264cb7f5 | ||
|
|
7b98d7381f | ||
|
|
fa61e4507c | ||
|
|
f79c8c63e5 | ||
|
|
5b3d61cedc | ||
|
|
510103fd9f | ||
|
|
b890d768d1 | ||
|
|
27965d0287 | ||
|
|
8ed9fccf25 | ||
|
|
522c2721a2 | ||
|
|
17d7a6967e | ||
|
|
f6edcc1acd | ||
|
|
5b2ec7f7c2 | ||
|
|
5768b1e4bd | ||
|
|
23928d26f0 | ||
|
|
cbeb30adf1 | ||
|
|
b488359e35 | ||
|
|
9f541e6276 | ||
|
|
4aa95107d3 | ||
|
|
4f7b3d2ac3 | ||
|
|
5165845b54 | ||
|
|
05e236ed6c | ||
|
|
8c2cc18b66 | ||
|
|
d7e88b236e | ||
|
|
b48430cd4d | ||
|
|
b5d9850bee | ||
|
|
8b534ace28 | ||
|
|
2ad79ebf71 | ||
|
|
a376f894a9 | ||
|
|
43cd87c417 | ||
|
|
b8be814015 | ||
|
|
b73f4be25e | ||
|
|
f18770eaa6 | ||
|
|
878374979b | ||
|
|
abd722d0e4 | ||
|
|
16d6cfb1ac | ||
|
|
60bb381796 | ||
|
|
f2397ac532 | ||
|
|
ebf6a92c8f | ||
|
|
634b3a6605 | ||
|
|
e770065edf | ||
|
|
5f53150390 | ||
|
|
184b8b567d | ||
|
|
de6db843ba | ||
|
|
6caf1a5f06 | ||
|
|
bda1ab23b8 | ||
|
|
50fb12e3b3 | ||
|
|
955334ff91 | ||
|
|
fa7aa3e88c | ||
|
|
38c13398fc | ||
|
|
14de09789e | ||
|
|
595f9cf42e | ||
|
|
fb0d13937b | ||
|
|
26ae7db0eb | ||
|
|
0212429c4a | ||
|
|
484ab3cd84 | ||
|
|
7694c1460b | ||
|
|
8812b09f5f | ||
|
|
f5d8d7735f | ||
|
|
3a801bc238 | ||
|
|
91462da29d | ||
|
|
5c61a442a0 | ||
|
|
9c81d85bb7 | ||
|
|
168ce1d85c | ||
|
|
1f6b962468 | ||
|
|
1f95f57be9 | ||
|
|
a2e479192f | ||
|
|
3f469f715f | ||
|
|
09133f4f10 | ||
|
|
ec190fdcf6 | ||
|
|
17c3cb35c0 | ||
|
|
37a620df95 | ||
|
|
6f90df9545 | ||
|
|
99f50f6de3 | ||
|
|
50f81e1d2e | ||
|
|
4312f77385 |
46
.github/workflows/tests.yml
vendored
46
.github/workflows/tests.yml
vendored
@@ -1,5 +1,7 @@
|
||||
name: Tests
|
||||
on: [push]
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -12,23 +14,23 @@ jobs:
|
||||
run: composer validate
|
||||
- name: Install dependencies
|
||||
run: composer install --prefer-dist --no-dev
|
||||
|
||||
|
||||
PHPunit:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
|
||||
php-versions: ['7.3', '7.4', '8.0', '8.1', '8.2']
|
||||
name: PHP ${{ matrix.php-versions }} unit tests on ${{ matrix.operating-system }}
|
||||
env:
|
||||
extensions: gd, sqlite3
|
||||
extensions-cache-key-name: phpextensions
|
||||
|
||||
|
||||
steps:
|
||||
|
||||
|
||||
# let's get started!
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
|
||||
# cache PHP extensions
|
||||
- name: Setup cache environment
|
||||
id: extcache
|
||||
@@ -44,77 +46,75 @@ jobs:
|
||||
path: ${{ steps.extcache.outputs.dir }}
|
||||
key: ${{ steps.extcache.outputs.key }}
|
||||
restore-keys: ${{ runner.os }}-${{ env.extensions-cache-key }}
|
||||
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extensions: ${{ env.extensions }}
|
||||
|
||||
|
||||
# Setup GitHub CI PHP problem matchers
|
||||
# https://github.com/shivammathur/setup-php#problem-matchers
|
||||
- name: Setup problem matchers for PHP
|
||||
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
||||
|
||||
run: echo "::add-matcher::${{ runner.tool_cache }}/php.json"
|
||||
|
||||
- name: Setup problem matchers for PHPUnit
|
||||
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||
|
||||
|
||||
# composer cache
|
||||
- name: Remove composer lock
|
||||
run: rm composer.lock
|
||||
|
||||
|
||||
- name: Get composer cache directory
|
||||
id: composer-cache
|
||||
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
# http://man7.org/linux/man-pages/man1/date.1.html
|
||||
# https://github.com/actions/cache#creating-a-cache-key
|
||||
- name: Get Date
|
||||
id: get-date
|
||||
run: echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/composer.json') }}
|
||||
restore-keys: ${{ runner.os }}-composer-${{ steps.get-date.outputs.date }}-
|
||||
|
||||
|
||||
# composer installation
|
||||
- name: Setup PHPunit
|
||||
run: composer install -n
|
||||
|
||||
- name: Install Google Cloud Storage
|
||||
run: composer require google/cloud-storage
|
||||
|
||||
|
||||
# testing
|
||||
- name: Run unit tests
|
||||
run: ../vendor/bin/phpunit --no-coverage
|
||||
working-directory: tst
|
||||
|
||||
|
||||
Mocha:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: 'js/package-lock.json'
|
||||
|
||||
|
||||
- name: Setup Mocha
|
||||
run: npm install -g mocha
|
||||
|
||||
|
||||
- name: Setup Node modules
|
||||
run: npm ci
|
||||
working-directory: js
|
||||
|
||||
|
||||
- name: Run unit tests
|
||||
run: npm test
|
||||
working-directory: js
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"aws/aws-sdk-php" : "3.239.0"
|
||||
},
|
||||
"require-dev" : {
|
||||
"phpunit/phpunit" : "^4.6 || ^5.0"
|
||||
"phpunit/phpunit" : "^9"
|
||||
},
|
||||
"autoload" : {
|
||||
"psr-4" : {
|
||||
|
||||
1573
composer.lock
generated
1573
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Configuration;
|
||||
|
||||
class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
class ConfigurationTest extends TestCase
|
||||
{
|
||||
private $_minimalConfig;
|
||||
|
||||
@@ -10,7 +11,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
private $_path;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
Helper::confBackup();
|
||||
@@ -23,7 +24,7 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
Helper::rmDir($this->_path);
|
||||
@@ -55,13 +56,11 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($this->_options, $conf->get(), 'returns correct defaults on missing file');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 2
|
||||
*/
|
||||
public function testHandleBlankConfigFile()
|
||||
{
|
||||
file_put_contents(CONF, '');
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(2);
|
||||
new Configuration;
|
||||
}
|
||||
|
||||
@@ -72,25 +71,21 @@ class ConfigurationTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($this->_options, $conf->get(), 'returns correct defaults on empty file');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 3
|
||||
*/
|
||||
public function testHandleInvalidSection()
|
||||
{
|
||||
file_put_contents(CONF, $this->_minimalConfig);
|
||||
$conf = new Configuration;
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(3);
|
||||
$conf->getKey('foo', 'bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 4
|
||||
*/
|
||||
public function testHandleInvalidKey()
|
||||
{
|
||||
file_put_contents(CONF, $this->_minimalConfig);
|
||||
$conf = new Configuration;
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(4);
|
||||
$conf->getKey('foo');
|
||||
}
|
||||
|
||||
|
||||
@@ -408,13 +408,14 @@ class ConfigurationTestGenerator
|
||||
* DO NOT EDIT: This file is generated automatically using configGenerator.php
|
||||
*/
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Controller;
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\Request;
|
||||
|
||||
class ConfigurationCombinationsTest extends PHPUnit_Framework_TestCase
|
||||
class ConfigurationCombinationsTest extends TestCase
|
||||
{
|
||||
private $_conf;
|
||||
|
||||
@@ -422,7 +423,7 @@ class ConfigurationCombinationsTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
private $_path;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
Helper::confBackup();
|
||||
@@ -431,7 +432,7 @@ class ConfigurationCombinationsTest extends PHPUnit_Framework_TestCase
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
unlink(CONF);
|
||||
@@ -560,7 +561,7 @@ EOT;
|
||||
case 'Delete':
|
||||
$code .= <<<'EOT'
|
||||
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<div[^>]*id="status"[^>]*>.*Paste was properly deleted[^<]*</div>#s',
|
||||
$content,
|
||||
'outputs deleted status correctly'
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Controller;
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\Request;
|
||||
|
||||
class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
class ControllerTest extends TestCase
|
||||
{
|
||||
protected $_data;
|
||||
|
||||
protected $_path;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
@@ -22,7 +23,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
unlink(CONF);
|
||||
@@ -55,17 +56,17 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'<title>PrivateBin</title>',
|
||||
$content,
|
||||
'outputs title correctly'
|
||||
);
|
||||
$this->assertNotContains(
|
||||
$this->assertStringNotContainsString(
|
||||
'id="shortenbutton"',
|
||||
$content,
|
||||
'doesn\'t output shortener button'
|
||||
);
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'# href="https://' . preg_quote($_SERVER['HTTP_HOST']) . '/">switching to HTTPS#',
|
||||
$content,
|
||||
'outputs configured https URL correctly'
|
||||
@@ -85,7 +86,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'<title>PrivateBin</title>',
|
||||
$content,
|
||||
'outputs title correctly'
|
||||
@@ -106,7 +107,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertContains(
|
||||
$this->assertStringContainsString(
|
||||
'<title>PrivateBin</title>',
|
||||
$content,
|
||||
'outputs title correctly'
|
||||
@@ -127,7 +128,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#id="shortenbutton"[^>]*data-shortener="' . preg_quote($shortener) . '"#',
|
||||
$content,
|
||||
'outputs configured shortener URL correctly'
|
||||
@@ -141,6 +142,8 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
public function testConf()
|
||||
{
|
||||
file_put_contents(CONF, '');
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(2);
|
||||
new Controller;
|
||||
}
|
||||
|
||||
@@ -436,8 +439,6 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
* silently removed, check that this case is handled
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 90
|
||||
*/
|
||||
public function testCreateBrokenUpload()
|
||||
{
|
||||
@@ -449,6 +450,8 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
$_SERVER['REQUEST_METHOD'] = 'POST';
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
$this->assertFalse($this->_data->exists(Helper::getPasteId()), 'paste does not exists before posting data');
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(90);
|
||||
new Controller;
|
||||
$this->assertFalse($this->_data->exists(Helper::getPasteId()), 'paste exists after posting data');
|
||||
}
|
||||
@@ -806,7 +809,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<div[^>]*id="status"[^>]*>.*Paste was properly deleted\.#s',
|
||||
$content,
|
||||
'outputs deleted status correctly'
|
||||
@@ -826,7 +829,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Invalid paste ID\.#s',
|
||||
$content,
|
||||
'outputs delete error correctly'
|
||||
@@ -845,7 +848,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.#s',
|
||||
$content,
|
||||
'outputs delete error correctly'
|
||||
@@ -864,7 +867,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Wrong deletion token\. Paste was not deleted\.#s',
|
||||
$content,
|
||||
'outputs delete error correctly'
|
||||
@@ -912,7 +915,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<div[^>]*id="errormessage"[^>]*>.*Paste does not exist, has expired or has been deleted\.#s',
|
||||
$content,
|
||||
'outputs error correctly'
|
||||
@@ -935,7 +938,7 @@ class ControllerTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<div[^>]*id="status"[^>]*>.*Paste was properly deleted\.#s',
|
||||
$content,
|
||||
'outputs deleted status correctly'
|
||||
|
||||
@@ -17,7 +17,7 @@ class ControllerWithDbTest extends ControllerTest
|
||||
),
|
||||
);
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
|
||||
@@ -14,7 +14,7 @@ class ControllerWithGcsTest extends ControllerTest
|
||||
private static $_bucket;
|
||||
private $_options = array();
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
$httpClient = new Client(array('debug'=>false));
|
||||
$handler = HttpHandlerFactory::build($httpClient);
|
||||
@@ -28,7 +28,7 @@ class ControllerWithGcsTest extends ControllerTest
|
||||
self::$_bucket = self::$_client->createBucket($name);
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Controller;
|
||||
use PrivateBin\Data\Database;
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
|
||||
class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
class DatabaseTest extends TestCase
|
||||
{
|
||||
private $_model;
|
||||
|
||||
@@ -18,14 +19,14 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
);
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_model = Database::getInstance($this->_options);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
if (is_dir($this->_path)) {
|
||||
@@ -42,7 +43,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertNotEquals($salt, '');
|
||||
ServerSalt::setStore($this->_model);
|
||||
ServerSalt::get();
|
||||
$this->assertFileNotExists($file, 'legacy ServerSalt got removed');
|
||||
$this->assertFileDoesNotExist($file, 'legacy ServerSalt got removed');
|
||||
$this->assertEquals($salt, ServerSalt::get(), 'ServerSalt got preserved & migrated');
|
||||
}
|
||||
|
||||
@@ -136,124 +137,102 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PDOException
|
||||
*/
|
||||
public function testGetIbmInstance()
|
||||
{
|
||||
$this->expectException(PDOException::class);
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'ibm:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PDOException
|
||||
*/
|
||||
public function testGetInformixInstance()
|
||||
{
|
||||
$this->expectException(PDOException::class);
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'informix:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PDOException
|
||||
*/
|
||||
public function testGetMssqlInstance()
|
||||
{
|
||||
$this->expectException(PDOException::class);
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'mssql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PDOException
|
||||
*/
|
||||
public function testGetMysqlInstance()
|
||||
{
|
||||
$this->expectException(PDOException::class);
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'mysql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PDOException
|
||||
*/
|
||||
public function testGetOciInstance()
|
||||
{
|
||||
$this->expectException(PDOException::class);
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'oci:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PDOException
|
||||
*/
|
||||
public function testGetPgsqlInstance()
|
||||
{
|
||||
$this->expectException(PDOException::class);
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'pgsql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 5
|
||||
*/
|
||||
public function testGetFooInstance()
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(5);
|
||||
Database::getInstance(array(
|
||||
'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 6
|
||||
*/
|
||||
public function testMissingDsn()
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['dsn']);
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(6);
|
||||
Database::getInstance($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 6
|
||||
*/
|
||||
public function testMissingUsr()
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['usr']);
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(6);
|
||||
Database::getInstance($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 6
|
||||
*/
|
||||
public function testMissingPwd()
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['pwd']);
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(6);
|
||||
Database::getInstance($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 6
|
||||
*/
|
||||
public function testMissingOpt()
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['opt']);
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(6);
|
||||
Database::getInstance($options);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Data\Filesystem;
|
||||
|
||||
class FilesystemTest extends PHPUnit_Framework_TestCase
|
||||
class FilesystemTest extends TestCase
|
||||
{
|
||||
private $_model;
|
||||
|
||||
@@ -10,7 +11,7 @@ class FilesystemTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
private $_invalidPath;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
@@ -24,7 +25,7 @@ class FilesystemTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
chmod($this->_invalidPath, 0700);
|
||||
@@ -162,13 +163,13 @@ class FilesystemTest extends PHPUnit_Framework_TestCase
|
||||
$this->_model->purge(10);
|
||||
foreach ($ids as $dataid => $storagedir) {
|
||||
$this->assertFileExists($storagedir . $dataid . '.php', "paste $dataid exists in new format");
|
||||
$this->assertFileNotExists($storagedir . $dataid, "old format paste $dataid got removed");
|
||||
$this->assertFileDoesNotExist($storagedir . $dataid, "old format paste $dataid got removed");
|
||||
$this->assertTrue($this->_model->exists($dataid), "paste $dataid exists");
|
||||
$this->assertEquals($this->_model->read($dataid), $paste, "paste $dataid wasn't modified in the conversion");
|
||||
|
||||
$storagedir .= $dataid . '.discussion' . DIRECTORY_SEPARATOR;
|
||||
$this->assertFileExists($storagedir . $dataid . '.' . $commentid . '.' . $dataid . '.php', "comment of $dataid exists in new format");
|
||||
$this->assertFileNotExists($storagedir . $dataid . '.' . $commentid . '.' . $dataid, "old format comment of $dataid got removed");
|
||||
$this->assertFileDoesNotExist($storagedir . $dataid . '.' . $commentid . '.' . $dataid, "old format comment of $dataid got removed");
|
||||
$this->assertTrue($this->_model->existsComment($dataid, $dataid, $commentid), "comment in paste $dataid exists");
|
||||
$comment = $comment;
|
||||
$comment['id'] = $commentid;
|
||||
|
||||
@@ -2,14 +2,15 @@
|
||||
|
||||
use Google\Auth\HttpHandler\HttpHandlerFactory;
|
||||
use GuzzleHttp\Client;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Data\GoogleCloudStorage;
|
||||
|
||||
class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase
|
||||
class GoogleCloudStorageTest extends TestCase
|
||||
{
|
||||
private static $_client;
|
||||
private static $_bucket;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
$httpClient = new Client(array('debug'=>false));
|
||||
$handler = HttpHandlerFactory::build($httpClient);
|
||||
@@ -23,7 +24,7 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase
|
||||
self::$_bucket = self::$_client->createBucket($name);
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
ini_set('error_log', stream_get_meta_data(tmpfile())['uri']);
|
||||
$this->_model = GoogleCloudStorage::getInstance(array(
|
||||
@@ -32,14 +33,14 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase
|
||||
));
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
foreach (self::$_bucket->objects() as $object) {
|
||||
$object->delete();
|
||||
}
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
self::$_bucket->delete();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Filter;
|
||||
|
||||
class FilterTest extends PHPUnit_Framework_TestCase
|
||||
class FilterTest extends TestCase
|
||||
{
|
||||
public function testFilterMakesTimesHumanlyReadable()
|
||||
{
|
||||
@@ -12,12 +13,10 @@ class FilterTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('6 months', Filter::formatHumanReadableTime('6months'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 30
|
||||
*/
|
||||
public function testFilterFailTimesHumanlyReadable()
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(30);
|
||||
Filter::formatHumanReadableTime('five_minutes');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\FormatV2;
|
||||
|
||||
class FormatV2Test extends PHPUnit_Framework_TestCase
|
||||
class FormatV2Test extends TestCase
|
||||
{
|
||||
public function testFormatV2ValidatorValidatesCorrectly()
|
||||
{
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\I18n;
|
||||
|
||||
class I18nTest extends PHPUnit_Framework_TestCase
|
||||
class I18nTest extends TestCase
|
||||
{
|
||||
private $_translations = array();
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_translations = json_decode(
|
||||
@@ -15,9 +16,9 @@ class I18nTest extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
unset($_COOKIE['lang'], $_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
||||
}
|
||||
|
||||
public function testTranslationFallback()
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Controller;
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Request;
|
||||
|
||||
class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
class JsonApiTest extends TestCase
|
||||
{
|
||||
protected $_model;
|
||||
|
||||
protected $_path;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
@@ -33,7 +34,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
Helper::createIniFile(CONF, $options);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
unlink(CONF);
|
||||
@@ -286,7 +287,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertContains('id="pasteurl" href="https://example.com/1"', $content, 'outputs shortened URL correctly');
|
||||
$this->assertStringContainsString('id="pasteurl" href="https://example.com/1"', $content, 'outputs shortened URL correctly');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -300,6 +301,6 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
|
||||
new Controller;
|
||||
$content = ob_get_contents();
|
||||
ob_end_clean();
|
||||
$this->assertContains('Error calling YOURLS.', $content, 'outputs error correctly');
|
||||
$this->assertStringContainsString('Error calling YOURLS.', $content, 'outputs error correctly');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Jdenticon\Identicon;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Configuration;
|
||||
use PrivateBin\Data\Database;
|
||||
use PrivateBin\Model;
|
||||
@@ -10,7 +11,7 @@ use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
use PrivateBin\Vizhash16x16;
|
||||
|
||||
class ModelTest extends PHPUnit_Framework_TestCase
|
||||
class ModelTest extends TestCase
|
||||
{
|
||||
private $_conf;
|
||||
|
||||
@@ -18,7 +19,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
protected $_path;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
@@ -44,7 +45,7 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$_SERVER['REMOTE_ADDR'] = '::1';
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
unlink(CONF);
|
||||
@@ -167,10 +168,6 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(Helper::getPasteId(), $comment->getParentId(), 'comment parent ID gets initialized to paste ID');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 75
|
||||
*/
|
||||
public function testPasteDuplicate()
|
||||
{
|
||||
$pasteData = Helper::getPastePost();
|
||||
@@ -182,13 +179,11 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$paste = $this->_model->getPaste();
|
||||
$paste->setData($pasteData);
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(75);
|
||||
$paste->store();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 76
|
||||
*/
|
||||
public function testStoreFail()
|
||||
{
|
||||
$path = $this->_path . DIRECTORY_SEPARATOR . 'model-store-test.sq3';
|
||||
@@ -225,13 +220,11 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$paste = $model->getPaste();
|
||||
$paste->setData($pasteData);
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(76);
|
||||
$paste->store();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 70
|
||||
*/
|
||||
public function testCommentStoreFail()
|
||||
{
|
||||
$path = $this->_path . DIRECTORY_SEPARATOR . 'model-test.sq3';
|
||||
@@ -273,13 +266,11 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$comment = $paste->getComment(Helper::getPasteId());
|
||||
$comment->setData($commentData);
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(70);
|
||||
$comment->store();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 69
|
||||
*/
|
||||
public function testCommentDuplicate()
|
||||
{
|
||||
$pasteData = Helper::getPastePost();
|
||||
@@ -296,6 +287,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$comment = $paste->getComment(Helper::getPasteId());
|
||||
$comment->setData($commentData);
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(69);
|
||||
$comment->store();
|
||||
}
|
||||
|
||||
@@ -334,52 +327,40 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertFalse(Paste::isValidId('../bar/baz'), 'path attack');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 64
|
||||
*/
|
||||
public function testInvalidPaste()
|
||||
{
|
||||
$this->_model->getPaste(Helper::getPasteId())->delete();
|
||||
$paste = $this->_model->getPaste(Helper::getPasteId());
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(64);
|
||||
$paste->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 75
|
||||
*/
|
||||
public function testInvalidPasteFormat()
|
||||
{
|
||||
$pasteData = Helper::getPastePost();
|
||||
$pasteData['adata'][1] = 'format does not exist';
|
||||
$paste = $this->_model->getPaste();
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(75);
|
||||
$paste->setData($pasteData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 60
|
||||
*/
|
||||
public function testInvalidPasteId()
|
||||
{
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(60);
|
||||
$this->_model->getPaste('');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 62
|
||||
*/
|
||||
public function testInvalidComment()
|
||||
{
|
||||
$paste = $this->_model->getPaste();
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(62);
|
||||
$paste->getComment(Helper::getPasteId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 67
|
||||
*/
|
||||
public function testInvalidCommentDeletedPaste()
|
||||
{
|
||||
$pasteData = Helper::getPastePost();
|
||||
@@ -389,13 +370,11 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$comment = $paste->getComment(Helper::getPasteId());
|
||||
$paste->delete();
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(67);
|
||||
$comment->store();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 68
|
||||
*/
|
||||
public function testInvalidCommentData()
|
||||
{
|
||||
$pasteData = Helper::getPastePost();
|
||||
@@ -405,18 +384,17 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$paste->store();
|
||||
|
||||
$comment = $paste->getComment(Helper::getPasteId());
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(68);
|
||||
$comment->store();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 65
|
||||
*/
|
||||
public function testInvalidCommentParent()
|
||||
{
|
||||
$paste = $this->_model->getPaste(Helper::getPasteId());
|
||||
$comment = $paste->getComment('');
|
||||
$comment->store();
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(65);
|
||||
$paste->getComment('');
|
||||
}
|
||||
|
||||
public function testExpiration()
|
||||
@@ -434,10 +412,6 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals((float) 300, (float) $paste['meta']['time_to_live'], 'remaining time is set correctly', 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 64
|
||||
*/
|
||||
public function testCommentDeletion()
|
||||
{
|
||||
$pasteData = Helper::getPastePost();
|
||||
@@ -446,6 +420,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||
$paste = $this->_model->getPaste();
|
||||
$paste->setData($pasteData);
|
||||
$paste->store();
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(64);
|
||||
$paste->getComment(Helper::getPasteId())->delete();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\Persistence\PurgeLimiter;
|
||||
|
||||
class PurgeLimiterTest extends PHPUnit_Framework_TestCase
|
||||
class PurgeLimiterTest extends TestCase
|
||||
{
|
||||
private $_path;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
@@ -19,7 +20,7 @@ class PurgeLimiterTest extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
Helper::rmDir($this->_path);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
|
||||
class ServerSaltTest extends PHPUnit_Framework_TestCase
|
||||
class ServerSaltTest extends TestCase
|
||||
{
|
||||
private $_path;
|
||||
|
||||
@@ -13,7 +14,7 @@ class ServerSaltTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
private $_invalidFile;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
@@ -33,7 +34,7 @@ class ServerSaltTest extends PHPUnit_Framework_TestCase
|
||||
$this->_invalidFile = $this->_invalidPath . DIRECTORY_SEPARATOR . 'salt.php';
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
chmod($this->_invalidPath, 0700);
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Persistence\TrafficLimiter;
|
||||
|
||||
class TrafficLimiterTest extends PHPUnit_Framework_TestCase
|
||||
class TrafficLimiterTest extends TestCase
|
||||
{
|
||||
private $_path;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'trafficlimit';
|
||||
@@ -17,7 +18,7 @@ class TrafficLimiterTest extends PHPUnit_Framework_TestCase
|
||||
TrafficLimiter::setStore($store);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
Helper::rmDir($this->_path . DIRECTORY_SEPARATOR);
|
||||
|
||||
@@ -1,19 +1,10 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Request;
|
||||
|
||||
class RequestTest extends PHPUnit_Framework_TestCase
|
||||
class RequestTest extends TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
}
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$_SERVER = array();
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\I18n;
|
||||
use PrivateBin\View;
|
||||
|
||||
class ViewTest extends PHPUnit_Framework_TestCase
|
||||
class ViewTest extends TestCase
|
||||
{
|
||||
private static $error = 'foo bar';
|
||||
|
||||
@@ -29,7 +30,7 @@ class ViewTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
private $_content = array();
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$page = new View;
|
||||
@@ -93,15 +94,10 @@ class ViewTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
}
|
||||
|
||||
public function testTemplateRendersCorrectly()
|
||||
{
|
||||
foreach ($this->_content as $template => $content) {
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<div[^>]+id="errormessage"[^>]*>.*' . self::$error . '#s',
|
||||
$content,
|
||||
$template . ': outputs error correctly'
|
||||
@@ -110,23 +106,23 @@ class ViewTest extends PHPUnit_Framework_TestCase
|
||||
// yourlsproxy template only displays error message
|
||||
continue;
|
||||
}
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<[^>]+id="password"[^>]*>#',
|
||||
$content,
|
||||
$template . ': password available if configured'
|
||||
);
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<input[^>]+id="opendiscussion"[^>]*checked="checked"[^>]*>#',
|
||||
$content,
|
||||
$template . ': checked discussion if configured'
|
||||
);
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<[^>]+id="opendiscussionoption"[^>]*>#',
|
||||
$content,
|
||||
$template . ': discussions available if configured'
|
||||
);
|
||||
// testing version number in JS address, since other instances may not be present in different templates
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'#<script[^>]+src="js/privatebin.js\\?' . rawurlencode(self::$version) . '"[^>]*>#',
|
||||
$content,
|
||||
$template . ': outputs version correctly'
|
||||
@@ -134,13 +130,11 @@ class ViewTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionCode 80
|
||||
*/
|
||||
public function testMissingTemplate()
|
||||
{
|
||||
$test = new View;
|
||||
$this->expectException(Exception::class);
|
||||
$this->expectExceptionCode(80);
|
||||
$test->draw('123456789 does not exist!');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Data\Filesystem;
|
||||
use PrivateBin\Persistence\ServerSalt;
|
||||
use PrivateBin\Vizhash16x16;
|
||||
|
||||
class Vizhash16x16Test extends PHPUnit_Framework_TestCase
|
||||
class Vizhash16x16Test extends TestCase
|
||||
{
|
||||
private $_file;
|
||||
|
||||
private $_path;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
@@ -21,7 +22,7 @@ class Vizhash16x16Test extends PHPUnit_Framework_TestCase
|
||||
ServerSalt::setStore(Filesystem::getInstance(array('dir' => $this->_path)));
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
chmod($this->_path, 0700);
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PrivateBin\Configuration;
|
||||
use PrivateBin\YourlsProxy;
|
||||
|
||||
class YourlsProxyTest extends PHPUnit_Framework_TestCase
|
||||
class YourlsProxyTest extends TestCase
|
||||
{
|
||||
private $_conf;
|
||||
|
||||
@@ -11,7 +12,7 @@ class YourlsProxyTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
private $_mock_yourls_service;
|
||||
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
@@ -28,7 +29,7 @@ class YourlsProxyTest extends PHPUnit_Framework_TestCase
|
||||
$this->_conf = new Configuration;
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
public function tearDown(): void
|
||||
{
|
||||
/* Tear Down Routine */
|
||||
unlink(CONF);
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
<phpunit bootstrap="Bootstrap.php" colors="true">
|
||||
<testsuite name="PrivateBin Test Suite">
|
||||
<directory suffix=".php">./</directory>
|
||||
<exclude>ConfigurationTestGenerator.php</exclude>
|
||||
</testsuite>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">../lib</directory>
|
||||
<exclude>
|
||||
<file>../lib/Data/AbstractData.php</file>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="log/coverage-clover.xml" />
|
||||
<log type="coverage-html" target="log/php-coverage-report" lowUpperBound="50" highLowerBound="80" />
|
||||
<log type="testdox-html" target="log/testdox.html" />
|
||||
</logging>
|
||||
<?xml version="1.0"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="Bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage>
|
||||
<include>
|
||||
<directory suffix=".php">../lib</directory>
|
||||
</include>
|
||||
<exclude>
|
||||
<file>../lib/Data/AbstractData.php</file>
|
||||
</exclude>
|
||||
<report>
|
||||
<clover outputFile="log/coverage-clover.xml"/>
|
||||
<html outputDirectory="log/php-coverage-report" lowUpperBound="50" highLowerBound="80"/>
|
||||
</report>
|
||||
</coverage>
|
||||
<testsuite name="PrivateBin Test Suite">
|
||||
<directory suffix=".php">./</directory>
|
||||
<exclude>ConfigurationTestGenerator.php</exclude>
|
||||
</testsuite>
|
||||
<logging>
|
||||
<testdoxHtml outputFile="log/testdox.html"/>
|
||||
</logging>
|
||||
</phpunit>
|
||||
|
||||
10
vendor/composer/installed.php
vendored
10
vendor/composer/installed.php
vendored
@@ -5,18 +5,18 @@
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '78aa70e3ab9277172489f9d88f8fd08cc1d03c97',
|
||||
'reference' => '46013df6201304840c8dab82af63cc9000a6d239',
|
||||
'name' => 'privatebin/privatebin',
|
||||
'dev' => false,
|
||||
),
|
||||
'versions' => array(
|
||||
'jdenticon/jdenticon' => array(
|
||||
'pretty_version' => '1.0.1',
|
||||
'version' => '1.0.1.0',
|
||||
'pretty_version' => '1.0.2',
|
||||
'version' => '1.0.2.0',
|
||||
'type' => 'library',
|
||||
'install_path' => __DIR__ . '/../jdenticon/jdenticon',
|
||||
'aliases' => array(),
|
||||
'reference' => '994ee07293fb978f983393ffcb2c0250592a6ac4',
|
||||
'reference' => 'cabb7a44c413c318392a341c5d3ca30fcdd57a6f',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'mlocati/ip-lib' => array(
|
||||
@@ -43,7 +43,7 @@
|
||||
'type' => 'project',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
'reference' => '78aa70e3ab9277172489f9d88f8fd08cc1d03c97',
|
||||
'reference' => '46013df6201304840c8dab82af63cc9000a6d239',
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'yzalis/identicon' => array(
|
||||
|
||||
@@ -21,6 +21,15 @@ class SuperSampleBuffer
|
||||
const IDX_G = 3;
|
||||
const IDX_B = 4;
|
||||
|
||||
private $samples;
|
||||
private $samplesPerPixel;
|
||||
|
||||
private $pixelOffset;
|
||||
private $subPixelOffset;
|
||||
|
||||
private $width;
|
||||
private $used;
|
||||
|
||||
/**
|
||||
* Creates a color buffer keeping an average color out of several
|
||||
* color samples per pixel.
|
||||
|
||||
Reference in New Issue
Block a user