Skip to content

Commit

Permalink
Improve unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
webeweb committed Sep 4, 2019
1 parent 69b112a commit e5bd424
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 72 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 1 addition & 19 deletions Tests/Controller/LayoutControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,7 @@ public function testBlankAction() {
*/
public function testFlashbagAction() {

$res = <<< EOT
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Danger
</div>
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Info
</div>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Success
</div>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Warning
</div>
EOT;
$res = file_get_contents(__DIR__ . "/testFlashbagAction.html.txt") . " ";

// Create a client.
$client = static::createClient();
Expand Down
16 changes: 16 additions & 0 deletions Tests/Controller/testFlashbagAction.html.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div class="alert alert-danger alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Danger
</div>
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Info
</div>
<div class="alert alert-success alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Success
</div>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
Warning
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,8 @@ public function testBootstrapBreadcrumbsFunction() {

$obj = new BreadcrumbTwigExtension($this->twigEnvironment, $this->translator);

$res = <<< EOT
<ol class="breadcrumb">
<li><a href="javascript:void(0);">GitHub</a></li>
<li class="active">Bootstrap bundle</li>
</ol>
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");
}

/**
Expand Down
18 changes: 4 additions & 14 deletions Tests/Twig/Extension/Component/ButtonGroupTwigExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,8 @@ public function testBootstrapButtonGroupBasicFunction() {
$obj = new ButtonGroupTwigExtension($this->twigEnvironment);

$arg = [];
$res = <<< EOT
<div class="btn-group" role="group">
<button class="btn btn-default" type="button">Edit</button>
<button class="btn btn-danger" type="button">Delete</button>
</div>
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");
}

/**
Expand All @@ -84,13 +79,8 @@ public function testBootstrapButtonGroupToolbarFunction() {
$obj = new ButtonGroupTwigExtension($this->twigEnvironment);

$arg = [];
$res = <<< EOT
<div class="btn-toolbar" role="toolbar">
<button class="btn btn-default" type="button">Edit</button>
<button class="btn btn-danger" type="button">Delete</button>
</div>
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");
}

/**
Expand Down
40 changes: 8 additions & 32 deletions Tests/Twig/Extension/Component/NavTwigExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,8 @@ public function testBootstrapNavsJustified() {
$obj = new NavTwigExtension($this->twigEnvironment);

$arg = ["items" => $this->items];
$res = <<< EOT
<ul class="nav nav-justified">
<li role="presentation"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Message</a></li>
</ul>
EOT;
$this->assertEquals($res, $obj->bootstrapNavsJustified($arg));
$res = file_get_contents(__DIR__ . "/testBootstrapNavsJustified.html.txt");
$this->assertEquals($res, $obj->bootstrapNavsJustified($arg) . "\n");
}

/**
Expand All @@ -75,14 +69,8 @@ public function testBootstrapNavsPills() {
$obj = new NavTwigExtension($this->twigEnvironment);

$arg = ["items" => $this->items, "stacked" => true];
$res = <<< EOT
<ul class="nav nav-pills nav-stacked">
<li role="presentation"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Message</a></li>
</ul>
EOT;
$this->assertEquals($res, $obj->bootstrapNavsPills($arg));
$res = file_get_contents(__DIR__ . "/testBootstrapNavsPills.html.txt");
$this->assertEquals($res, $obj->bootstrapNavsPills($arg) . "\n");
}

/**
Expand All @@ -95,14 +83,8 @@ public function testBootstrapNavsPillsWithItems() {
$obj = new NavTwigExtension($this->twigEnvironment);

$arg = ["items" => $this->items];
$res = <<< EOT
<ul class="nav nav-pills">
<li role="presentation"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Message</a></li>
</ul>
EOT;
$this->assertEquals($res, $obj->bootstrapNavsPills($arg));
$res = file_get_contents(__DIR__ . "/testBootstrapNavsPillsWithItems.html.txt");
$this->assertEquals($res, $obj->bootstrapNavsPills($arg) . "\n");
}

/**
Expand All @@ -115,14 +97,8 @@ public function testBootstrapNavsTabs() {
$obj = new NavTwigExtension($this->twigEnvironment);

$arg = ["items" => $this->items];
$res = <<< EOT
<ul class="nav nav-tabs">
<li role="presentation"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Message</a></li>
</ul>
EOT;
$this->assertEquals($res, $obj->bootstrapNavsTabs($arg));
$res = file_get_contents(__DIR__ . "/testBootstrapNavsTabs.html.txt");
$this->assertEquals($res, $obj->bootstrapNavsTabs($arg) . "\n");
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<ol class="breadcrumb">
<li><a href="javascript:void(0);">GitHub</a></li>
<li class="active">Bootstrap bundle</li>
</ol>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="btn-group" role="group">
<button class="btn btn-default" type="button">Edit</button>
<button class="btn btn-danger" type="button">Delete</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="btn-toolbar" role="toolbar">
<button class="btn btn-default" type="button">Edit</button>
<button class="btn btn-danger" type="button">Delete</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul class="nav nav-justified">
<li role="presentation"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Message</a></li>
</ul>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul class="nav nav-pills nav-stacked">
<li role="presentation"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Message</a></li>
</ul>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul class="nav nav-pills">
<li role="presentation"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Message</a></li>
</ul>
5 changes: 5 additions & 0 deletions Tests/Twig/Extension/Component/testBootstrapNavsTabs.html.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<ul class="nav nav-tabs">
<li role="presentation"><a href="#">Home</a></li>
<li role="presentation"><a href="#">Profile</a></li>
<li role="presentation"><a href="#">Message</a></li>
</ul>

0 comments on commit e5bd424

Please sign in to comment.