-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit df33f14
Showing
12 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Source spatie/laravel-backup/.github/workflows/run-tests.yml | ||
name: run-tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: true | ||
matrix: | ||
php: [8.0, 8.1] | ||
laravel: [9.*] | ||
dependency-version: [prefer-lowest, prefer-stable] | ||
include: | ||
- laravel: 9.* | ||
testbench: 7.* | ||
|
||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v1 | ||
|
||
- name: Install SQLite 3 | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install sqlite3 | ||
- name: Cache dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.composer/cache/files | ||
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv | ||
coverage: none | ||
|
||
- name: Install dependencies | ||
run: | | ||
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update | ||
composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest | ||
- name: Execute tests | ||
run: vendor/bin/pest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/vendor/ | ||
composer.lock | ||
package-lock.json | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Nils | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# laravel-blade-repeat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
{ | ||
"name": "poldixd/laravel-blade-repeat", | ||
"license": "MIT", | ||
"homepage": "https://github.com/poldixd/laravel-blade-repeat", | ||
"authors": [ | ||
{ | ||
"name": "Nils Poltmann", | ||
"email": "dev@nils.li" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.0", | ||
"illuminate/support": "^9.0" | ||
}, | ||
"require-dev": { | ||
"orchestra/testbench": "^7.0", | ||
"pestphp/pest": "^1.21", | ||
"pestphp/pest-plugin-laravel": "^1.2", | ||
"spatie/pest-plugin-snapshots": "^1.1" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"poldixd\\BladeRepeat\\": "src/" | ||
} | ||
}, | ||
"scripts": { | ||
"test": "vendor/bin/pest" | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"poldixd\\BladeRepeat\\Tests\\": "tests/" | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"poldixd\\BladeRepeat\\BladeRepeatServiceProvider" | ||
] | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"config": { | ||
"allow-plugins": { | ||
"pestphp/pest-plugin": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage> | ||
<include> | ||
<directory suffix=".php">src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace poldixd\BladeRepeat; | ||
|
||
use Illuminate\Support\ServiceProvider; | ||
use Blade; | ||
|
||
class BladeRepeatServiceProvider extends ServiceProvider | ||
{ | ||
public function boot() | ||
{ | ||
Blade::directive('repeat', function ($expression = 1) { | ||
return "<?php for (\$iteration=1; \$iteration <= $expression; \$iteration++): ?>"; | ||
}); | ||
|
||
Blade::directive('endrepeat', function () { | ||
return "<?php endfor; ?>"; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Blade; | ||
use function Spatie\Snapshots\assertMatchesHtmlSnapshot; | ||
|
||
it('can render string 3 times', function () { | ||
$html = <<<BLADE | ||
@repeat(3) | ||
Test | ||
@endrepeat | ||
BLADE; | ||
|
||
assertMatchesHtmlSnapshot(Blade::render($html)); | ||
}); | ||
|
||
it('can render string 2 times with iteration', function () { | ||
$html = <<<BLADE | ||
@repeat(2) | ||
Test #{{ \$iteration }} | ||
@endrepeat | ||
BLADE; | ||
|
||
assertMatchesHtmlSnapshot(Blade::render($html)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
use poldixd\BladeRepeat\Tests\TestCase; | ||
|
||
uses(TestCase::class)->in(__DIR__); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace poldixd\BladeRepeat\Tests; | ||
|
||
use poldixd\BladeRepeat\BladeRepeatServiceProvider; | ||
use Orchestra\Testbench\TestCase as BaseTestCase; | ||
use Illuminate\Foundation\Testing\Concerns\InteractsWithViews; | ||
|
||
class TestCase extends BaseTestCase | ||
{ | ||
use InteractsWithViews; | ||
|
||
protected function getPackageProviders($app): array | ||
{ | ||
return [ | ||
BladeRepeatServiceProvider::class, | ||
]; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/__snapshots__/BladeRepeatTest__it_can_render_string_2_times_with_iteration__1.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<html><body><p>Test #1 | ||
Test #2 | ||
</p></body></html> |
4 changes: 4 additions & 0 deletions
4
tests/__snapshots__/BladeRepeatTest__it_can_render_string_3_times__1.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<html><body><p>Test | ||
Test | ||
Test | ||
</p></body></html> |