Skip to content
This repository has been archived by the owner on Sep 18, 2022. It is now read-only.

Commit

Permalink
Merge 5cd6dc5 into 68a9f08
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Nov 29, 2019
2 parents 68a9f08 + 5cd6dc5 commit 32b0931
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -35,7 +35,8 @@
"require-dev": {
"bamarni/composer-bin-plugin": "^1.2",
"cache/adapter-bundle": "^1.2",
"sllh/composer-lint": "^1.0"
"sllh/composer-lint": "^1.0",
"symfony/browser-kit": "^3.4 || ^4.0"
},
"suggest": {
"cache/adapter-bundle": "If you need caching.",
Expand Down
25 changes: 25 additions & 0 deletions tests/Action/SitemapXMLActionIntegrationTest.php
@@ -0,0 +1,25 @@
<?php

/*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Core23\SitemapBundle\Tests\Action;

use Core23\SitemapBundle\Tests\App\AppKernel;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;

final class SitemapXMLActionIntegrationTest extends TestCase
{
public function testSitemapXml(): void
{
$client = new KernelBrowser(new AppKernel());
$client->request('GET', '/sitemap.xml');

static::assertSame(200, $client->getResponse()->getStatusCode());
}
}
68 changes: 68 additions & 0 deletions tests/App/AppKernel.php
@@ -0,0 +1,68 @@
<?php

declare(strict_types=1);

/*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Core23\SitemapBundle\Tests\App;

use Core23\SitemapBundle\Core23SitemapBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\RouteCollectionBuilder;

final class AppKernel extends Kernel
{
use MicroKernelTrait;

public function __construct()
{
parent::__construct('test', false);
}

public function registerBundles()
{
return [
new FrameworkBundle(),
new Core23SitemapBundle(),
];
}

public function getCacheDir(): string
{
return $this->getBaseDir().'cache';
}

public function getLogDir(): string
{
return $this->getBaseDir().'log';
}

public function getProjectDir(): string
{
return __DIR__;
}

protected function configureRoutes(RouteCollectionBuilder $routes): void
{
$routes->import(__DIR__.'/../../src/Resources/config/routing/sitemap.yml');
}

protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void
{
$loader->load(__DIR__.'/config/config.yaml');
}

private function getBaseDir(): string
{
return sys_get_temp_dir().'/app-bundle/var/';
}
}
29 changes: 29 additions & 0 deletions tests/App/Sitemap/DemoSitemap.php
@@ -0,0 +1,29 @@
<?php

/*
* (c) Christian Gripp <mail@core23.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Core23\SitemapBundle\Tests\App\Sitemap;

use Core23\SitemapBundle\Definition\SitemapDefinitionInterface;
use Core23\SitemapBundle\Model\Url;
use Core23\SitemapBundle\Sitemap\SitemapServiceInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

final class DemoSitemap implements SitemapServiceInterface
{
public function configureSettings(OptionsResolver $resolver): void
{
}

public function execute(SitemapDefinitionInterface $sitemap): array
{
return [
new Url('example.com'),
];
}
}
11 changes: 11 additions & 0 deletions tests/App/config/config.yaml
@@ -0,0 +1,11 @@
framework:
secret: secret

services:
_defaults:
autowire: true
autoconfigure: true

Core23\SitemapBundle\Tests\App\Sitemap\DemoSitemap:
tags: ['core23.sitemap']

0 comments on commit 32b0931

Please sign in to comment.