3 namespace Shaarli\Formatter
;
5 use Shaarli\Config\ConfigManager
;
9 * Class FormatterFactoryTest
11 * @package Shaarli\Formatter
13 class FormatterFactoryTest
extends TestCase
15 /** @var string Path of test config file */
16 protected static $testConf = 'sandbox/config';
18 /** @var FormatterFactory instance */
21 /** @var ConfigManager instance */
25 * Initialize FormatterFactory instance
27 protected function setUp(): void
29 copy('tests/utils/config/configJson.json.php', self
::$testConf .'.json.php');
30 $this->conf
= new ConfigManager(self
::$testConf);
31 $this->factory
= new FormatterFactory($this->conf
, true);
35 * Test creating an instance of BookmarkFormatter without any setting -> default formatter
37 public function testCreateInstanceDefault()
39 $this->assertInstanceOf(BookmarkDefaultFormatter
::class, $this->factory
->getFormatter());
43 * Test creating an instance of BookmarkDefaultFormatter from settings
45 public function testCreateInstanceDefaultSetting()
47 $this->conf
->set('formatter', 'default');
48 $this->assertInstanceOf(BookmarkDefaultFormatter
::class, $this->factory
->getFormatter());
52 * Test creating an instance of BookmarkDefaultFormatter from parameter
54 public function testCreateInstanceDefaultParameter()
56 $this->assertInstanceOf(
57 BookmarkDefaultFormatter
::class,
58 $this->factory
->getFormatter('default')
63 * Test creating an instance of BookmarkRawFormatter from settings
65 public function testCreateInstanceRawSetting()
67 $this->conf
->set('formatter', 'raw');
68 $this->assertInstanceOf(BookmarkRawFormatter
::class, $this->factory
->getFormatter());
72 * Test creating an instance of BookmarkRawFormatter from parameter
74 public function testCreateInstanceRawParameter()
76 $this->assertInstanceOf(
77 BookmarkRawFormatter
::class,
78 $this->factory
->getFormatter('raw')
83 * Test creating an instance of BookmarkMarkdownFormatter from settings
85 public function testCreateInstanceMarkdownSetting()
87 $this->conf
->set('formatter', 'markdown');
88 $this->assertInstanceOf(BookmarkMarkdownFormatter
::class, $this->factory
->getFormatter());
92 * Test creating an instance of BookmarkMarkdownFormatter from parameter
94 public function testCreateInstanceMarkdownParameter()
96 $this->assertInstanceOf(
97 BookmarkMarkdownFormatter
::class,
98 $this->factory
->getFormatter('markdown')