Unit test fixes

This commit is contained in:
Dennis Eichhorn 2017-03-19 15:49:21 +01:00
parent 082a493cc7
commit a03f6ee047
8 changed files with 63 additions and 16 deletions

View File

@ -29,6 +29,7 @@ use phpOMS\Datatypes\Enum;
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
* @todo Should be changed to int instead of string
*/
abstract class AssetType extends Enum
{

View File

@ -88,6 +88,42 @@ class NetPromoterScore {
$total = $promoters + $passives + $detractors;
return ((int) ($promoters / $total)) - ((int) ($detractors / $total));
return $total === 0 ? 0 : ((int) ($promoters * 100 / $total)) - ((int) ($detractors * 100 / $total));
}
public function countDetractors() : int
{
$count = 0;
foreach($this->scores as $score) {
if($score < 7) {
$count++;
}
}
return $count;
}
public function countPassives() : int
{
$count = 0;
foreach($this->scores as $score) {
if($score > 6 && $score < 9) {
$count++;
}
}
return $count;
}
public function countPromoters() : int
{
$count = 0;
foreach($this->scores as $score) {
if($score > 8) {
$count++;
}
}
return $count;
}
}

View File

@ -38,7 +38,7 @@ abstract class CacheType extends Enum
/* public */ const _STRING = 1; /* Data is string */
/* public */ const _ARRAY = 2; /* Data is array */
/* public */ const _SERIALIZABLE = 3; /* Data is object */
/* public */ const _JSONSERIALIZABLE = 6;
/* public */ const _FLOAT = 4; /* Data is float */
/* public */ const _BOOL = 5; /* Data is float */
/* public */ const _BOOL = 5; /* Data is bool */
/* public */ const _JSONSERIALIZABLE = 6;
}

View File

@ -33,7 +33,6 @@ use phpOMS\Datatypes\Enum;
abstract class ResponseType extends Enum
{
/* public */ const HTTP = 0; /* HTTP */
/* public */ const JSON = 1; /* JSON */
/* public */ const SOCKET = 2; /* Socket */
/* public */ const CONSOLE = 3; /* Console */
/* public */ const SOCKET = 1; /* Socket */
/* public */ const CONSOLE = 2; /* Console */
}

View File

@ -63,7 +63,7 @@ class Router
*/
public function importFromFile(string $path) : bool
{
if (stream_resolve_include_path($path) !== false) {
if (file_exists($path)) {
/** @noinspection PhpIncludeInspection */
$this->routes += include $path;

View File

@ -32,10 +32,10 @@ use phpOMS\Datatypes\Enum;
*/
abstract class PriorityMode extends Enum
{
/* public */ const FIFO = 0;
/* public */ const LIFO = 0;
/* public */ const EARLIEST_DEADLINE = 0;
/* public */ const SHORTEST_JOB = 0;
/* public */ const HIGHEST = 0;
/* public */ const LOWEST = 0;
/* public */ const FIFO = 1;
/* public */ const LIFO = 2;
/* public */ const EARLIEST_DEADLINE = 4;
/* public */ const SHORTEST_JOB = 8;
/* public */ const HIGHEST = 16;
/* public */ const LOWEST = 32;
}

View File

@ -28,7 +28,7 @@ namespace phpOMS\Utils;
* @link http://orange-management.com
* @since 1.0.0
*/
class Color
class ColorUtils
{
/**
@ -83,4 +83,15 @@ class Color
return $gradient;
}
public static function intToRgb(int $rgbInt) : array
{
$rgb = [];
$rgb['b'] = $rgbInt & 255;
$rgb['g'] = ($rgbInt >> 8) & 255;
$rgb['r'] = ($rgbInt >> 16) & 255;
return $rgb;
}
}

View File

@ -63,7 +63,7 @@ class Caesar
$ascii = ord($source[$i]) + ord($key[$j]);
if ($ascii > self::LIMIT_UPPER) {
$ascii -= self::LIMIT_UPPER;
$ascii = self::LIMIT_LOWER + ($ascii - self::LIMIT_UPPER);
}
$result .= chr($ascii);
@ -89,7 +89,7 @@ class Caesar
$ascii = ord($raw[$i]) - ord($key[$j]);
if ($ascii < self::LIMIT_LOWER) {
$ascii += self::LIMIT_LOWER;
$ascii = self::LIMIT_UPPER + ($ascii - self::LIMIT_LOWER) ;
}
$result .= chr($ascii);