Skip to content

Commit

Permalink
Merge pull request #51 from fedeisas/modernizing_package_dependencies
Browse files Browse the repository at this point in the history
Modernizing Package
  • Loading branch information
ceesvanegmond committed Aug 6, 2017
2 parents c73844d + 16c94e3 commit 4370043
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 65 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
charset = utf-8
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/vendor
/build
vendor/
build/
composer.phar
composer.lock
.DS_Store
23 changes: 23 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
filter:
excluded_paths: [tests/*]

checks:
php:
remove_extra_empty_lines: true
remove_php_closing_tag: true
remove_trailing_whitespace: true
fix_use_statements:
remove_unused: true
preserve_multiple: false
preserve_blanklines: true
order_alphabetically: true
fix_php_opening_tag: true
fix_linefeed: true
fix_line_ending: true
fix_identation_4spaces: true
fix_doc_comments: true

tools:
external_code_coverage:
timeout: 600
runs: 3
1 change: 1 addition & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
preset: psr2
21 changes: 15 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,28 @@
"tijsverkoyen/css-to-inline-styles": "~2.0"
},
"require-dev" : {
"jakub-onderka/php-parallel-lint": "0.8.*",
"jakub-onderka/php-console-highlighter": "0.3.*",
"phpmd/phpmd": "~1.5",
"phpunit/phpunit": "~4.0",
"satooshi/php-coveralls": "~0.7@dev",
"squizlabs/php_codesniffer": "~1.5",
"phpunit/phpunit": "~5.7",
"squizlabs/php_codesniffer": "^2.3",
"swiftmailer/swiftmailer": "~5.0"
},
"autoload": {
"psr-4": {
"Fedeisas\\LaravelMailCssInliner\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"test": "phpunit",
"check-style": "phpcs -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests",
"fix-style": "phpcbf -p --standard=PSR2 --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 src tests"
},
"config": {
"sort-packages": true
},
"extra": {
"laravel": {
"providers": [
Expand Down
15 changes: 0 additions & 15 deletions phpcs.xml

This file was deleted.

27 changes: 0 additions & 27 deletions phpmd.xml

This file was deleted.

7 changes: 7 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,11 @@
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
</phpunit>
6 changes: 3 additions & 3 deletions src/CssInlinerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public function loadOptions($options)

/**
* Find CSS stylesheet links and load them
*
* Loads the body of the message and passes
*
* Loads the body of the message and passes
* any link stylesheets to $this->css
* Removes any link elements
*
*
* @return string $message The message
*/
public function loadCssFilesFromLinks($message)
Expand Down
9 changes: 5 additions & 4 deletions src/LaravelMailCssInlinerServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Illuminate\Support\ServiceProvider;
use Swift_Mailer;
use Fedeisas\LaravelMailCssInliner\CssInlinerPlugin;

class LaravelMailCssInlinerServiceProvider extends ServiceProvider
{
Expand All @@ -13,7 +14,7 @@ class LaravelMailCssInlinerServiceProvider extends ServiceProvider
public function boot()
{
$this->publishes([
__DIR__.'/../config/css-inliner.php' => config_path('css-inliner.php'),
__DIR__ . '/../config/css-inliner.php' => config_path('css-inliner.php'),
], 'config');
}

Expand All @@ -24,14 +25,14 @@ public function boot()
*/
public function register()
{
$this->mergeConfigFrom(__DIR__.'/../config/css-inliner.php', 'css-inliner');
$this->mergeConfigFrom(__DIR__ . '/../config/css-inliner.php', 'css-inliner');

$this->app->singleton('Fedeisas\LaravelMailCssInliner\CssInlinerPlugin', function ($app) {
$this->app->singleton(CssInlinerPlugin::class, function ($app) {
return new CssInlinerPlugin($app['config']->get('css-inliner'));
});

$this->app->extend('swift.mailer', function (Swift_Mailer $swiftMailer, $app) {
$inlinerPlugin = $app->make('Fedeisas\LaravelMailCssInliner\CssInlinerPlugin');
$inlinerPlugin = $app->make(CssInlinerPlugin::class);
$swiftMailer->registerPlugin($inlinerPlugin);
return $swiftMailer;
});
Expand Down
33 changes: 25 additions & 8 deletions tests/CssInlinerPluginTest.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,43 @@
<?php

namespace Tests;

use Fedeisas\LaravelMailCssInliner\CssInlinerPlugin;
use Swift_Mailer;
use Swift_Message;
use Swift_NullTransport;
use PHPUnit\Framework\TestCase;

class CssInlinerPluginTest extends PHPUnit_Framework_TestCase
class CssInlinerPluginTest extends TestCase
{
/**
* @var array
*/
protected $stubs;

/**
* @var array
*/
protected $options;

protected static $stubDefinitions = array(
'plain-text', 'original-html', 'original-html-with-css',
'original-html-with-link-css', 'original-html-with-links-css',
'converted-html', 'converted-html-with-css', 'converted-html-with-links-css'
);
protected static $stubDefinitions = [
'plain-text',
'original-html',
'original-html-with-css',
'original-html-with-link-css',
'original-html-with-links-css',
'converted-html',
'converted-html-with-css',
'converted-html-with-links-css',
];

public function setUp()
{
foreach (self::$stubDefinitions as $stub) {
$this->stubs[$stub] = file_get_contents(__DIR__.'/stubs/'.$stub.'.stub');
$this->stubs[$stub] = file_get_contents(__DIR__ . '/stubs/' . $stub . '.stub');
}

$this->options = require(__DIR__.'/../config/css-inliner.php');
$this->options = require(__DIR__ . '/../config/css-inliner.php');
}

/** @test **/
Expand Down

0 comments on commit 4370043

Please sign in to comment.