Skip to content

Commit

Permalink
Merge pull request #4 from mikebronner/patch-1
Browse files Browse the repository at this point in the history
Add Laravel 6.0 compatibility.
  • Loading branch information
yansongda committed Sep 1, 2019
2 parents 2cc6512 + fa8109d commit c8d6464
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,2 +1,3 @@
vendor/
composer.lock
.phpunit.result.cache
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -77,4 +77,4 @@ Reference: [erusev/parsedown](https://github.com/erusev/parsedown/wiki/Tutorial:

## License

MIT
MIT
16 changes: 13 additions & 3 deletions composer.json
Expand Up @@ -13,9 +13,12 @@
}
],
"require": {
"illuminate/support": "^5.1",
"illuminate/support": "5.1 - 6.0",
"erusev/parsedown": "~1.7"
},
"require-dev": {
"orchestra/testbench": "3.9.x-dev@dev"
},
"autoload": {
"psr-4": {
"Yansongda\\LaravelParsedown\\": "src"
Expand All @@ -24,6 +27,11 @@
"src/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Yansongda\\LaravelParsedown\\Tests\\": "tests"
}
},
"extra": {
"laravel": {
"providers": [
Expand All @@ -34,5 +42,7 @@
}
}
},
"license": "MIT"
}
"license": "MIT",
"minimum-stability": "dev",
"prefer-stable": true
}
31 changes: 31 additions & 0 deletions phpunit.xml
@@ -0,0 +1,31 @@
<?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="Tests">
<directory suffix="Test.php">./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="APP_KEY" value="base64:q+1Q2UvnkEsVI9JG5bSZMibWXtbspjdzcJKkj8woFVk="/>
<env name="APP_DEBUG" value="true"/>
<env name="APP_LOG_LEVEL" value="debug"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="file"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>
21 changes: 13 additions & 8 deletions src/ParsedownServiceProvider.php
Expand Up @@ -26,10 +26,15 @@ class ParsedownServiceProvider extends ServiceProvider
*/
public function boot()
{
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
$this->publishes([
dirname(__DIR__).'/config/markdown.php' => config_path('markdown.php'),
], 'laravel-parsedown-config');
if ($this->app instanceof LaravelApplication
&& $this->app->runningInConsole()
) {
$this->publishes(
[
__DIR__.'/config/markdown.php' => config_path('markdown.php'),
],
'laravel-parsedown-config'
);
} elseif ($this->app instanceof LumenApplication) {
$this->app->configure('markdown');
}
Expand All @@ -48,11 +53,11 @@ public function register()
{
$this->mergeConfigFrom(dirname(__DIR__).'/config/markdown.php', 'markdown');

$this->app->singleton(Parsedown::class, function ($app) {
$this->app->singleton(Parsedown::class, function () {
return Parsedown::instance()->setSafeMode(config('markdown.parsedown.safeMode'))
->setBreaksEnabled(config('markdown.parsedown.breaksEnabled'))
->setMarkupEscaped(config('markdown.parsedown.markupEscaped'))
->setUrlsLinked(config('markdown.parsedown.urlsLinked'));
->setBreaksEnabled(config('markdown.parsedown.breaksEnabled'))
->setMarkupEscaped(config('markdown.parsedown.markupEscaped'))
->setUrlsLinked(config('markdown.parsedown.urlsLinked'));
});

$this->app->alias(Parsedown::class, 'parsedown');
Expand Down
30 changes: 30 additions & 0 deletions tests/Facades/ParsedownTest.php
@@ -0,0 +1,30 @@
<?php

namespace Yansongda\LaravelParsedown\Tests\Facades;

use Yansongda\LaravelParsedown\Facades\Parsedown;
use Yansongda\LaravelParsedown\Tests\TestCase;

class ParsedownTest extends TestCase
{
public function testHelperWorks()
{
$result = parsedown('# Heading 1');

$this->assertEquals('<h1>Heading 1</h1>', $result);
}

public function testFacadeWorks()
{
$result = Parsedown::text('# Heading 1');

$this->assertEquals('<h1>Heading 1</h1>', $result);
}

public function testSingletonWorks()
{
$result = app('parsedown')->text('# Heading 1');

$this->assertEquals('<h1>Heading 1</h1>', $result);
}
}
16 changes: 16 additions & 0 deletions tests/TestCase.php
@@ -0,0 +1,16 @@
<?php

namespace Yansongda\LaravelParsedown\Tests;

use Orchestra\Testbench\TestCase as OrchestraTestCase;
use Yansongda\LaravelParsedown\ParsedownServiceProvider;

abstract class TestCase extends OrchestraTestCase
{
protected function getPackageProviders($app)
{
return [
ParsedownServiceProvider::class,
];
}
}

0 comments on commit c8d6464

Please sign in to comment.