Navigation Menu

Skip to content

Commit

Permalink
Coding style: manually fix remaining errors in tests after PHPCBF
Browse files Browse the repository at this point in the history
Related to #95
  • Loading branch information
ArthurHoaro committed Apr 5, 2021
1 parent 0681511 commit 830a73d
Show file tree
Hide file tree
Showing 61 changed files with 243 additions and 194 deletions.
6 changes: 6 additions & 0 deletions composer.json
Expand Up @@ -71,5 +71,11 @@
"Shaarli\\Updater\\": "application/updater",
"Shaarli\\Updater\\Exception\\": "application/updater/exception"
}
},
"autoload-dev": {
"psr-4": {
"Shaarli\\Tests\\": "tests",
"Shaarli\\Tests\\Utils\\": "tests/utils"
}
}
}
6 changes: 6 additions & 0 deletions phpcs.xml
Expand Up @@ -19,5 +19,11 @@
<!-- index.php bootstraps everything, so yes mixed symbols with side effects -->
<exclude-pattern>index.php</exclude-pattern>
<exclude-pattern>plugins/*</exclude-pattern>
<exclude-pattern>tests/bootstrap.php</exclude-pattern>
<exclude-pattern>tests/utils/RainTPL.php</exclude-pattern>
</rule>

<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace">
<exclude-pattern>tests/utils/RainTPL.php</exclude-pattern>
</rule>
</ruleset>
4 changes: 2 additions & 2 deletions tests/ThumbnailerTest.php
Expand Up @@ -15,9 +15,9 @@
*/
class ThumbnailerTest extends TestCase
{
const WIDTH = 190;
protected const WIDTH = 190;

const HEIGHT = 210;
protected const HEIGHT = 210;

/**
* @var Thumbnailer;
Expand Down
6 changes: 4 additions & 2 deletions tests/TimeZoneTest.php
Expand Up @@ -4,12 +4,14 @@
* TimeZone's tests
*/

require_once 'application/TimeZone.php';
namespace Shaarli\Tests;

use Shaarli\TestCase;

/**
* Unitary tests for timezone utilities
*/
class TimeZoneTest extends \Shaarli\TestCase
class TimeZoneTest extends TestCase
{
/**
* @var array of timezones
Expand Down
9 changes: 5 additions & 4 deletions tests/UtilsTest.php
Expand Up @@ -4,14 +4,15 @@
* Utilities' tests
*/

require_once 'application/Utils.php';
require_once 'application/Languages.php';
namespace Shaarli\Tests;

use DateTime;
use Shaarli\TestCase;

/**
* Unitary tests for Shaarli utilities
*/
class UtilsTest extends \Shaarli\TestCase
class UtilsTest extends TestCase
{
// Log file
protected static $testLogFile = 'tests.log';
Expand Down Expand Up @@ -55,7 +56,7 @@ protected function setUp(): void
/**
* Returns a list of the elements from the last logged entry
*
* @return list (date, ip address, message)
* @return array (date, ip address, message)
*/
protected function getLastLogEntry()
{
Expand Down
5 changes: 3 additions & 2 deletions tests/api/ApiMiddlewareTest.php
Expand Up @@ -5,6 +5,7 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
Expand Down Expand Up @@ -33,7 +34,7 @@ class ApiMiddlewareTest extends \Shaarli\TestCase
protected $conf;

/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;

Expand All @@ -50,7 +51,7 @@ protected function setUp(): void
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('api.secret', 'NapoleonWasALizard');

$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);

$history = new History('sandbox/history.php');
Expand Down
10 changes: 5 additions & 5 deletions tests/api/controllers/history/HistoryTest.php
Expand Up @@ -4,14 +4,14 @@

use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\ReferenceHistory;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
use Slim\Http\Response;

require_once 'tests/utils/ReferenceHistory.php';

class HistoryTest extends \Shaarli\TestCase
class HistoryTest extends TestCase
{
/**
* @var string datastore to test write operations
Expand All @@ -24,7 +24,7 @@ class HistoryTest extends \Shaarli\TestCase
protected $conf;

/**
* @var \ReferenceHistory instance.
* @var ReferenceHistory instance.
*/
protected $refHistory = null;

Expand All @@ -44,7 +44,7 @@ class HistoryTest extends \Shaarli\TestCase
protected function setUp(): void
{
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->refHistory = new \ReferenceHistory();
$this->refHistory = new ReferenceHistory();
$this->refHistory->write(self::$testHistory);
$this->container = new Container();
$this->container['conf'] = $this->conf;
Expand Down
9 changes: 5 additions & 4 deletions tests/api/controllers/info/InfoTest.php
Expand Up @@ -8,6 +8,7 @@
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
Expand All @@ -33,7 +34,7 @@ class InfoTest extends TestCase
protected $conf;

/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;

Expand All @@ -55,7 +56,7 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$this->pluginManager = new PluginManager($this->conf);
$history = new History('sandbox/history.php');
Expand Down Expand Up @@ -96,7 +97,7 @@ public function testGetInfo()
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);

$this->assertEquals(\ReferenceLinkDB::$NB_LINKS_TOTAL, $data['global_counter']);
$this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, $data['global_counter']);
$this->assertEquals(2, $data['private_counter']);
$this->assertEquals('Shaarli', $data['settings']['title']);
$this->assertEquals('?', $data['settings']['header_link']);
Expand All @@ -119,7 +120,7 @@ public function testGetInfo()
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);

$this->assertEquals(\ReferenceLinkDB::$NB_LINKS_TOTAL, $data['global_counter']);
$this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, $data['global_counter']);
$this->assertEquals(2, $data['private_counter']);
$this->assertEquals($title, $data['settings']['title']);
$this->assertEquals($headerLink, $data['settings']['header_link']);
Expand Down
8 changes: 5 additions & 3 deletions tests/api/controllers/links/DeleteLinkTest.php
Expand Up @@ -7,6 +7,8 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceHistory;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
Expand All @@ -30,7 +32,7 @@ class DeleteLinkTest extends \Shaarli\TestCase
protected $conf;

/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;

Expand Down Expand Up @@ -68,9 +70,9 @@ protected function setUp(): void
$this->mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$refHistory = new \ReferenceHistory();
$refHistory = new ReferenceHistory();
$refHistory->write(self::$testHistory);
$this->history = new History(self::$testHistory);
$this->pluginManager = new PluginManager($this->conf);
Expand Down
7 changes: 4 additions & 3 deletions tests/api/controllers/links/GetLinkIdTest.php
Expand Up @@ -8,6 +8,7 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
Expand Down Expand Up @@ -35,7 +36,7 @@ class GetLinkIdTest extends \Shaarli\TestCase
protected $conf;

/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;

Expand All @@ -52,7 +53,7 @@ class GetLinkIdTest extends \Shaarli\TestCase
/**
* Number of JSON fields per link.
*/
const NB_FIELDS_LINK = 9;
protected const NB_FIELDS_LINK = 9;

/**
* Before each test, instantiate a new Api with its config, plugins and bookmarks.
Expand All @@ -62,7 +63,7 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$history = new History('sandbox/history.php');

Expand Down
9 changes: 5 additions & 4 deletions tests/api/controllers/links/GetLinksTest.php
Expand Up @@ -9,6 +9,7 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
Expand Down Expand Up @@ -36,7 +37,7 @@ class GetLinksTest extends \Shaarli\TestCase
protected $conf;

/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;

Expand All @@ -53,7 +54,7 @@ class GetLinksTest extends \Shaarli\TestCase
/**
* Number of JSON field per link.
*/
const NB_FIELDS_LINK = 9;
protected const NB_FIELDS_LINK = 9;

/**
* Before every test, instantiate a new Api with its config, plugins and bookmarks.
Expand All @@ -63,7 +64,7 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$history = new History('sandbox/history.php');

Expand Down Expand Up @@ -431,7 +432,7 @@ public function testGetLinksSearchTags()
$response = $this->controller->getLinks($request, new Response());
$this->assertEquals(200, $response->getStatusCode());
$data = json_decode((string) $response->getBody(), true);
$this->assertEquals(\ReferenceLinkDB::$NB_LINKS_TOTAL, count($data));
$this->assertEquals(ReferenceLinkDB::$NB_LINKS_TOTAL, count($data));
$this->assertEquals(10, $data[0]['id']);
$this->assertEquals(41, $data[2]['id']);

Expand Down
10 changes: 6 additions & 4 deletions tests/api/controllers/links/PostLinkTest.php
Expand Up @@ -9,6 +9,8 @@
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\TestCase;
use Shaarli\Tests\Utils\ReferenceHistory;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
Expand Down Expand Up @@ -40,7 +42,7 @@ class PostLinkTest extends TestCase
protected $conf;

/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;

Expand All @@ -67,7 +69,7 @@ class PostLinkTest extends TestCase
/**
* Number of JSON field per link.
*/
const NB_FIELDS_LINK = 9;
protected const NB_FIELDS_LINK = 9;

/**
* Before every test, instantiate a new Api with its config, plugins and bookmarks.
Expand All @@ -77,9 +79,9 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$refHistory = new \ReferenceHistory();
$refHistory = new ReferenceHistory();
$refHistory->write(self::$testHistory);
$this->history = new History(self::$testHistory);
$pluginManager = new PluginManager($this->conf);
Expand Down
10 changes: 6 additions & 4 deletions tests/api/controllers/links/PutLinkTest.php
Expand Up @@ -8,6 +8,8 @@
use Shaarli\Config\ConfigManager;
use Shaarli\History;
use Shaarli\Plugin\PluginManager;
use Shaarli\Tests\Utils\ReferenceHistory;
use Shaarli\Tests\Utils\ReferenceLinkDB;
use Slim\Container;
use Slim\Http\Environment;
use Slim\Http\Request;
Expand All @@ -31,7 +33,7 @@ class PutLinkTest extends \Shaarli\TestCase
protected $conf;

/**
* @var \ReferenceLinkDB instance.
* @var ReferenceLinkDB instance.
*/
protected $refDB = null;

Expand All @@ -58,7 +60,7 @@ class PutLinkTest extends \Shaarli\TestCase
/**
* Number of JSON field per link.
*/
const NB_FIELDS_LINK = 9;
protected const NB_FIELDS_LINK = 9;

/**
* Before every test, instantiate a new Api with its config, plugins and bookmarks.
Expand All @@ -68,9 +70,9 @@ protected function setUp(): void
$mutex = new NoMutex();
$this->conf = new ConfigManager('tests/utils/config/configJson');
$this->conf->set('resource.datastore', self::$testDatastore);
$this->refDB = new \ReferenceLinkDB();
$this->refDB = new ReferenceLinkDB();
$this->refDB->write(self::$testDatastore);
$refHistory = new \ReferenceHistory();
$refHistory = new ReferenceHistory();
$refHistory->write(self::$testHistory);
$this->history = new History(self::$testHistory);
$pluginManager = new PluginManager($this->conf);
Expand Down

0 comments on commit 830a73d

Please sign in to comment.