Skip to content

Commit b003132

Browse files
committed
Initial commit
0 parents  commit b003132

File tree

10 files changed

+240
-0
lines changed

10 files changed

+240
-0
lines changed

.github/workflows/laravel.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Laravel
2+
3+
on: push
4+
5+
jobs:
6+
laravel-tests:
7+
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Cache Dependencies
13+
uses: actions/cache@v1
14+
with:
15+
path: ~/.composer/cache/files
16+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
17+
restore-keys: |
18+
${{ runner.os }}-composer-
19+
- name: Install Dependencies
20+
run: |
21+
composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist
22+
- name: Execute tests (Unit and Feature tests) via PHPUnit
23+
run: vendor/bin/phpunit --testdox --coverage-clover=coverage.xml
24+
# - name: Upload Code Coverage Report
25+
# uses: codecov/codecov-action@v1
26+
# with:
27+
# token: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
/vendor
3+
composer.lock
4+
coverage.xml
5+
Thumbs.db

.php_cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
$excluded_folders = [
4+
'node_modules',
5+
'storage',
6+
'vendor',
7+
];
8+
9+
$finder = PhpCsFixer\Finder::create()
10+
->exclude($excluded_folders)
11+
->in(__DIR__);
12+
13+
return PhpCsFixer\Config::create()
14+
->setRules([
15+
'@Symfony' => true,
16+
'binary_operator_spaces' => ['align_double_arrow' => true],
17+
'array_syntax' => ['syntax' => 'short'],
18+
'linebreak_after_opening_tag' => true,
19+
'not_operator_with_successor_space' => true,
20+
'ordered_imports' => ['sort_algorithm' => 'length'],
21+
'phpdoc_order' => true,
22+
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
23+
])
24+
->setFinder($finder)
25+
;

composer.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "soved/laravel-snapshot",
3+
"description": "Full-page browser screenshots",
4+
"keywords": ["laravel", "snapshot", "soved", "screenshot", "full-page"],
5+
"type": "library",
6+
"require": {
7+
"php": "^7.4",
8+
"laravel/framework": "~8.0"
9+
},
10+
"require-dev": {
11+
"orchestra/testbench": "^5.2",
12+
"fzaninotto/faker": "^1.4"
13+
},
14+
"autoload": {
15+
"psr-4": {
16+
"Soved\\Laravel\\Snapshot\\": "src/"
17+
}
18+
},
19+
"autoload-dev": {
20+
"psr-4": {
21+
"Tests\\": "tests"
22+
}
23+
},
24+
"license": "MIT",
25+
"authors": [
26+
{
27+
"name": "Sander de Vos",
28+
"email": "sander@tutanota.de"
29+
}
30+
],
31+
"minimum-stability": "stable",
32+
"extra": {
33+
"laravel": {
34+
"providers": [
35+
]
36+
}
37+
}
38+
}

phpunit.xml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit backupGlobals="false"
3+
backupStaticAttributes="false"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false">
11+
<testsuites>
12+
<testsuite name="Feature">
13+
<directory suffix="Test.php">./tests/Feature</directory>
14+
</testsuite>
15+
16+
<testsuite name="Unit">
17+
<directory suffix="Test.php">./tests/Unit</directory>
18+
</testsuite>
19+
</testsuites>
20+
<filter>
21+
<whitelist processUncoveredFilesFromWhitelist="true">
22+
<directory suffix=".php">./src</directory>
23+
</whitelist>
24+
</filter>
25+
<php>
26+
<env name="APP_ENV" value="testing"/>
27+
<env name="DB_CONNECTION" value="testing"/>
28+
<env name="BCRYPT_ROUNDS" value="4"/>
29+
<env name="CACHE_DRIVER" value="array"/>
30+
<env name="SESSION_DRIVER" value="database"/>
31+
<env name="QUEUE_CONNECTION" value="sync"/>
32+
<env name="MAIL_DRIVER" value="array"/>
33+
</php>
34+
</phpunit>

readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Full-page browser screenshots
2+
3+
[![tests](https://github.com/sander3/laravel-snapshot/workflows/Laravel/badge.svg)](https://github.com/sander3/laravel-snapshot/actions?query=workflow%3ALaravel)
4+
[![codecov](https://codecov.io/gh/sander3/laravel-snapshot/branch/master/graph/badge.svg)](https://codecov.io/gh/sander3/laravel-snapshot)
5+
6+
## Requirements
7+
8+
- PHP >= 7.4
9+
- Laravel >= 8.0
10+
11+
## Security Vulnerabilities
12+
13+
If you discover a security vulnerability within this project, please send an e-mail to Sander de Vos via [sander@tutanota.de](mailto:sander@tutanota.de). All security vulnerabilities will be promptly addressed.

tests/Models/Snapshot.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
namespace Tests\Models;
4+
5+
use Illuminate\Support\Str;
6+
use Illuminate\Database\Eloquent\Model;
7+
use Illuminate\Database\Eloquent\SoftDeletes;
8+
9+
class Snapshot extends Model
10+
{
11+
use SoftDeletes;
12+
13+
/**
14+
* The attributes that are mass assignable.
15+
*
16+
* @var array
17+
*/
18+
protected $fillable = [
19+
'title',
20+
'url',
21+
];
22+
23+
/**
24+
* Get the route key for the model.
25+
*
26+
* @return string
27+
*/
28+
public function getRouteKeyName()
29+
{
30+
return 'slug';
31+
}
32+
33+
public function setTitleAttribute(string $value): void
34+
{
35+
$this->attributes['title'] = $value;
36+
37+
$this->attributes['slug'] = Str::slug($value);
38+
}
39+
}

tests/TestCase.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Tests;
4+
5+
class TestCase extends \Orchestra\Testbench\TestCase
6+
{
7+
protected function setUpTheDatabaseEnvironment(): void
8+
{
9+
$this->loadMigrationsFrom(__DIR__.'/database/migrations');
10+
11+
$this->withFactories(__DIR__.'/database/factories');
12+
}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
use Tests\Models\Snapshot;
4+
use Faker\Generator as Faker;
5+
6+
$factory->define(Snapshot::class, function (Faker $faker) {
7+
return [
8+
'title' => $faker->sentence,
9+
'url' => $faker->url,
10+
];
11+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
use Illuminate\Support\Facades\Schema;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Database\Migrations\Migration;
6+
7+
class CreateSnapshotsTable extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*
12+
* @return void
13+
*/
14+
public function up()
15+
{
16+
Schema::create('snapshots', function (Blueprint $table) {
17+
$table->bigIncrements('id');
18+
$table->string('title');
19+
$table->string('slug')->unique();
20+
$table->string('url');
21+
$table->softDeletes();
22+
$table->timestamps();
23+
});
24+
}
25+
26+
/**
27+
* Reverse the migrations.
28+
*
29+
* @return void
30+
*/
31+
public function down()
32+
{
33+
Schema::dropIfExists('snapshots');
34+
}
35+
}

0 commit comments

Comments
 (0)