Skip to content

Commit

Permalink
tests: use attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
yajra committed Mar 14, 2024
1 parent c2ff5c7 commit 0eeec19
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/vendor
/coverage
/.phpunit.cache
composer.phar
composer.lock
21 changes: 6 additions & 15 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
</testsuite>
</testsuites>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix="Test.php">./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
10 changes: 6 additions & 4 deletions tests/FractalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
namespace Yajra\DataTables\Fractal\Tests;

use Illuminate\Foundation\Testing\DatabaseTransactions;
use PHPUnit\Framework\Attributes\Test;
use Yajra\DataTables\Facades\DataTables;
use Yajra\DataTables\Fractal\Tests\Models\User;
use Yajra\DataTables\Fractal\Tests\Transformers\UserTransformer;

class FractalTest extends TestCase
{
use DatabaseTransactions;

/** @test */
#[Test]
public function it_can_transform_response()
{
$json = $this->getAjax('/users');
Expand All @@ -25,7 +27,7 @@ public function it_can_transform_response()
$this->assertIsString($json['data'][0]['name']);
}

/** @test */
#[Test]
public function it_works_with_closure()
{
$json = $this->getAjax('/closure');
Expand All @@ -45,13 +47,13 @@ protected function setUp(): void
parent::setUp();

$this->app['router']->get('/users', function () {
return datatables()->eloquent(User::query())
return DataTables::eloquent(User::query())
->setTransformer(UserTransformer::class)
->toJson();
});

$this->app['router']->get('/closure', function () {
return datatables()->eloquent(User::query())
return DataTables::eloquent(User::query())
->setTransformer(function (User $user) {
return [
'id' => (int) $user->id,
Expand Down

0 comments on commit 0eeec19

Please sign in to comment.