feat: add branded tutorials and display-only plan device settings
This commit is contained in:
1 parent
4f48e61a2c
commit
cd117604a3
126 files changed
+1197
-9
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Http\Requests\Admin\PlanSave;
|
||||
use App\Http\Resources\PlanResource;
|
||||
use App\Models\Plan;
|
||||
use Illuminate\Http\Request;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PlanDisplayDeviceLimitTest extends TestCase
|
||||
{
|
||||
public function test_display_count_does_not_replace_actual_limit_and_zero_is_explicit(): void
|
||||
{
|
||||
foreach ([[5, 18, 18], [5, null, 5], [5, 0, 0], [null, 200, 200], [null, null, null]] as [$actual, $display, $expected]) {
|
||||
$plan = new Plan(['device_limit' => $actual, 'display_device_limit' => $display, 'reset_traffic_method' => 1]);
|
||||
$this->assertSame($expected, $plan->getDisplayDeviceLimit());
|
||||
$data = (new PlanResource($plan))->toArray(new Request());
|
||||
$this->assertSame($actual, $data['device_limit']);
|
||||
$this->assertSame($display, $data['display_device_limit']);
|
||||
}
|
||||
}
|
||||
|
||||
public function test_existing_template_variable_keeps_actual_limit(): void
|
||||
{
|
||||
$plan = new Plan(['device_limit' => 5, 'display_device_limit' => 18, 'reset_traffic_method' => 1, 'content' => '{{devices}} / {{display_devices}}']);
|
||||
$this->assertSame('5 / 18', (new PlanResource($plan))->toArray(new Request())['content']);
|
||||
}
|
||||
|
||||
public function test_display_count_rejects_negative_fraction_and_overflow(): void
|
||||
{
|
||||
$rule = (new PlanSave())->rules()['display_device_limit'];
|
||||
foreach ([null, 0, 5, 200, 4294967295] as $value) {
|
||||
$this->assertFalse(validator(['display_device_limit' => $value], ['display_device_limit' => $rule])->fails());
|
||||
}
|
||||
foreach ([-1, 1.5, 'abc', 4294967296] as $value) {
|
||||
$this->assertTrue(validator(['display_device_limit' => $value], ['display_device_limit' => $rule])->fails());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user