Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@2.6

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v6
uses: stefanzweifel/git-auto-commit-action@v7
with:
commit_message: Fix styling
50 changes: 50 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Run Tests

on:
push:
branches: [ main, develop ]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
extensions: dom, curl, libxml, mbstring, zip, pdo, sqlite, pdo_sqlite
coverage: none

- name: Install dependencies
run: composer install --prefer-dist --no-interaction

- name: Execute tests
run: vendor/bin/phpunit

code-style:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.4
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none
tools: cs2pr

- name: Install dependencies
run: composer install --prefer-dist --no-interaction

- name: Run Laravel Pint
run: |
if [ -f vendor/bin/pint ]; then
vendor/bin/pint --test
fi
4 changes: 2 additions & 2 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v4
uses: actions/checkout@v6
with:
ref: main

Expand All @@ -25,7 +25,7 @@ jobs:
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v6
uses: stefanzweifel/git-auto-commit-action@v7
with:
branch: main
commit_message: Update CHANGELOG
Expand Down
17 changes: 6 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@
"php": "^8.2",
"spatie/laravel-package-tools": "^1.16",
"illuminate/contracts": "^10.0||^11.0||^12.0",
"livewire/livewire": "^3.6",
"openspout/openspout": "^4.30"
"livewire/livewire": "^3.6||^4.0",
"openspout/openspout": "^5.2"
},
"require-dev": {
"laravel/pint": "^1.14",
"nunomaduro/collision": "^8.1.1||^7.10.0",
"larastan/larastan": "^2.9||^3.0",
"orchestra/testbench": "^10.0.0||^9.0.0||^8.22.0",
"pestphp/pest": "^3.0",
"pestphp/pest-plugin-arch": "^3.0",
"pestphp/pest-plugin-laravel": "^3.0",
"phpunit/phpunit": "^10.5.15",
"spatie/laravel-ray": "^1.35"
},
"autoload": {
Expand All @@ -45,15 +43,12 @@
"scripts": {
"post-autoload-dump": "@composer run prepare",
"prepare": "@php vendor/bin/testbench package:discover --ansi",
"test": "vendor/bin/pest",
"test-coverage": "vendor/bin/pest --coverage",
"test": "vendor/bin/phpunit",
"test-coverage": "vendor/bin/phpunit --coverage",
"format": "vendor/bin/pint"
},
"config": {
"sort-packages": true,
"allow-plugins": {
"pestphp/pest-plugin": true
}
"sort-packages": true
},
"extra": {
"laravel": {
Expand Down
36 changes: 14 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd"
backupGlobals="false"
bootstrap="vendor/autoload.php"
colors="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
cacheDirectory=".phpunit.cache"
backupStaticProperties="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true"
>
<testsuites>
<testsuite name="RealZone22 Test Suite">
<directory>tests</directory>
<testsuite name="PenguTables Test Suite">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
<source>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</coverage>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="sqlite"/>
<env name="DB_DATABASE" value=":memory:"/>
</php>
</phpunit>
2 changes: 1 addition & 1 deletion src/Livewire/PenguTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function boot(): void
public function mount(): void
{
$this->columns = collect($this->columns())
->filter(fn($column) => !$column->hidden)
->filter(fn ($column) => ! $column->hidden)
->values()
->toArray();
$this->initializeFilters();
Expand Down
2 changes: 1 addition & 1 deletion src/PenguTablesServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public function configurePackage(Package $package): void
->name('pengutables')
->hasConfigFile()
->hasTranslations()
->hasViews();
->hasViews('pengutables');
}
}
11 changes: 6 additions & 5 deletions src/Traits/WithExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function exportSelected($type)
public function exportAll($type)
{
$query = $this->applyFilters($this->applySearch($this->query()));

return $this->exportChunked($query, $type);
}

Expand All @@ -45,9 +46,9 @@ protected function export($data, $type)

protected function exportChunked($query, $type)
{
$filename = config('pengutables.export_filename', 'export_' . now()->format('Ymd_Hi'));
$exportColumns = collect($this->columns())->filter(fn($column) => $column->hideInExport)->values()->toArray();
$headers = collect($exportColumns)->map(fn($column) => $column->label)->toArray();
$filename = config('pengutables.export_filename', 'export_'.now()->format('Ymd_Hi'));
$exportColumns = collect($this->columns())->filter(fn ($column) => $column->hideInExport)->values()->toArray();
$headers = collect($exportColumns)->map(fn ($column) => $column->label)->toArray();

if (str_starts_with($type, 'csv')) {
return $this->streamChunkedCsv($filename, $headers, $query, $exportColumns);
Expand All @@ -72,7 +73,7 @@ protected function streamCsv($filename, $headers, $rows)
$writer->close();
}, 200, [
'Content-Type' => 'text/csv',
'Content-Disposition' => 'attachment; filename="' . $filename . '.csv"',
'Content-Disposition' => 'attachment; filename="'.$filename.'.csv"',
'Pragma' => 'no-cache',
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
'Expires' => '0',
Expand Down Expand Up @@ -156,7 +157,7 @@ protected function streamChunkedExcel($filename, $headers, $query, $exportColumn
$writer->close();
}, 200, [
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'Content-Disposition' => 'attachment; filename="' . $filename . '.xlsx"',
'Content-Disposition' => 'attachment; filename="'.$filename.'.xlsx"',
'Pragma' => 'no-cache',
'Cache-Control' => 'must-revalidate, post-check=0, pre-check=0',
'Expires' => '0',
Expand Down
5 changes: 0 additions & 5 deletions tests/ArchTest.php

This file was deleted.

5 changes: 0 additions & 5 deletions tests/ExampleTest.php

This file was deleted.

5 changes: 0 additions & 5 deletions tests/Pest.php

This file was deleted.

38 changes: 38 additions & 0 deletions tests/Table/ActionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace RealZone22\PenguTables\Tests\Table;

use RealZone22\PenguTables\Table\Action;
use RealZone22\PenguTables\Tests\TestCase;

class ActionTest extends TestCase
{
/** @test */
public function it_can_create_an_action()
{
$action = Action::make('<button>Click Me</button>');

$this->assertInstanceOf(Action::class, $action);
}

/** @test */
public function it_stores_the_action_content()
{
$action = Action::make('<button>Click Me</button>');

// Check that the content is stored in the toLivewire array
$livewireData = $action->toLivewire();
$this->assertEquals('<button>Click Me</button>', $livewireData['action']);
}

/** @test */
public function it_implements_wireable_interface()
{
$action = Action::make('<button>Click Me</button>');

$serialized = $action->toLivewire();
$deserialized = Action::fromLivewire($serialized);

$this->assertEquals($action->toLivewire(), $deserialized->toLivewire());
}
}
Loading