mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
parent
0503887629
commit
e88604594b
21
app/Ninja/Domain/Helpers/NumberHelper.php
Normal file
21
app/Ninja/Domain/Helpers/NumberHelper.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\Domain\Helpers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class NumberHelper
|
||||||
|
* @package App\Ninja
|
||||||
|
*/
|
||||||
|
class NumberHelper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param float $value
|
||||||
|
* @param int $precision
|
||||||
|
* @return float
|
||||||
|
*/
|
||||||
|
public static function roundValue(float $value, int $precision = 2) : float
|
||||||
|
{
|
||||||
|
return round($value, $precision, PHP_ROUND_HALF_UP);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
35
app/Ninja/Domain/Invoice/InvoiceTotals.php
Normal file
35
app/Ninja/Domain/Invoice/InvoiceTotals.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Ninja\Domain\Invoice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class InvoiceTotals
|
||||||
|
*/
|
||||||
|
|
||||||
|
class InvoiceTotals
|
||||||
|
{
|
||||||
|
|
||||||
|
protected $invoice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* InvoiceTotals constructor.
|
||||||
|
* @param $invoice
|
||||||
|
*/
|
||||||
|
public function __construct($invoice)
|
||||||
|
{
|
||||||
|
$this->invoice = $invoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function calculate()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sumLineItems()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
57
c3.php
57
c3.php
@ -1,35 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
// @codingStandardsIgnoreFile
|
// @codingStandardsIgnoreFile
|
||||||
// @codeCoverageIgnoreStart
|
// @codeCoverageIgnoreStart
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* C3 - Codeception Code Coverage
|
* C3 - Codeception Code Coverage
|
||||||
*
|
*
|
||||||
* @author tiger
|
* @author tiger
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'] = 1;
|
// $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'] = 1;
|
||||||
|
|
||||||
if (isset($_COOKIE['CODECEPTION_CODECOVERAGE'])) {
|
if (isset($_COOKIE['CODECEPTION_CODECOVERAGE'])) {
|
||||||
$cookie = json_decode($_COOKIE['CODECEPTION_CODECOVERAGE'], true);
|
$cookie = json_decode($_COOKIE['CODECEPTION_CODECOVERAGE'], true);
|
||||||
|
|
||||||
// fix for improperly encoded JSON in Code Coverage cookie with WebDriver.
|
// fix for improperly encoded JSON in Code Coverage cookie with WebDriver.
|
||||||
// @see https://github.com/Codeception/Codeception/issues/874
|
// @see https://github.com/Codeception/Codeception/issues/874
|
||||||
if (!is_array($cookie)) {
|
if (!is_array($cookie)) {
|
||||||
$cookie = json_decode($cookie, true);
|
$cookie = json_decode($cookie, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($cookie) {
|
if ($cookie) {
|
||||||
foreach ($cookie as $key => $value) {
|
foreach ($cookie as $key => $value) {
|
||||||
$_SERVER["HTTP_X_CODECEPTION_" . strtoupper($key)] = $value;
|
$_SERVER["HTTP_X_CODECEPTION_" . strtoupper($key)] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE', $_SERVER)) {
|
if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE', $_SERVER)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!function_exists('__c3_error')) {
|
if (!function_exists('__c3_error')) {
|
||||||
function __c3_error($message)
|
function __c3_error($message)
|
||||||
{
|
{
|
||||||
@ -47,7 +40,6 @@ if (!function_exists('__c3_error')) {
|
|||||||
setcookie('CODECEPTION_CODECOVERAGE_ERROR', $message);
|
setcookie('CODECEPTION_CODECOVERAGE_ERROR', $message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// phpunit codecoverage shimming
|
// phpunit codecoverage shimming
|
||||||
if (!class_exists('PHP_CodeCoverage') and class_exists('SebastianBergmann\CodeCoverage\CodeCoverage')) {
|
if (!class_exists('PHP_CodeCoverage') and class_exists('SebastianBergmann\CodeCoverage\CodeCoverage')) {
|
||||||
class_alias('SebastianBergmann\CodeCoverage\CodeCoverage', 'PHP_CodeCoverage');
|
class_alias('SebastianBergmann\CodeCoverage\CodeCoverage', 'PHP_CodeCoverage');
|
||||||
@ -63,7 +55,6 @@ if (!class_exists('PHP_CodeCoverage') and class_exists('SebastianBergmann\CodeCo
|
|||||||
if (!class_exists('PHPUnit_Runner_Version') && class_exists('PHPUnit\Runner\Version')) {
|
if (!class_exists('PHPUnit_Runner_Version') && class_exists('PHPUnit\Runner\Version')) {
|
||||||
class_alias('PHPUnit\Runner\Version', 'PHPUnit_Runner_Version');
|
class_alias('PHPUnit\Runner\Version', 'PHPUnit_Runner_Version');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Autoload Codeception classes
|
// Autoload Codeception classes
|
||||||
if (!class_exists('\\Codeception\\Codecept')) {
|
if (!class_exists('\\Codeception\\Codecept')) {
|
||||||
if (file_exists(__DIR__ . '/codecept.phar')) {
|
if (file_exists(__DIR__ . '/codecept.phar')) {
|
||||||
@ -80,11 +71,9 @@ if (!class_exists('\\Codeception\\Codecept')) {
|
|||||||
__c3_error('Codeception is not loaded. Please check that either PHAR or Composer package can be used');
|
__c3_error('Codeception is not loaded. Please check that either PHAR or Composer package can be used');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load Codeception Config
|
// Load Codeception Config
|
||||||
$config_dist_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.dist.yml';
|
$config_dist_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.dist.yml';
|
||||||
$config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.yml';
|
$config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.yml';
|
||||||
|
|
||||||
if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'])) {
|
if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'])) {
|
||||||
$config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'];
|
$config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'];
|
||||||
}
|
}
|
||||||
@ -101,12 +90,9 @@ try {
|
|||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
__c3_error($e->getMessage());
|
__c3_error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
|
if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
|
||||||
|
|
||||||
// workaround for 'zend_mm_heap corrupted' problem
|
// workaround for 'zend_mm_heap corrupted' problem
|
||||||
gc_disable();
|
gc_disable();
|
||||||
|
|
||||||
$memoryLimit = ini_get('memory_limit');
|
$memoryLimit = ini_get('memory_limit');
|
||||||
$requiredMemory = '384M';
|
$requiredMemory = '384M';
|
||||||
if ((substr($memoryLimit, -1) === 'M' && (int)$memoryLimit < (int)$requiredMemory)
|
if ((substr($memoryLimit, -1) === 'M' && (int)$memoryLimit < (int)$requiredMemory)
|
||||||
@ -115,98 +101,74 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
|
|||||||
) {
|
) {
|
||||||
ini_set('memory_limit', $requiredMemory);
|
ini_set('memory_limit', $requiredMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
define('C3_CODECOVERAGE_MEDIATE_STORAGE', Codeception\Configuration::logDir() . 'c3tmp');
|
define('C3_CODECOVERAGE_MEDIATE_STORAGE', Codeception\Configuration::logDir() . 'c3tmp');
|
||||||
define('C3_CODECOVERAGE_PROJECT_ROOT', Codeception\Configuration::projectDir());
|
define('C3_CODECOVERAGE_PROJECT_ROOT', Codeception\Configuration::projectDir());
|
||||||
define('C3_CODECOVERAGE_TESTNAME', $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE']);
|
define('C3_CODECOVERAGE_TESTNAME', $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE']);
|
||||||
|
|
||||||
function __c3_build_html_report(PHP_CodeCoverage $codeCoverage, $path)
|
function __c3_build_html_report(PHP_CodeCoverage $codeCoverage, $path)
|
||||||
{
|
{
|
||||||
$writer = new PHP_CodeCoverage_Report_HTML();
|
$writer = new PHP_CodeCoverage_Report_HTML();
|
||||||
$writer->process($codeCoverage, $path . 'html');
|
$writer->process($codeCoverage, $path . 'html');
|
||||||
|
|
||||||
if (file_exists($path . '.tar')) {
|
if (file_exists($path . '.tar')) {
|
||||||
unlink($path . '.tar');
|
unlink($path . '.tar');
|
||||||
}
|
}
|
||||||
|
|
||||||
$phar = new PharData($path . '.tar');
|
$phar = new PharData($path . '.tar');
|
||||||
$phar->setSignatureAlgorithm(Phar::SHA1);
|
$phar->setSignatureAlgorithm(Phar::SHA1);
|
||||||
$files = $phar->buildFromDirectory($path . 'html');
|
$files = $phar->buildFromDirectory($path . 'html');
|
||||||
array_map('unlink', $files);
|
array_map('unlink', $files);
|
||||||
|
|
||||||
if (in_array('GZ', Phar::getSupportedCompression())) {
|
if (in_array('GZ', Phar::getSupportedCompression())) {
|
||||||
if (file_exists($path . '.tar.gz')) {
|
if (file_exists($path . '.tar.gz')) {
|
||||||
unlink($path . '.tar.gz');
|
unlink($path . '.tar.gz');
|
||||||
}
|
}
|
||||||
|
|
||||||
$phar->compress(\Phar::GZ);
|
$phar->compress(\Phar::GZ);
|
||||||
|
|
||||||
// close the file so that we can rename it
|
// close the file so that we can rename it
|
||||||
unset($phar);
|
unset($phar);
|
||||||
|
|
||||||
unlink($path . '.tar');
|
unlink($path . '.tar');
|
||||||
rename($path . '.tar.gz', $path . '.tar');
|
rename($path . '.tar.gz', $path . '.tar');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $path . '.tar';
|
return $path . '.tar';
|
||||||
}
|
}
|
||||||
|
|
||||||
function __c3_build_clover_report(PHP_CodeCoverage $codeCoverage, $path)
|
function __c3_build_clover_report(PHP_CodeCoverage $codeCoverage, $path)
|
||||||
{
|
{
|
||||||
$writer = new PHP_CodeCoverage_Report_Clover();
|
$writer = new PHP_CodeCoverage_Report_Clover();
|
||||||
$writer->process($codeCoverage, $path . '.clover.xml');
|
$writer->process($codeCoverage, $path . '.clover.xml');
|
||||||
|
|
||||||
return $path . '.clover.xml';
|
return $path . '.clover.xml';
|
||||||
}
|
}
|
||||||
|
|
||||||
function __c3_build_crap4j_report(PHP_CodeCoverage $codeCoverage, $path)
|
function __c3_build_crap4j_report(PHP_CodeCoverage $codeCoverage, $path)
|
||||||
{
|
{
|
||||||
$writer = new PHP_CodeCoverage_Report_Crap4j();
|
$writer = new PHP_CodeCoverage_Report_Crap4j();
|
||||||
$writer->process($codeCoverage, $path . '.crap4j.xml');
|
$writer->process($codeCoverage, $path . '.crap4j.xml');
|
||||||
|
|
||||||
return $path . '.crap4j.xml';
|
return $path . '.crap4j.xml';
|
||||||
}
|
}
|
||||||
|
|
||||||
function __c3_build_phpunit_report(PHP_CodeCoverage $codeCoverage, $path)
|
function __c3_build_phpunit_report(PHP_CodeCoverage $codeCoverage, $path)
|
||||||
{
|
{
|
||||||
$writer = new PHP_CodeCoverage_Report_XML(\PHPUnit_Runner_Version::id());
|
$writer = new PHP_CodeCoverage_Report_XML(\PHPUnit_Runner_Version::id());
|
||||||
$writer->process($codeCoverage, $path . 'phpunit');
|
$writer->process($codeCoverage, $path . 'phpunit');
|
||||||
|
|
||||||
if (file_exists($path . '.tar')) {
|
if (file_exists($path . '.tar')) {
|
||||||
unlink($path . '.tar');
|
unlink($path . '.tar');
|
||||||
}
|
}
|
||||||
|
|
||||||
$phar = new PharData($path . '.tar');
|
$phar = new PharData($path . '.tar');
|
||||||
$phar->setSignatureAlgorithm(Phar::SHA1);
|
$phar->setSignatureAlgorithm(Phar::SHA1);
|
||||||
$files = $phar->buildFromDirectory($path . 'phpunit');
|
$files = $phar->buildFromDirectory($path . 'phpunit');
|
||||||
array_map('unlink', $files);
|
array_map('unlink', $files);
|
||||||
|
|
||||||
if (in_array('GZ', Phar::getSupportedCompression())) {
|
if (in_array('GZ', Phar::getSupportedCompression())) {
|
||||||
if (file_exists($path . '.tar.gz')) {
|
if (file_exists($path . '.tar.gz')) {
|
||||||
unlink($path . '.tar.gz');
|
unlink($path . '.tar.gz');
|
||||||
}
|
}
|
||||||
|
|
||||||
$phar->compress(\Phar::GZ);
|
$phar->compress(\Phar::GZ);
|
||||||
|
|
||||||
// close the file so that we can rename it
|
// close the file so that we can rename it
|
||||||
unset($phar);
|
unset($phar);
|
||||||
|
|
||||||
unlink($path . '.tar');
|
unlink($path . '.tar');
|
||||||
rename($path . '.tar.gz', $path . '.tar');
|
rename($path . '.tar.gz', $path . '.tar');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $path . '.tar';
|
return $path . '.tar';
|
||||||
}
|
}
|
||||||
|
|
||||||
function __c3_send_file($filename)
|
function __c3_send_file($filename)
|
||||||
{
|
{
|
||||||
if (!headers_sent()) {
|
if (!headers_sent()) {
|
||||||
readfile($filename);
|
readfile($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
return __c3_exit();
|
return __c3_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $filename
|
* @param $filename
|
||||||
* @param bool $lock Lock the file for writing?
|
* @param bool $lock Lock the file for writing?
|
||||||
@ -231,7 +193,6 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
|
|||||||
} else {
|
} else {
|
||||||
$phpCoverage = new PHP_CodeCoverage();
|
$phpCoverage = new PHP_CodeCoverage();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'])) {
|
if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'])) {
|
||||||
$suite = $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'];
|
$suite = $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'];
|
||||||
try {
|
try {
|
||||||
@ -242,7 +203,6 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
|
|||||||
} else {
|
} else {
|
||||||
$settings = \Codeception\Configuration::config();
|
$settings = \Codeception\Configuration::config();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
\Codeception\Coverage\Filter::setup($phpCoverage)
|
\Codeception\Coverage\Filter::setup($phpCoverage)
|
||||||
->whiteList($settings)
|
->whiteList($settings)
|
||||||
@ -250,10 +210,8 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
|
|||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
__c3_error($e->getMessage());
|
__c3_error($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
return array($phpCoverage, $file);
|
return array($phpCoverage, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
function __c3_exit()
|
function __c3_exit()
|
||||||
{
|
{
|
||||||
if (!isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'])) {
|
if (!isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'])) {
|
||||||
@ -261,37 +219,28 @@ if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function __c3_clear()
|
function __c3_clear()
|
||||||
{
|
{
|
||||||
\Codeception\Util\FileSystem::doEmptyDir(C3_CODECOVERAGE_MEDIATE_STORAGE);
|
\Codeception\Util\FileSystem::doEmptyDir(C3_CODECOVERAGE_MEDIATE_STORAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_dir(C3_CODECOVERAGE_MEDIATE_STORAGE)) {
|
if (!is_dir(C3_CODECOVERAGE_MEDIATE_STORAGE)) {
|
||||||
if (mkdir(C3_CODECOVERAGE_MEDIATE_STORAGE, 0777, true) === false) {
|
if (mkdir(C3_CODECOVERAGE_MEDIATE_STORAGE, 0777, true) === false) {
|
||||||
__c3_error('Failed to create directory "' . C3_CODECOVERAGE_MEDIATE_STORAGE . '"');
|
__c3_error('Failed to create directory "' . C3_CODECOVERAGE_MEDIATE_STORAGE . '"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// evaluate base path for c3-related files
|
// evaluate base path for c3-related files
|
||||||
$path = realpath(C3_CODECOVERAGE_MEDIATE_STORAGE) . DIRECTORY_SEPARATOR . 'codecoverage';
|
$path = realpath(C3_CODECOVERAGE_MEDIATE_STORAGE) . DIRECTORY_SEPARATOR . 'codecoverage';
|
||||||
|
|
||||||
$requested_c3_report = (strpos($_SERVER['REQUEST_URI'], 'c3/report') !== false);
|
$requested_c3_report = (strpos($_SERVER['REQUEST_URI'], 'c3/report') !== false);
|
||||||
|
|
||||||
$complete_report = $current_report = $path . '.serialized';
|
$complete_report = $current_report = $path . '.serialized';
|
||||||
if ($requested_c3_report) {
|
if ($requested_c3_report) {
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
|
|
||||||
$route = ltrim(strrchr($_SERVER['REQUEST_URI'], '/'), '/');
|
$route = ltrim(strrchr($_SERVER['REQUEST_URI'], '/'), '/');
|
||||||
|
|
||||||
if ($route === 'clear') {
|
if ($route === 'clear') {
|
||||||
__c3_clear();
|
__c3_clear();
|
||||||
return __c3_exit();
|
return __c3_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
list($codeCoverage, ) = __c3_factory($complete_report);
|
list($codeCoverage, ) = __c3_factory($complete_report);
|
||||||
|
|
||||||
switch ($route) {
|
switch ($route) {
|
||||||
case 'html':
|
case 'html':
|
||||||
try {
|
try {
|
||||||
@ -329,21 +278,18 @@ if ($requested_c3_report) {
|
|||||||
}
|
}
|
||||||
return __c3_exit();
|
return __c3_exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
list($codeCoverage, ) = __c3_factory(null);
|
list($codeCoverage, ) = __c3_factory(null);
|
||||||
$codeCoverage->start(C3_CODECOVERAGE_TESTNAME);
|
$codeCoverage->start(C3_CODECOVERAGE_TESTNAME);
|
||||||
if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG', $_SERVER)) {
|
if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG', $_SERVER)) {
|
||||||
register_shutdown_function(
|
register_shutdown_function(
|
||||||
function () use ($codeCoverage, $current_report) {
|
function () use ($codeCoverage, $current_report) {
|
||||||
|
|
||||||
$codeCoverage->stop();
|
$codeCoverage->stop();
|
||||||
if (!file_exists(dirname($current_report))) { // verify directory exists
|
if (!file_exists(dirname($current_report))) { // verify directory exists
|
||||||
if (!mkdir(dirname($current_report), 0777, true)) {
|
if (!mkdir(dirname($current_report), 0777, true)) {
|
||||||
__c3_error("Can't write CodeCoverage report into $current_report");
|
__c3_error("Can't write CodeCoverage report into $current_report");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This will either lock the existing report for writing and return it along with a file pointer,
|
// This will either lock the existing report for writing and return it along with a file pointer,
|
||||||
// or return a fresh PHP_CodeCoverage object without a file pointer. We'll merge the current request
|
// or return a fresh PHP_CodeCoverage object without a file pointer. We'll merge the current request
|
||||||
// into that coverage object, write it to disk, and release the lock. By doing this in the end of
|
// into that coverage object, write it to disk, and release the lock. By doing this in the end of
|
||||||
@ -356,10 +302,8 @@ if ($requested_c3_report) {
|
|||||||
// In addition, by locking the file for exclusive writing, we make sure no other request try to
|
// In addition, by locking the file for exclusive writing, we make sure no other request try to
|
||||||
// read/write to the file at the same time as this request (leading to a corrupt file). flock() is a
|
// read/write to the file at the same time as this request (leading to a corrupt file). flock() is a
|
||||||
// blocking call, so it waits until an exclusive lock can be acquired before continuing.
|
// blocking call, so it waits until an exclusive lock can be acquired before continuing.
|
||||||
|
|
||||||
list($existingCodeCoverage, $file) = __c3_factory($current_report, true);
|
list($existingCodeCoverage, $file) = __c3_factory($current_report, true);
|
||||||
$existingCodeCoverage->merge($codeCoverage);
|
$existingCodeCoverage->merge($codeCoverage);
|
||||||
|
|
||||||
if ($file === null) {
|
if ($file === null) {
|
||||||
file_put_contents($current_report, serialize($existingCodeCoverage), LOCK_EX);
|
file_put_contents($current_report, serialize($existingCodeCoverage), LOCK_EX);
|
||||||
} else {
|
} else {
|
||||||
@ -373,5 +317,4 @@ if ($requested_c3_report) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @codeCoverageIgnoreEnd
|
// @codeCoverageIgnoreEnd
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
// https://bulma.io/documentation/components/navbar/
|
// https://bulma.io/documentation/components/navbar/
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
|
||||||
// Get all "navbar-burger" elements
|
// Get all "navbar-burger" elements
|
||||||
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
||||||
@ -25,14 +25,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<header class="hero is-light">
|
<header class="hero is-light">
|
||||||
<div class="hero-head">
|
<div class="hero-head">
|
||||||
<nav class="navbar" role="navigation" aria-label="main navigation">
|
<nav class="navbar" role="navigation" aria-label="main navigation">
|
||||||
<div class="navbar-brand">
|
<div class="navbar-brand">
|
||||||
<a class="navbar-item" href="https://bulma.io">
|
<a class="navbar-item" href="https://app.invoiceninja.com/">
|
||||||
<img src="https://bulma.io/images/bulma-logo.png" width="112" height="28">
|
<img src="https://bulma.io/images/bulma-logo.png" width="112" height="28">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
@ -45,13 +45,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
<div id="navbarBasicExample" class="navbar-menu">
|
<div id="navbarBasicExample" class="navbar-menu">
|
||||||
<div class="navbar-start">
|
<div class="navbar-start">
|
||||||
<a class="navbar-item">
|
|
||||||
Home
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a class="navbar-item">
|
|
||||||
Documentation
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<div class="navbar-item has-dropdown is-hoverable">
|
<div class="navbar-item has-dropdown is-hoverable">
|
||||||
<a class="navbar-link">
|
<a class="navbar-link">
|
||||||
@ -74,10 +67,57 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="navbar-item field has-addons">
|
||||||
|
<div class="control has-icons-left">
|
||||||
|
<input class="input" type="email" placeholder="Search">
|
||||||
|
<span class="icon is-small is-left">
|
||||||
|
<i class="fa fa-search"></i>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="navbar-end">
|
<div class="navbar-end">
|
||||||
<div class="navbar-item">
|
<div class="navbar-item has-dropdown is-hoverable">
|
||||||
|
<a class="navbar-link">Company Switcher</a>
|
||||||
|
<div class="navbar-dropdown is-right is-boxed">
|
||||||
|
<a class="navbar-item" href="/switch">
|
||||||
|
<span class="icon"><i class="fa fa-gear"></i></span>
|
||||||
|
<span>co 1</span>
|
||||||
|
</a>
|
||||||
|
<a class="navbar-item" href="/switch">
|
||||||
|
<span class="icon"><i class="fa fa-gear"></i></span>
|
||||||
|
<span>co 2</span>
|
||||||
|
</a>
|
||||||
|
<a class="navbar-item" href="/switch">
|
||||||
|
<span class="icon"><i class="fa fa-gear"></i></span>
|
||||||
|
<span>co 3</span>
|
||||||
|
</a>
|
||||||
|
<div class="navbar-divider"></div>
|
||||||
|
<a class="navbar-item" href="/log-out">
|
||||||
|
<span class="icon"><i class="fa fa-sign-out"></i></span>
|
||||||
|
<span>Add Co</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="navbar-item has-dropdown is-hoverable">
|
||||||
|
<a class="navbar-link">Ninja User</a>
|
||||||
|
<div class="navbar-dropdown is-right is-boxed">
|
||||||
|
<a class="navbar-item" href="/settings">
|
||||||
|
<span class="icon"><i class="fa fa-gear"></i></span>
|
||||||
|
<span>Settings</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<div class="navbar-divider"></div>
|
||||||
|
<a class="navbar-item" href="/log-out">
|
||||||
|
<span class="icon"><i class="fa fa-sign-out"></i></span>
|
||||||
|
<span>Log out</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<a class="button is-primary">
|
<a class="button is-primary">
|
||||||
<strong>Sign up</strong>
|
<strong>Sign up</strong>
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Feature;
|
|
||||||
|
|
||||||
use Tests\TestCase;
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* A basic test example.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testBasicTest()
|
|
||||||
{
|
|
||||||
$response = $this->get('/');
|
|
||||||
|
|
||||||
$response->assertStatus(200);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Unit;
|
|
||||||
|
|
||||||
use Tests\TestCase;
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
||||||
|
|
||||||
class ExampleTest extends TestCase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* A basic test example.
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testBasicTest()
|
|
||||||
{
|
|
||||||
$this->assertTrue(true);
|
|
||||||
}
|
|
||||||
}
|
|
34
tests/Unit/NumberTest.php
Normal file
34
tests/Unit/NumberTest.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit;
|
||||||
|
|
||||||
|
use App\Ninja\Domain\Helpers\NumberHelper;
|
||||||
|
use Tests\TestCase;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
|
||||||
|
class NumberTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public function testRoundingThreeLow()
|
||||||
|
{
|
||||||
|
$rounded = NumberHelper::roundValue(3.144444444444, 3);
|
||||||
|
|
||||||
|
$this->assertEquals(3.144, $rounded);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRoundingThreeHigh()
|
||||||
|
{
|
||||||
|
$rounded = NumberHelper::roundValue(3.144944444444, 3);
|
||||||
|
|
||||||
|
$this->assertEquals(3.145, $rounded);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRoundingTwoLow()
|
||||||
|
{
|
||||||
|
$rounded = NumberHelper::roundValue(2.145);
|
||||||
|
|
||||||
|
$this->assertEquals(2.15, $rounded);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user