1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
<?php
namespace Shaarli\Formatter;
use PHPUnit\Framework\TestCase;
use Shaarli\Config\ConfigManager;
/**
* Class FormatterFactoryTest
*
* @package Shaarli\Formatter
*/
class FormatterFactoryTest extends TestCase
{
/** @var string Path of test config file */
protected static $testConf = 'sandbox/config';
/** @var FormatterFactory instance */
protected $factory;
/** @var ConfigManager instance */
protected $conf;
/**
* Initialize FormatterFactory instance
*/
public function setUp()
{
copy('tests/utils/config/configJson.json.php', self::$testConf .'.json.php');
$this->conf = new ConfigManager(self::$testConf);
$this->factory = new FormatterFactory($this->conf, true);
}
/**
* Test creating an instance of BookmarkFormatter without any setting -> default formatter
*/
public function testCreateInstanceDefault()
{
$this->assertInstanceOf(BookmarkDefaultFormatter::class, $this->factory->getFormatter());
}
/**
* Test creating an instance of BookmarkDefaultFormatter from settings
*/
public function testCreateInstanceDefaultSetting()
{
$this->conf->set('formatter', 'default');
$this->assertInstanceOf(BookmarkDefaultFormatter::class, $this->factory->getFormatter());
}
/**
* Test creating an instance of BookmarkDefaultFormatter from parameter
*/
public function testCreateInstanceDefaultParameter()
{
$this->assertInstanceOf(
BookmarkDefaultFormatter::class,
$this->factory->getFormatter('default')
);
}
/**
* Test creating an instance of BookmarkRawFormatter from settings
*/
public function testCreateInstanceRawSetting()
{
$this->conf->set('formatter', 'raw');
$this->assertInstanceOf(BookmarkRawFormatter::class, $this->factory->getFormatter());
}
/**
* Test creating an instance of BookmarkRawFormatter from parameter
*/
public function testCreateInstanceRawParameter()
{
$this->assertInstanceOf(
BookmarkRawFormatter::class,
$this->factory->getFormatter('raw')
);
}
/**
* Test creating an instance of BookmarkMarkdownFormatter from settings
*/
public function testCreateInstanceMarkdownSetting()
{
$this->conf->set('formatter', 'markdown');
$this->assertInstanceOf(BookmarkMarkdownFormatter::class, $this->factory->getFormatter());
}
/**
* Test creating an instance of BookmarkMarkdownFormatter from parameter
*/
public function testCreateInstanceMarkdownParameter()
{
$this->assertInstanceOf(
BookmarkMarkdownFormatter::class,
$this->factory->getFormatter('markdown')
);
}
}
|