From e26e2060f5470ce8bf4c5973284bae07b8af170a Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 17 Jan 2020 21:34:12 +0100 Subject: Add and update unit test for the new system (Bookmark + Service) See #1307 --- tests/formatter/FormatterFactoryTest.php | 101 +++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tests/formatter/FormatterFactoryTest.php (limited to 'tests/formatter/FormatterFactoryTest.php') diff --git a/tests/formatter/FormatterFactoryTest.php b/tests/formatter/FormatterFactoryTest.php new file mode 100644 index 00000000..317c0b2d --- /dev/null +++ b/tests/formatter/FormatterFactoryTest.php @@ -0,0 +1,101 @@ +conf = new ConfigManager(self::$testConf); + $this->factory = new FormatterFactory($this->conf); + } + + /** + * 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') + ); + } +} -- cgit v1.2.3