From e5bd424af1498b016f07b413bfbf607be81e7b43 Mon Sep 17 00:00:00 2001 From: webeweb Date: Wed, 4 Sep 2019 18:22:33 +0200 Subject: [PATCH] Improve unit tests --- CHANGELOG.md | 4 ++ Tests/Controller/LayoutControllerTest.php | 20 +--------- Tests/Controller/testFlashbagAction.html.txt | 16 ++++++++ .../Component/BreadcrumbTwigExtensionTest.php | 9 +---- .../ButtonGroupTwigExtensionTest.php | 18 ++------- .../Component/NavTwigExtensionTest.php | 40 ++++--------------- .../testBootstrapBreadcrumbsFunction.html.txt | 4 ++ ...BootstrapButtonGroupBasicFunction.html.txt | 4 ++ ...otstrapButtonGroupToolbarFunction.html.txt | 4 ++ .../testBootstrapNavsJustified.html.txt | 5 +++ .../Component/testBootstrapNavsPills.html.txt | 5 +++ .../testBootstrapNavsPillsWithItems.html.txt | 5 +++ .../Component/testBootstrapNavsTabs.html.txt | 5 +++ 13 files changed, 67 insertions(+), 72 deletions(-) create mode 100644 Tests/Controller/testFlashbagAction.html.txt create mode 100644 Tests/Twig/Extension/Component/testBootstrapBreadcrumbsFunction.html.txt create mode 100644 Tests/Twig/Extension/Component/testBootstrapButtonGroupBasicFunction.html.txt create mode 100644 Tests/Twig/Extension/Component/testBootstrapButtonGroupToolbarFunction.html.txt create mode 100644 Tests/Twig/Extension/Component/testBootstrapNavsJustified.html.txt create mode 100644 Tests/Twig/Extension/Component/testBootstrapNavsPills.html.txt create mode 100644 Tests/Twig/Extension/Component/testBootstrapNavsPillsWithItems.html.txt create mode 100644 Tests/Twig/Extension/Component/testBootstrapNavsTabs.html.txt diff --git a/CHANGELOG.md b/CHANGELOG.md index c1c54343..0c4a0eeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ CHANGELOG ========= +### [3.3.2](https://github.com/webeweb/bootstrap-bundle/tree/v3.3.2) (2019-09-04) + +- Improve unit tests + ### [3.3.1](https://github.com/webeweb/bootstrap-bundle/tree/v3.3.1) (2019-07-22) - Add PHP extensions into Composer diff --git a/Tests/Controller/LayoutControllerTest.php b/Tests/Controller/LayoutControllerTest.php index 5817a604..fdf162f1 100644 --- a/Tests/Controller/LayoutControllerTest.php +++ b/Tests/Controller/LayoutControllerTest.php @@ -44,25 +44,7 @@ public function testBlankAction() { */ public function testFlashbagAction() { - $res = <<< EOT - - - - - -EOT; + $res = file_get_contents(__DIR__ . "/testFlashbagAction.html.txt") . " "; // Create a client. $client = static::createClient(); diff --git a/Tests/Controller/testFlashbagAction.html.txt b/Tests/Controller/testFlashbagAction.html.txt new file mode 100644 index 00000000..a89cd96d --- /dev/null +++ b/Tests/Controller/testFlashbagAction.html.txt @@ -0,0 +1,16 @@ + + + + diff --git a/Tests/Twig/Extension/Component/BreadcrumbTwigExtensionTest.php b/Tests/Twig/Extension/Component/BreadcrumbTwigExtensionTest.php index d8c572b2..df67e7dc 100644 --- a/Tests/Twig/Extension/Component/BreadcrumbTwigExtensionTest.php +++ b/Tests/Twig/Extension/Component/BreadcrumbTwigExtensionTest.php @@ -53,13 +53,8 @@ public function testBootstrapBreadcrumbsFunction() { $obj = new BreadcrumbTwigExtension($this->twigEnvironment, $this->translator); - $res = <<< EOT - -EOT; - $this->assertEquals($res, $obj->bootstrapBreadcrumbsFunction([], $this->tree, Request::create("https://github.com/webeweb/bootstrap-bundle"))); + $res = file_get_contents(__DIR__ . "/testBootstrapBreadcrumbsFunction.html.txt"); + $this->assertEquals($res, $obj->bootstrapBreadcrumbsFunction([], $this->tree, Request::create("https://github.com/webeweb/bootstrap-bundle")) . "\n"); } /** diff --git a/Tests/Twig/Extension/Component/ButtonGroupTwigExtensionTest.php b/Tests/Twig/Extension/Component/ButtonGroupTwigExtensionTest.php index b3aba283..1ed59e44 100644 --- a/Tests/Twig/Extension/Component/ButtonGroupTwigExtensionTest.php +++ b/Tests/Twig/Extension/Component/ButtonGroupTwigExtensionTest.php @@ -65,13 +65,8 @@ public function testBootstrapButtonGroupBasicFunction() { $obj = new ButtonGroupTwigExtension($this->twigEnvironment); $arg = []; - $res = <<< EOT -
- - -
-EOT; - $this->assertEquals($res, $obj->bootstrapButtonGroupBasicFunction($arg, [$this->editButton, $this->deleteButton])); + $res = file_get_contents(__DIR__ . "/testBootstrapButtonGroupBasicFunction.html.txt"); + $this->assertEquals($res, $obj->bootstrapButtonGroupBasicFunction($arg, [$this->editButton, $this->deleteButton]) . "\n"); } /** @@ -84,13 +79,8 @@ public function testBootstrapButtonGroupToolbarFunction() { $obj = new ButtonGroupTwigExtension($this->twigEnvironment); $arg = []; - $res = <<< EOT - -EOT; - $this->assertEquals($res, $obj->bootstrapButtonGroupToolbarFunction($arg, [$this->editButton, $this->deleteButton])); + $res = file_get_contents(__DIR__ . "/testBootstrapButtonGroupToolbarFunction.html.txt"); + $this->assertEquals($res, $obj->bootstrapButtonGroupToolbarFunction($arg, [$this->editButton, $this->deleteButton]) . "\n"); } /** diff --git a/Tests/Twig/Extension/Component/NavTwigExtensionTest.php b/Tests/Twig/Extension/Component/NavTwigExtensionTest.php index 14240deb..67e30855 100644 --- a/Tests/Twig/Extension/Component/NavTwigExtensionTest.php +++ b/Tests/Twig/Extension/Component/NavTwigExtensionTest.php @@ -55,14 +55,8 @@ public function testBootstrapNavsJustified() { $obj = new NavTwigExtension($this->twigEnvironment); $arg = ["items" => $this->items]; - $res = <<< EOT - -EOT; - $this->assertEquals($res, $obj->bootstrapNavsJustified($arg)); + $res = file_get_contents(__DIR__ . "/testBootstrapNavsJustified.html.txt"); + $this->assertEquals($res, $obj->bootstrapNavsJustified($arg) . "\n"); } /** @@ -75,14 +69,8 @@ public function testBootstrapNavsPills() { $obj = new NavTwigExtension($this->twigEnvironment); $arg = ["items" => $this->items, "stacked" => true]; - $res = <<< EOT - -EOT; - $this->assertEquals($res, $obj->bootstrapNavsPills($arg)); + $res = file_get_contents(__DIR__ . "/testBootstrapNavsPills.html.txt"); + $this->assertEquals($res, $obj->bootstrapNavsPills($arg) . "\n"); } /** @@ -95,14 +83,8 @@ public function testBootstrapNavsPillsWithItems() { $obj = new NavTwigExtension($this->twigEnvironment); $arg = ["items" => $this->items]; - $res = <<< EOT - -EOT; - $this->assertEquals($res, $obj->bootstrapNavsPills($arg)); + $res = file_get_contents(__DIR__ . "/testBootstrapNavsPillsWithItems.html.txt"); + $this->assertEquals($res, $obj->bootstrapNavsPills($arg) . "\n"); } /** @@ -115,14 +97,8 @@ public function testBootstrapNavsTabs() { $obj = new NavTwigExtension($this->twigEnvironment); $arg = ["items" => $this->items]; - $res = <<< EOT - -EOT; - $this->assertEquals($res, $obj->bootstrapNavsTabs($arg)); + $res = file_get_contents(__DIR__ . "/testBootstrapNavsTabs.html.txt"); + $this->assertEquals($res, $obj->bootstrapNavsTabs($arg) . "\n"); } /** diff --git a/Tests/Twig/Extension/Component/testBootstrapBreadcrumbsFunction.html.txt b/Tests/Twig/Extension/Component/testBootstrapBreadcrumbsFunction.html.txt new file mode 100644 index 00000000..6a7e5316 --- /dev/null +++ b/Tests/Twig/Extension/Component/testBootstrapBreadcrumbsFunction.html.txt @@ -0,0 +1,4 @@ + diff --git a/Tests/Twig/Extension/Component/testBootstrapButtonGroupBasicFunction.html.txt b/Tests/Twig/Extension/Component/testBootstrapButtonGroupBasicFunction.html.txt new file mode 100644 index 00000000..c9599fb2 --- /dev/null +++ b/Tests/Twig/Extension/Component/testBootstrapButtonGroupBasicFunction.html.txt @@ -0,0 +1,4 @@ +
+ + +
diff --git a/Tests/Twig/Extension/Component/testBootstrapButtonGroupToolbarFunction.html.txt b/Tests/Twig/Extension/Component/testBootstrapButtonGroupToolbarFunction.html.txt new file mode 100644 index 00000000..d59ff120 --- /dev/null +++ b/Tests/Twig/Extension/Component/testBootstrapButtonGroupToolbarFunction.html.txt @@ -0,0 +1,4 @@ + diff --git a/Tests/Twig/Extension/Component/testBootstrapNavsJustified.html.txt b/Tests/Twig/Extension/Component/testBootstrapNavsJustified.html.txt new file mode 100644 index 00000000..8b563d3a --- /dev/null +++ b/Tests/Twig/Extension/Component/testBootstrapNavsJustified.html.txt @@ -0,0 +1,5 @@ + diff --git a/Tests/Twig/Extension/Component/testBootstrapNavsPills.html.txt b/Tests/Twig/Extension/Component/testBootstrapNavsPills.html.txt new file mode 100644 index 00000000..fec959cb --- /dev/null +++ b/Tests/Twig/Extension/Component/testBootstrapNavsPills.html.txt @@ -0,0 +1,5 @@ + diff --git a/Tests/Twig/Extension/Component/testBootstrapNavsPillsWithItems.html.txt b/Tests/Twig/Extension/Component/testBootstrapNavsPillsWithItems.html.txt new file mode 100644 index 00000000..0f1cca60 --- /dev/null +++ b/Tests/Twig/Extension/Component/testBootstrapNavsPillsWithItems.html.txt @@ -0,0 +1,5 @@ + diff --git a/Tests/Twig/Extension/Component/testBootstrapNavsTabs.html.txt b/Tests/Twig/Extension/Component/testBootstrapNavsTabs.html.txt new file mode 100644 index 00000000..3cd65845 --- /dev/null +++ b/Tests/Twig/Extension/Component/testBootstrapNavsTabs.html.txt @@ -0,0 +1,5 @@ +