Skip to content

Commit

Permalink
Merge pull request #14 from ARCANEDEV/develop
Browse files Browse the repository at this point in the history
Updating the tests
  • Loading branch information
arcanedev-maroc authored Mar 19, 2024
2 parents 1bf0a37 + cc14eae commit e4f3797
Show file tree
Hide file tree
Showing 56 changed files with 407 additions and 330 deletions.
8 changes: 5 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
bootstrap="vendor/autoload.php"
colors="true"
>
<source>
<include>
<directory>src</directory>
</include>
</source>
<testsuites>
<testsuite name="Package Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="build/coverage/clover.xml"/>
<html outputDirectory="build/coverage/html"/>
Expand Down
9 changes: 5 additions & 4 deletions tests/Elements/ATest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Arcanedev\Html\Tests\Elements;

use Arcanedev\Html\Elements\A;
use PHPUnit\Framework\Attributes\Test;

/**
* Class ATest
Expand All @@ -18,7 +19,7 @@ class ATest extends TestCase
| -----------------------------------------------------------------
*/

/** @test */
#[Test]
public function it_can_create(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -27,7 +28,7 @@ public function it_can_create(): void
);
}

/** @test */
#[Test]
public function it_can_create_with_a_href(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -36,7 +37,7 @@ public function it_can_create_with_a_href(): void
);
}

/** @test */
#[Test]
public function it_can_create_with_custom_data_attributes(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -45,7 +46,7 @@ public function it_can_create_with_custom_data_attributes(): void
);
}

/** @test */
#[Test]
public function it_can_create_an_a_element_with_a_target(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand Down
13 changes: 7 additions & 6 deletions tests/Elements/ButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Arcanedev\Html\Tests\Elements;

use Arcanedev\Html\Elements\{Button, I};
use PHPUnit\Framework\Attributes\Test;

/**
* Class ButtonTest
Expand All @@ -18,7 +19,7 @@ class ButtonTest extends TestCase
| -----------------------------------------------------------------
*/

/** @test */
#[Test]
public function it_can_create(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -27,7 +28,7 @@ public function it_can_create(): void
);
}

/** @test */
#[Test]
public function it_can_create_with_custom_type_and_value(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -36,7 +37,7 @@ public function it_can_create_with_custom_type_and_value(): void
);
}

/** @test */
#[Test]
public function it_can_create_with_content(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -45,7 +46,7 @@ public function it_can_create_with_content(): void
);
}

/** @test */
#[Test]
public function it_can_create_with_html_content(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -54,7 +55,7 @@ public function it_can_create_with_html_content(): void
);
}

/** @test */
#[Test]
public function it_can_create_with_html_element_object(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -65,7 +66,7 @@ public function it_can_create_with_html_element_object(): void
);
}

/** @test */
#[Test]
public function it_can_create_with_a_specific_type(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand Down
11 changes: 5 additions & 6 deletions tests/Elements/DivTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace Arcanedev\Html\Tests\Elements;

use Arcanedev\Html\Elements\Div;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* Class DivTest
Expand All @@ -18,7 +20,7 @@ class DivTest extends TestCase
| -----------------------------------------------------------------
*/

/** @test */
#[Test]
public function it_can_create(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -27,11 +29,8 @@ public function it_can_create(): void
);
}

/**
* @test
*
* @dataProvider getCustomStylesDP
*/
#[Test]
#[DataProvider('getCustomStylesDP')]
public function it_can_create_with_custom_styles(array $styles, string $expected): void
{
static::assertHtmlStringEqualsHtmlString(
Expand Down
13 changes: 7 additions & 6 deletions tests/Elements/DlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Arcanedev\Html\Tests\Elements;

use Arcanedev\Html\Elements\Dl;
use PHPUnit\Framework\Attributes\Test;

/**
* Class DlTest
Expand All @@ -18,7 +19,7 @@ class DlTest extends TestCase
| -----------------------------------------------------------------
*/

/** @test */
#[Test]
public function it_can_be_instantiated(): void
{
$dl = Dl::make();
Expand All @@ -32,7 +33,7 @@ public function it_can_be_instantiated(): void
}
}

/** @test */
#[Test]
public function it_can_make_list(): void
{
$dl = Dl::make();
Expand All @@ -48,7 +49,7 @@ public function it_can_make_list(): void
);
}

/** @test */
#[Test]
public function it_can_add_items(): void
{
$dl = Dl::make();
Expand Down Expand Up @@ -85,7 +86,7 @@ public function it_can_add_items(): void
);
}

/** @test */
#[Test]
public function it_can_add_html_items(): void
{
$items = [
Expand All @@ -107,7 +108,7 @@ public function it_can_add_html_items(): void
);
}

/** @test */
#[Test]
public function it_can_add_multiple_items_at_once_with_custom_attributes(): void
{
$items = [
Expand All @@ -132,7 +133,7 @@ public function it_can_add_multiple_items_at_once_with_custom_attributes(): void
);
}

/** @test */
#[Test]
public function it_can_add_multiple_items_with_multiple_definitions(): void
{
$items = [
Expand Down
19 changes: 10 additions & 9 deletions tests/Elements/ElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Arcanedev\Html\Elements\Div;
use Arcanedev\Html\Elements\HtmlElement;
use PHPUnit\Framework\Attributes\Test;

/**
* Class ElementTest
Expand All @@ -19,7 +20,7 @@ class ElementTest extends TestCase
| -----------------------------------------------------------------
*/

/** @test */
#[Test]
public function it_can_create_an_element(): void
{
static::assertEquals(
Expand All @@ -28,7 +29,7 @@ public function it_can_create_an_element(): void
);
}

/** @test */
#[Test]
public function it_can_create_an_element_with_attributes(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -37,7 +38,7 @@ public function it_can_create_an_element_with_attributes(): void
);
}

/** @test */
#[Test]
public function it_can_create_an_element_with_a_custom_tag(): void
{
static::assertSame(
Expand All @@ -46,7 +47,7 @@ public function it_can_create_an_element_with_a_custom_tag(): void
);
}

/** @test */
#[Test]
public function it_cant_create_an_element_without_a_tag(): void
{
$this->expectException(\Arcanedev\Html\Exceptions\MissingTagException::class);
Expand All @@ -55,7 +56,7 @@ public function it_cant_create_an_element_without_a_tag(): void
HtmlElement::make()->render();
}

/** @test */
#[Test]
public function it_can_add_conditional_changes(): void
{
$elt = HtmlElement::withTag('foo');
Expand All @@ -82,7 +83,7 @@ public function it_can_add_conditional_changes(): void
);
}

/** @test */
#[Test]
public function it_can_set_an_attribute_with_attribute_if(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -109,7 +110,7 @@ public function it_can_set_an_attribute_with_attribute_if(): void
);
}

/** @test */
#[Test]
public function it_can_get_class_list(): void
{
$elt = HtmlElement::withTag('a')->class('btn btn-primary');
Expand Down Expand Up @@ -139,7 +140,7 @@ public function it_can_get_class_list(): void
);
}

/** @test */
#[Test]
public function it_can_push_class_to_class_list(): void
{
$elt = HtmlElement::withTag('a')->class('btn btn-primary');
Expand All @@ -157,7 +158,7 @@ public function it_can_push_class_to_class_list(): void
static::assertCount(4, $elt->classList());
}

/** @test */
#[Test]
public function it_must_throw_exception_on_void_element_with_child_elements(): void
{
$this->expectException(\Arcanedev\Html\Exceptions\InvalidHtmlException::class);
Expand Down
5 changes: 3 additions & 2 deletions tests/Elements/FieldsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Arcanedev\Html\Tests\Elements;

use Arcanedev\Html\Elements\Fieldset;
use PHPUnit\Framework\Attributes\Test;

/**
* Class FieldsetTest
Expand All @@ -18,7 +19,7 @@ class FieldsetTest extends TestCase
| -----------------------------------------------------------------
*/

/** @test */
#[Test]
public function it_can_create(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand All @@ -27,7 +28,7 @@ public function it_can_create(): void
);
}

/** @test */
#[Test]
public function it_can_add_a_legend_to_the_fieldset(): void
{
static::assertHtmlStringEqualsHtmlString(
Expand Down
Loading

0 comments on commit e4f3797

Please sign in to comment.