forked from fa/breadcrumb-the-shire
47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace MintyPHP\Tests\Service\Export;
|
||
|
|
|
||
|
|
use PHPUnit\Framework\TestCase;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Thin tests for the procedural helpers in core/Support/helpers/export.php.
|
||
|
|
* The functions are bootstrapped via composer autoload through
|
||
|
|
* core/Support/helpers.php, so they are globally available in tests.
|
||
|
|
*/
|
||
|
|
class ExportHelpersTest extends TestCase
|
||
|
|
{
|
||
|
|
public function testExportCapLimitClampsNonNumericToMax(): void
|
||
|
|
{
|
||
|
|
$this->assertSame(5000, exportCapLimit(null, 5000));
|
||
|
|
$this->assertSame(5000, exportCapLimit('', 5000));
|
||
|
|
$this->assertSame(5000, exportCapLimit('abc', 5000));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testExportCapLimitClampsZeroAndNegativeToMax(): void
|
||
|
|
{
|
||
|
|
$this->assertSame(5000, exportCapLimit(0, 5000));
|
||
|
|
$this->assertSame(5000, exportCapLimit(-1, 5000));
|
||
|
|
$this->assertSame(5000, exportCapLimit('-42', 5000));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testExportCapLimitRespectsUserValueWhenInRange(): void
|
||
|
|
{
|
||
|
|
$this->assertSame(250, exportCapLimit(250, 5000));
|
||
|
|
$this->assertSame(5000, exportCapLimit(5000, 5000));
|
||
|
|
$this->assertSame(1, exportCapLimit(1, 5000));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testExportCapLimitClampsAboveMaxToMax(): void
|
||
|
|
{
|
||
|
|
$this->assertSame(5000, exportCapLimit(9999, 5000));
|
||
|
|
$this->assertSame(100, exportCapLimit(999999, 100));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testExportCapLimitHonoursCustomMax(): void
|
||
|
|
{
|
||
|
|
$this->assertSame(50, exportCapLimit(50, 100));
|
||
|
|
$this->assertSame(100, exportCapLimit(200, 100));
|
||
|
|
}
|
||
|
|
}
|