Skip to content

Commit

Permalink
Merge pull request #125 from RonasIT/nova-test-trait
Browse files Browse the repository at this point in the history
feat: add nova test trait
  • Loading branch information
DenTray authored Jun 3, 2024
2 parents e0f3b57 + 0f8bfcc commit 466cfcc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Traits/NovaTestTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace RonasIT\Support\Traits;

trait NovaTestTrait
{
public function novaSearchParams(array $filters, string $search = '', int $perPage = 25): array
{
return [
'search' => $search,
'filters' => base64_encode(json_encode($filters)),
'perPage' => $perPage,
];
}
}
25 changes: 25 additions & 0 deletions tests/NovaTestTraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

namespace RonasIT\Support\Tests;

use RonasIT\Support\Traits\MockTrait;
use RonasIT\Support\Traits\NovaTestTrait;

class NovaTestTraitTest extends HelpersTestCase
{
use MockTrait;
use NovaTestTrait;

public function testMockSingleCall()
{
$result = $this->novaSearchParams([
'Badge:kyc_status' => ['Completed'],
]);

$this->assertEquals($result, [
'search' => '',
'filters' => 'eyJCYWRnZTpreWNfc3RhdHVzIjpbIkNvbXBsZXRlZCJdfQ==',
'perPage' => 25,
]);
}
}

0 comments on commit 466cfcc

Please sign in to comment.