Skip to content
This repository has been archived by the owner on Feb 26, 2023. It is now read-only.

Commit

Permalink
Missing test files after refactoring folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Sep 8, 2017
1 parent ed13abf commit e6e7ba5
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/Block/Service/ShariffShareBlockServiceTest.php
@@ -0,0 +1,61 @@
<?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\ShariffBundle\Tests\Block\Service;

use Core23\ShariffBundle\Block\Service\ShariffShareBlockService;
use Sonata\BlockBundle\Block\BlockContext;
use Sonata\BlockBundle\Model\Block;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\BlockBundle\Test\AbstractBlockServiceTestCase;

class ShariffShareBlockServiceTest extends AbstractBlockServiceTestCase
{
public function testDefaultSettings()
{
$blockService = new ShariffShareBlockService('block.service', $this->templating);
$blockContext = $this->getBlockContext($blockService);

$this->assertSettings(array(
'url' => null,
'class' => '',
'services' => array('twitter', 'facebook', 'googleplus'),
'theme' => 'standard',
'orientation' => 'horizontal',
'flattrUser' => null,
'flattrCategory' => null,
'template' => 'Core23ShariffBundle:Block:block_shariff.html.twig',
), $blockContext);
}

public function testExecute()
{
$block = new Block();

$blockContext = new BlockContext($block, array(
'url' => null,
'class' => '',
'services' => array('twitter', 'facebook', 'googleplus'),
'theme' => 'standard',
'orientation' => 'horizontal',
'flattrUser' => null,
'flattrCategory' => null,
'template' => 'Core23ShariffBundle:Block:block_shariff.html.twig',
));

$blockService = new ShariffShareBlockService('block.service', $this->templating);
$blockService->execute($blockContext);

$this->assertSame('Core23ShariffBundle:Block:block_shariff.html.twig', $this->templating->view);

$this->assertSame($blockContext, $this->templating->parameters['context']);
$this->assertInternalType('array', $this->templating->parameters['settings']);
$this->assertInstanceOf(BlockInterface::class, $this->templating->parameters['block']);
}
}
54 changes: 54 additions & 0 deletions tests/DependencyInjection/Core23ShariffExtensionTest.php
@@ -0,0 +1,54 @@
<?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\ShariffBundle\Tests\DependencyInjection;

use Core23\ShariffBundle\DependencyInjection\Core23ShariffExtension;
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractExtensionTestCase;

class Core23ShariffExtensionTest extends AbstractExtensionTestCase
{
public function testLoadDefault()
{
$this->load();

$this->assertContainerBuilderHasParameter('core23_shariff.options', array(
'domains' => array(),
'services' => array('GooglePlus', 'LinkedIn', 'Reddit', 'StumbleUpon', 'Flattr', 'Pinterest', 'Xing', 'AddThis'),
));
}

public function testLoadFacebook()
{
$this->load(array(
'services' => array(
'facebook' => array(
'app_id' => 'foo_id',
'secret' => 'app_secret',
),
),
));

$this->assertContainerBuilderHasParameter('core23_shariff.options', array(
'domains' => array(),
'services' => array('GooglePlus', 'Facebook', 'LinkedIn', 'Reddit', 'StumbleUpon', 'Flattr', 'Pinterest', 'Xing', 'AddThis'),
'Facebook' => array(
'app_id' => 'foo_id',
'secret' => 'app_secret',
),
));
}

protected function getContainerExtensions()
{
return array(
new Core23ShariffExtension(),
);
}
}

0 comments on commit e6e7ba5

Please sign in to comment.