Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Adapting tests for dependecy injection.

 - Using orchestra/testbench for testing laravel package.
 - Using config helper instead config parameters.
 - Using App:make instead new Sitemap.
 - Changing required version of PHPUnit for testing (the older version wasn't compatible with orchestra/testbench).
 - Remove artisan property in Sitemap class.
 - Fix cache class injection in SitemapServiceProvider class.
  • Loading branch information...
fjborquez committed Oct 4, 2017
1 parent d7a0ef7 commit 6cc3581fe09ba2f22bac0445d2fadef1b2adbaf3
Showing with 19 additions and 11 deletions.
  1. +2 −1 composer.json
  2. +0 −1 src/Roumen/Sitemap/Sitemap.php
  3. +1 −1 src/Roumen/Sitemap/SitemapServiceProvider.php
  4. +16 −8 tests/SitemapTest.php
@@ -17,7 +17,8 @@
"illuminate/support": "5.5.*"
},
"require-dev": {
"phpunit/phpunit": "5.4.*"
"phpunit/phpunit": "~6.0",
"orchestra/testbench": "3.5.*"
},
"autoload": {
"psr-0": {
@@ -73,7 +73,6 @@ public function __construct(array $config, CacheRepository $cache, ConfigReposit
$this->file = $file;
$this->response = $response;
$this->view = $view;
$this->artisan = $artisan;
$this->model = new Model($config);
}
@@ -51,7 +51,7 @@ public function register()
return new Sitemap(
$config,
$app['cache'],
$app['Illuminate\Cache\Repository'],
$app['config'],
$app['files'],
$app['Illuminate\Contracts\Routing\ResponseFactory'],
@@ -1,23 +1,31 @@
<?php
<?php namespace Roumen\Sitemap\Test;
class SitemapTest extends PHPUnit_Framework_TestCase
use Orchestra\Testbench\TestCase as TestCase;
class SitemapTest extends TestCase
{
protected $sitemap;
protected function getPackageProviders($app)
{
return ['Roumen\Sitemap\SitemapServiceProvider'];
}
public function setUp()
{
parent::setUp();
// config
$config = [
'use_cache' => false,
'cache_key' => 'Laravel.Sitemap.',
'cache_duration' => 3600,
'testing' => true
'sitemap.use_cache' => false,
'sitemap.cache_key' => 'Laravel.Sitemap.',
'sitemap.cache_duration' => 3600,
'sitemap.testing' => true
];
$this->sitemap = new Roumen\Sitemap\Sitemap($config);
config($config);
$this->sitemap = $this->app->make('Roumen\Sitemap\Sitemap');
}

0 comments on commit 6cc3581

Please sign in to comment.
You can’t perform that action at this time.