From 67186f691085aea44ef60637e9ae011c23ee08fb Mon Sep 17 00:00:00 2001 From: "Marcel Kapfer (mmk2410)" Date: Sun, 5 Jun 2016 22:37:05 +0200 Subject: [PATCH] Unit test for Config.php --- tests/ConfigTest.php | 83 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/ConfigTest.php diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php new file mode 100644 index 0000000..5ac88d3 --- /dev/null +++ b/tests/ConfigTest.php @@ -0,0 +1,83 @@ + array( + "title" => "Example Blog", + "author" => "John", + "description" => "A short description of your blog", + "home" => "on", + "homeurl" => "../", + "homename" => "Home", + "mainname" => "", + "intro" => "on", + "disqus" => "rangitaki", + "analytics" => "", + "footer" => + "Rangitaki 2016 \n gitlab.com/mmk2410/rangitaki", "url" => "https://example.com/blog/", + ), + "design" => array( + "fab" => "on", + "drawer" => "on", + "theme" => "material-light", + "pagination" => 0, + "favicon" => "http://example.com/res/img/favicon.png", + ), + "rcc" => array( + "rcc" => "on", + "api" => "on", + ), + "language" => "en", + ]; + + $configParser = new Config("./config.yaml", "./vendor/autoload.php"); + $this->assertEquals($config, $configParser->getConfig()); + } + + public function testWriteReadConfig() + { + $changedConfig = [ + "blog" => array( + "title" => "Examples Blog", + "author" => "Wilson O'Sullivan", + "description" => "A long description of your blog", + "home" => "on", + "homeurl" => "../", + "homename" => "Exit", + "mainname" => "", + "intro" => "on", + "disqus" => "", + "analytics" => "", + "footer" => + "pBlog 1102 + \n gitlab.com/mmk2410/rangitaki", "url" => "https://example.com/blog/", + ), + "design" => array( + "fab" => "off", + "drawer" => "off", + "theme" => "material-dark", + "pagination" => "-1", + "favicon" => "http://sample.com/res/img/favicon.png", + ), + "rcc" => array( + "rcc" => "on", + "api" => "off", + ), + "language" => "en", + ]; + $configParser = new Config("/tmp/config-test.yaml", "./vendor/autoload.php"); + $configParser->writeConfig($changedConfig); + $this->assertEquals($changedConfig, $configParser->getConfig()); + } +}