mirror of
https://code.mensbeam.com/MensBeam/Arsse.git
synced 2024-12-22 05:02:40 +00:00
Change some conditions to asserts
This commit is contained in:
parent
d0f780d4e6
commit
fb6e2babb9
4 changed files with 7 additions and 13 deletions
|
@ -126,7 +126,7 @@ class RoboFile extends \Robo\Tasks {
|
|||
$execpath = norm(BASE."vendor-bin/phpunit/vendor/phpunit/phpunit/phpunit");
|
||||
$confpath = realpath(BASE_TEST."phpunit.dist.xml") ?: norm(BASE_TEST."phpunit.xml");
|
||||
$this->taskServer(8000)->host("localhost")->dir(BASE_TEST."docroot")->rawArg("-n")->arg(BASE_TEST."server.php")->rawArg($this->blackhole())->background()->run();
|
||||
return $this->taskExec($executor)->arg($execpath)->option("-c", $confpath)->args(array_merge($set, $args))->run();
|
||||
return $this->taskExec($executor)->option("-d", "zend.assertions=1")->arg($execpath)->option("-c", $confpath)->args(array_merge($set, $args))->run();
|
||||
}
|
||||
|
||||
/** Packages a given commit of the software into a release tarball
|
||||
|
|
|
@ -198,13 +198,11 @@ class Database {
|
|||
* @param boolean $matchAny Whether the search is successful when it matches any (true) or all (false) terms
|
||||
*/
|
||||
protected function generateSearch(array $terms, array $cols, bool $matchAny = false): array {
|
||||
if (!$cols) {
|
||||
throw new Exception("arrayEmpty", "cols"); // @codeCoverageIgnore
|
||||
}
|
||||
$clause = [];
|
||||
$types = [];
|
||||
$values = [];
|
||||
$like = $this->db->sqlToken("like");
|
||||
assert(sizeof($cols) > 0, new Exception("arrayEmpty", "cols"));
|
||||
$embedSet = sizeof($terms) > ((int) (self::LIMIT_SET_SIZE / sizeof($cols)));
|
||||
foreach ($terms as $term) {
|
||||
$embedTerm = ($embedSet && strlen($term) <= self::LIMIT_SET_STRING_LENGTH);
|
||||
|
@ -2081,9 +2079,7 @@ class Database {
|
|||
* @param boolean $byName Whether to interpret the $id parameter as the label's name (true) or identifier (false)
|
||||
*/
|
||||
public function labelArticlesSet(string $user, $id, Context $context, int $mode = self::ASSOC_ADD, bool $byName = false): int {
|
||||
if (!in_array($mode, [self::ASSOC_ADD, self::ASSOC_REMOVE, self::ASSOC_REPLACE])) {
|
||||
throw new Exception("constantUnknown", $mode); // @codeCoverageIgnore
|
||||
}
|
||||
assert(in_array($mode, [self::ASSOC_ADD, self::ASSOC_REMOVE, self::ASSOC_REPLACE]), new Exception("constantUnknown", $mode));
|
||||
if (!Arsse::$user->authorize($user, __FUNCTION__)) {
|
||||
throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
|
||||
}
|
||||
|
@ -2386,9 +2382,7 @@ class Database {
|
|||
* @param boolean $byName Whether to interpret the $id parameter as the tag's name (true) or identifier (false)
|
||||
*/
|
||||
public function tagSubscriptionsSet(string $user, $id, array $subscriptions, int $mode = self::ASSOC_ADD, bool $byName = false): int {
|
||||
if (!in_array($mode, [self::ASSOC_ADD, self::ASSOC_REMOVE, self::ASSOC_REPLACE])) {
|
||||
throw new Exception("constantUnknown", $mode); // @codeCoverageIgnore
|
||||
}
|
||||
assert(in_array($mode, [self::ASSOC_ADD, self::ASSOC_REMOVE, self::ASSOC_REPLACE]), new Exception("constantUnknown", $mode));
|
||||
if (!Arsse::$user->authorize($user, __FUNCTION__)) {
|
||||
throw new User\ExceptionAuthz("notAuthorized", ["action" => __FUNCTION__, "user" => $user]);
|
||||
}
|
||||
|
|
|
@ -56,9 +56,7 @@ abstract class AbstractStatement implements Statement {
|
|||
$this->retypeArray($binding, true);
|
||||
} else {
|
||||
$bindId = self::TYPES[trim(strtolower($binding))] ?? 0;
|
||||
if (!$bindId) {
|
||||
throw new Exception("paramTypeInvalid", $binding); // @codeCoverageIgnore
|
||||
}
|
||||
assert($bindId, new Exception("paramTypeInvalid", $binding));
|
||||
$this->types[] = $bindId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,5 +10,7 @@ const NS_BASE = __NAMESPACE__."\\";
|
|||
define(NS_BASE."BASE", dirname(__DIR__).DIRECTORY_SEPARATOR);
|
||||
const DOCROOT = BASE."tests".DIRECTORY_SEPARATOR."docroot".DIRECTORY_SEPARATOR;
|
||||
ini_set("memory_limit", "-1");
|
||||
ini_set("zend.assertions", "1");
|
||||
ini_set("assert.exception", "true");
|
||||
error_reporting(\E_ALL);
|
||||
require_once BASE."vendor".DIRECTORY_SEPARATOR."autoload.php";
|
||||
|
|
Loading…
Reference in a new issue