Skip to content

Commit c8d6464

Browse files
authored
Merge pull request #4 from mikebronner/patch-1
Add Laravel 6.0 compatibility.
2 parents 2cc6512 + fa8109d commit c8d6464

7 files changed

+105
-12
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor/
22
composer.lock
3+
.phpunit.result.cache

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,4 @@ Reference: [erusev/parsedown](https://github.com/erusev/parsedown/wiki/Tutorial:
7777

7878
## License
7979

80-
MIT
80+
MIT

composer.json

+13-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
}
1414
],
1515
"require": {
16-
"illuminate/support": "^5.1",
16+
"illuminate/support": "5.1 - 6.0",
1717
"erusev/parsedown": "~1.7"
1818
},
19+
"require-dev": {
20+
"orchestra/testbench": "3.9.x-dev@dev"
21+
},
1922
"autoload": {
2023
"psr-4": {
2124
"Yansongda\\LaravelParsedown\\": "src"
@@ -24,6 +27,11 @@
2427
"src/helpers.php"
2528
]
2629
},
30+
"autoload-dev": {
31+
"psr-4": {
32+
"Yansongda\\LaravelParsedown\\Tests\\": "tests"
33+
}
34+
},
2735
"extra": {
2836
"laravel": {
2937
"providers": [
@@ -34,5 +42,7 @@
3442
}
3543
}
3644
},
37-
"license": "MIT"
38-
}
45+
"license": "MIT",
46+
"minimum-stability": "dev",
47+
"prefer-stable": true
48+
}

phpunit.xml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
>
12+
<testsuites>
13+
<testsuite name="Tests">
14+
<directory suffix="Test.php">./tests</directory>
15+
</testsuite>
16+
</testsuites>
17+
<filter>
18+
<whitelist processUncoveredFilesFromWhitelist="true">
19+
<directory suffix=".php">./app</directory>
20+
</whitelist>
21+
</filter>
22+
<php>
23+
<env name="APP_ENV" value="testing"/>
24+
<env name="APP_KEY" value="base64:q+1Q2UvnkEsVI9JG5bSZMibWXtbspjdzcJKkj8woFVk="/>
25+
<env name="APP_DEBUG" value="true"/>
26+
<env name="APP_LOG_LEVEL" value="debug"/>
27+
<env name="CACHE_DRIVER" value="array"/>
28+
<env name="SESSION_DRIVER" value="file"/>
29+
<env name="QUEUE_DRIVER" value="sync"/>
30+
</php>
31+
</phpunit>

src/ParsedownServiceProvider.php

+13-8
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ class ParsedownServiceProvider extends ServiceProvider
2626
*/
2727
public function boot()
2828
{
29-
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
30-
$this->publishes([
31-
dirname(__DIR__).'/config/markdown.php' => config_path('markdown.php'),
32-
], 'laravel-parsedown-config');
29+
if ($this->app instanceof LaravelApplication
30+
&& $this->app->runningInConsole()
31+
) {
32+
$this->publishes(
33+
[
34+
__DIR__.'/config/markdown.php' => config_path('markdown.php'),
35+
],
36+
'laravel-parsedown-config'
37+
);
3338
} elseif ($this->app instanceof LumenApplication) {
3439
$this->app->configure('markdown');
3540
}
@@ -48,11 +53,11 @@ public function register()
4853
{
4954
$this->mergeConfigFrom(dirname(__DIR__).'/config/markdown.php', 'markdown');
5055

51-
$this->app->singleton(Parsedown::class, function ($app) {
56+
$this->app->singleton(Parsedown::class, function () {
5257
return Parsedown::instance()->setSafeMode(config('markdown.parsedown.safeMode'))
53-
->setBreaksEnabled(config('markdown.parsedown.breaksEnabled'))
54-
->setMarkupEscaped(config('markdown.parsedown.markupEscaped'))
55-
->setUrlsLinked(config('markdown.parsedown.urlsLinked'));
58+
->setBreaksEnabled(config('markdown.parsedown.breaksEnabled'))
59+
->setMarkupEscaped(config('markdown.parsedown.markupEscaped'))
60+
->setUrlsLinked(config('markdown.parsedown.urlsLinked'));
5661
});
5762

5863
$this->app->alias(Parsedown::class, 'parsedown');

tests/Facades/ParsedownTest.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Yansongda\LaravelParsedown\Tests\Facades;
4+
5+
use Yansongda\LaravelParsedown\Facades\Parsedown;
6+
use Yansongda\LaravelParsedown\Tests\TestCase;
7+
8+
class ParsedownTest extends TestCase
9+
{
10+
public function testHelperWorks()
11+
{
12+
$result = parsedown('# Heading 1');
13+
14+
$this->assertEquals('<h1>Heading 1</h1>', $result);
15+
}
16+
17+
public function testFacadeWorks()
18+
{
19+
$result = Parsedown::text('# Heading 1');
20+
21+
$this->assertEquals('<h1>Heading 1</h1>', $result);
22+
}
23+
24+
public function testSingletonWorks()
25+
{
26+
$result = app('parsedown')->text('# Heading 1');
27+
28+
$this->assertEquals('<h1>Heading 1</h1>', $result);
29+
}
30+
}

tests/TestCase.php

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Yansongda\LaravelParsedown\Tests;
4+
5+
use Orchestra\Testbench\TestCase as OrchestraTestCase;
6+
use Yansongda\LaravelParsedown\ParsedownServiceProvider;
7+
8+
abstract class TestCase extends OrchestraTestCase
9+
{
10+
protected function getPackageProviders($app)
11+
{
12+
return [
13+
ParsedownServiceProvider::class,
14+
];
15+
}
16+
}

0 commit comments

Comments
 (0)