Skip to content

Commit 9f1a6af

Browse files
author
Frank Verhoeven
authored
Merge pull request #4 from MyOnlineStore/TD-207
TD-207 upgrade to SF 4.4|5.3
2 parents 6f565c3 + f1da140 commit 9f1a6af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+122
-806
lines changed

.coveralls.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

.scrutinizer.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.styleci.yml

Lines changed: 0 additions & 13 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

Composer/ScriptHandler.php

Lines changed: 0 additions & 23 deletions
This file was deleted.

Tests/AppKernel.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

Tests/Command/DumpEmoticonsCommandTest.php

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,59 @@
22

33
namespace FM\BbcodeBundle\Tests\Command;
44

5+
use FM\BbcodeBundle\Command\DumpEmoticonsCommand;
56
use PHPUnit\Framework\TestCase;
67
use Symfony\Component\Console\Tester\CommandTester;
7-
use FM\BbcodeBundle\Command\DumpEmoticonsCommand;
8-
use Symfony\Component\DependencyInjection\ContainerInterface;
98

109
/**
1110
* @author Alexandre Quercia <alquerci@email.com>
1211
*/
1312
class DumpEmoticonsCommandTest extends TestCase
1413
{
14+
private $emoticonFolder;
15+
16+
private $emoticonPath;
17+
1518
private $rootDir;
19+
1620
private $webDir;
17-
private $emoticonPath;
18-
private $emoticonFolder;
1921

20-
public function setUp()
22+
public function setUp(): void
2123
{
22-
$this->rootDir = __DIR__.'/..';
23-
$this->webDir = sys_get_temp_dir().'/symfonyFMBbcodeweb';
24+
$this->rootDir = __DIR__ . '/..';
25+
$this->webDir = sys_get_temp_dir() . '/symfonyFMBbcodeweb';
2426
if (!file_exists($this->webDir)) {
2527
mkdir($this->webDir);
2628
}
27-
$this->emoticonPath = '/emoticons';
28-
$this->emoticonFolder = $this->rootDir.'/../vendor/mjohnson/decoda/emoticons';
29+
$this->emoticonPath = '/emoticons';
30+
$this->emoticonFolder = $this->rootDir . '/../vendor/mjohnson/decoda/emoticons';
2931
}
3032

31-
public function tearDown()
33+
public function tearDown(): void
3234
{
3335
if (!is_dir($this->webDir)) {
3436
return;
3537
}
3638
$this->removeDirectory($this->webDir);
3739
}
3840

39-
protected function removeDirectory($directory)
41+
public function testExecute(): void
4042
{
41-
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory), \RecursiveIteratorIterator::CHILD_FIRST);
43+
$command = new DumpEmoticonsCommand($this->webDir, $this->emoticonPath, $this->emoticonFolder);
44+
45+
$tester = new CommandTester($command);
46+
$tester->execute([]);
47+
48+
$this->assertFileExists($this->webDir . $this->emoticonPath);
49+
$this->assertEquals('Emoticons dumped succesfully' . PHP_EOL, $tester->getDisplay());
50+
}
51+
52+
protected function removeDirectory($directory): void
53+
{
54+
$iterator = new \RecursiveIteratorIterator(
55+
new \RecursiveDirectoryIterator($directory),
56+
\RecursiveIteratorIterator::CHILD_FIRST
57+
);
4258
foreach ($iterator as $path) {
4359
if (preg_match('#[/\\\\]\.\.?$#', $path->__toString())) {
4460
continue;
@@ -51,42 +67,4 @@ protected function removeDirectory($directory)
5167
}
5268
@rmdir($directory);
5369
}
54-
55-
public function testExecute()
56-
{
57-
$webDir = $this->webDir;
58-
$emoticonPath = $this->emoticonPath;
59-
$rootDir = $this->rootDir;
60-
$emoticonFolder = $this->emoticonFolder;
61-
62-
$container = $this->createMock(ContainerInterface::class);
63-
$container
64-
->expects($this->any())
65-
->method('getParameter')
66-
->withAnyParameters()
67-
->will($this->returnCallback(function ($v) use ($webDir, $emoticonPath, $rootDir, $emoticonFolder) {
68-
switch ($v) {
69-
case 'fm_bbcode.public_path':
70-
return $webDir;
71-
case 'fm_bbcode.emoticon.path':
72-
return $emoticonPath;
73-
case 'fm_bbcode.emoticon.folder':
74-
return $emoticonFolder;
75-
case 'kernel.root_dir':
76-
return $rootDir;
77-
default:
78-
throw new \RuntimeException(sprintf('Unknown parameter "%s".', $v));
79-
}
80-
}))
81-
;
82-
83-
$command = new DumpEmoticonsCommand();
84-
$command->setContainer($container);
85-
86-
$tester = new CommandTester($command);
87-
$tester->execute(array());
88-
89-
$this->assertFileExists($this->webDir.$this->emoticonPath);
90-
$this->assertEquals('Emoticons dumped succesfully'.PHP_EOL, $tester->getDisplay());
91-
}
9270
}

Tests/Decoda/DecodaManagerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class DecodaManagerTest extends TestCase
1717
*/
1818
protected $object;
1919

20-
protected function setUp()
20+
protected function setUp(): void
2121
{
2222
$container = $this->createMock(ContainerInterface::class);
2323
$kernel = $this->createMock(KernelInterface::class);
@@ -32,22 +32,22 @@ protected function setUp()
3232
$this->object = new DecodaManager($container, $locator, $options);
3333
}
3434

35-
public function testHas()
35+
public function testHas(): void
3636
{
3737
$this->assertTrue($this->object->has(DecodaManager::DECODA_DEFAULT));
3838
$this->assertTrue($this->object->has('foo'));
3939
$this->assertFalse($this->object->has('bar'));
4040
}
4141

42-
public function testSetFilter()
42+
public function testSetFilter(): void
4343
{
4444
$filter = $this->createMock(Filter::class);
4545
$this->object->setFilter('foo', $filter);
4646
$this->assertTrue($this->object->hasFilter('foo'));
4747
$this->assertSame($filter, $this->object->getFilter('foo'));
4848
}
4949

50-
public function testSetHook()
50+
public function testSetHook(): void
5151
{
5252
$hook = $this->createMock(Hook::class);
5353
$this->object->setHook('foo', $hook);

Tests/Decoda/DecodaTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class DecodaTest extends TestCase
99
{
10-
public function testSetLocale()
10+
public function testSetLocale(): void
1111
{
1212
$result = new Decoda();
1313
$result->setDefaultLocale('en');
@@ -23,7 +23,7 @@ public function testSetLocale()
2323
/**
2424
* @dataProvider getMessage
2525
*/
26-
public function testMessage($defaultLocale, $locale, $value, $expect)
26+
public function testMessage($defaultLocale, $locale, $value, $expect): void
2727
{
2828
if ($expect instanceof \Exception) {
2929
$this->expectException(get_class($expect));
@@ -58,7 +58,7 @@ public function testMessage($defaultLocale, $locale, $value, $expect)
5858
$this->assertEquals($expect, $result->message($value));
5959
}
6060

61-
public function getMessage()
61+
public function getMessage(): array
6262
{
6363
return array(
6464
array(null, 'en', 'foo', 'foo-en'),

Tests/Decoda/Hook/EmoticonHookTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
class EmoticonHookTest extends TestCase
1313
{
14-
public function testGetMatcher()
14+
public function testGetMatcher(): void
1515
{
1616
$expectEmoticon = new Emoticon();
1717
$expectEmoticon->setSmiley(':foo:');

0 commit comments

Comments
 (0)