Skip to content

Commit

Permalink
Update tests add return types to some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kudashevs committed Apr 2, 2024
1 parent 41a5d74 commit 6d771c3
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 59 deletions.
14 changes: 7 additions & 7 deletions tests/Acceptance/ShareButtonsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function setUp(): void
}

/** @test */
public function an_instance_can_throw_an_exception_when_a_wrong_button_name()
public function an_instance_can_throw_an_exception_when_a_wrong_button_name(): void
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('ShareButtons::wrong()');
Expand All @@ -29,7 +29,7 @@ public function an_instance_can_throw_an_exception_when_a_wrong_button_name()
}

/** @test */
public function a_facade_can_throw_an_exception_when_a_wrong_button_name()
public function a_facade_can_throw_an_exception_when_a_wrong_button_name(): void
{
$this->expectException(BadMethodCallException::class);
$this->expectExceptionMessage('ShareButtons::wrong()');
Expand All @@ -38,7 +38,7 @@ public function a_facade_can_throw_an_exception_when_a_wrong_button_name()
}

/** @test */
public function an_instance_can_generate_one_share_button_url()
public function an_instance_can_generate_one_share_button_url(): void
{
$rawLinks = $this->share->page('https://mysite.com')
->twitter()
Expand All @@ -49,7 +49,7 @@ public function an_instance_can_generate_one_share_button_url()
}

/** @test */
public function a_facade_can_generate_one_share_button_url()
public function a_facade_can_generate_one_share_button_url(): void
{
$rawLinks = ShareButtonsFacade::page('https://mysite.com')
->twitter()
Expand All @@ -60,7 +60,7 @@ public function a_facade_can_generate_one_share_button_url()
}

/** @test */
public function an_instance_can_generate_one_share_button_link()
public function an_instance_can_generate_one_share_button_link(): void
{
$readyHtml = $this->share->page('https://mysite.com')
->twitter()
Expand All @@ -70,7 +70,7 @@ public function an_instance_can_generate_one_share_button_link()
}

/** @test */
public function a_facade_can_generate_one_share_button_link()
public function a_facade_can_generate_one_share_button_link(): void
{
$readyHtml = ShareButtonsFacade::page('https://mysite.com')
->twitter()
Expand All @@ -88,7 +88,7 @@ public function it_can_generate_an_expected_share_button(
string $url,
string $title,
string $expected
) {
): void {
$readyHtml = $this->share->page($url, $title)
->$media()
->getShareButtons();
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Factories/TemplaterFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class TemplaterFactoryTest extends TestCase
{
/** @test */
public function it_can_throw_an_exception_when_an_unknown_formatter_is_provided()
public function it_can_throw_an_exception_when_an_unknown_formatter_is_provided(): void
{
$this->expectException(InvalidTemplaterFactoryArgument::class);
$this->expectExceptionMessage('not a valid');
Expand All @@ -21,7 +21,7 @@ public function it_can_throw_an_exception_when_an_unknown_formatter_is_provided(
}

/** @test */
public function it_can_be_instantiated_from_options()
public function it_can_be_instantiated_from_options(): void
{
$formatter = TemplaterFactory::createFromOptions([
'templater' => LaravelTemplater::class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected function setUp(): void
}

/** @test */
public function it_skips_an_unknown_attribute()
public function it_skips_an_unknown_attribute(): void
{
$attributes = ['unknown' => 'test'];

Expand All @@ -25,7 +25,7 @@ public function it_skips_an_unknown_attribute()
}

/** @test */
public function it_returns_an_empty_string_when_no_attribute_provided()
public function it_returns_an_empty_string_when_no_attribute_provided(): void
{
$attributes = [];

Expand All @@ -35,7 +35,7 @@ public function it_returns_an_empty_string_when_no_attribute_provided()
}

/** @test */
public function it_formats_some_of_the_attributes()
public function it_formats_some_of_the_attributes(): void
{
$attributes = [
'class' => 'active',
Expand All @@ -55,7 +55,7 @@ public function it_formats_some_of_the_attributes()
}

/** @test */
public function it_formats_all_of_the_attributes()
public function it_formats_all_of_the_attributes(): void
{
$attributes = [
'class' => 'active',
Expand Down
19 changes: 11 additions & 8 deletions tests/Unit/Presenters/TemplateShareButtonsPresenterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ protected function setUp(): void
* @test
* @dataProvider provideDifferentPresentationOptions
*/
public function it_can_retrieve_presentation_data_from_options(array $options, string $method, string $expected)
{
public function it_can_retrieve_presentation_data_from_options(
array $options,
string $method,
string $expected
): void {
$this->presenter->refresh($options);

$presentation = $this->presenter->$method();
Expand Down Expand Up @@ -109,7 +112,7 @@ public static function provideDifferentPresentationOptions(): array
* @test
* @dataProvider provideDifferentPresentationConfigurations
*/
public function it_can_retrieve_presentation_data_from_configuration(string $configuration, string $method)
public function it_can_retrieve_presentation_data_from_configuration(string $configuration, string $method): void
{
$expected = config('share-buttons.' . $configuration);

Expand Down Expand Up @@ -141,7 +144,7 @@ public static function provideDifferentPresentationConfigurations(): array
}

/** @test */
public function it_can_format_an_element_with_presentation_data_from_configuration()
public function it_can_format_an_element_with_presentation_data_from_configuration(): void
{
$elementPrefix = config('share-buttons.element_prefix');
$elementSuffix = config('share-buttons.element_suffix');
Expand All @@ -160,7 +163,7 @@ public function it_can_format_an_element_with_presentation_data_from_configurati
}

/** @test */
public function it_can_format_an_element_with_presentation_data_from_options_provided_through_refresh_method()
public function it_can_format_an_element_with_presentation_data_from_options_provided_through_refresh_method(): void
{
$elementPrefix = '<p>';
$elementSuffix = '</p>';
Expand Down Expand Up @@ -188,7 +191,7 @@ public function it_can_format_an_element_body_with_presentation_data_from_option
string $url,
array $options,
string $expected
) {
): void {
$elementBody = $this->presenter->getElementBody(
'facebook',
array_merge([
Expand Down Expand Up @@ -245,7 +248,7 @@ public static function provideDifferentOptions(): array
}

/** @test */
public function it_cannot_override_presentation_data_with_options_provided_directly_without_calling_refresh_method()
public function it_cannot_override_presentation_data_with_options_provided_directly_without_calling_refresh_method(): void
{
$elementPrefix = config('share-buttons.element_prefix');
$elementSuffix = config('share-buttons.element_suffix');
Expand All @@ -266,7 +269,7 @@ public function it_cannot_override_presentation_data_with_options_provided_direc
}

/** @test */
public function it_cannot_override_presentation_data_from_arguments_with_options_provided_through_refresh_method()
public function it_cannot_override_presentation_data_from_arguments_with_options_provided_through_refresh_method(): void
{
$elementPrefix = config('share-buttons.element_prefix');
$elementSuffix = config('share-buttons.element_suffix');
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Presenters/TemplateShareButtonsUrlPresenterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected function setUp(): void
}

/** @test */
public function it_can_generate_an_empty_url_when_wrong_name()
public function it_can_generate_an_empty_url_when_wrong_name(): void
{
$generatedUrl = $this->presenter->generateUrl('wrong', []);

Expand All @@ -28,7 +28,7 @@ public function it_can_generate_an_empty_url_when_wrong_name()
* @test
* @dataProvider provideDifferentShareButtonsValues
*/
public function it_can_generate_a_url(string $name, array $arguments, string $expected)
public function it_can_generate_a_url(string $name, array $arguments, string $expected): void
{
$generatedUrl = $this->presenter->generateUrl($name, $arguments);

Expand Down Expand Up @@ -254,7 +254,7 @@ public static function provideDifferentShareButtonsValues(): array
}

/** @test */
public function it_can_generate_a_hashed_url_for_copylink()
public function it_can_generate_a_hashed_url_for_copylink(): void
{
config()->set('share-buttons.buttons.copylink.extra.hash', true);

Expand All @@ -264,7 +264,7 @@ public function it_can_generate_a_hashed_url_for_copylink()
}

/** @test */
public function it_can_generate_a_url_with_infromation_from_defaults()
public function it_can_generate_a_url_with_infromation_from_defaults(): void
{
$expectedUrl = 'https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmysite.com&quote=Default+share+text';

Expand All @@ -277,7 +277,7 @@ public function it_can_generate_a_url_with_infromation_from_defaults()
}

/** @test */
public function it_can_generate_a_url_with_information_from_call_options()
public function it_can_generate_a_url_with_information_from_call_options(): void
{
$expectedUrl = 'https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fmysite.com&quote=Title';

Expand All @@ -290,7 +290,7 @@ public function it_can_generate_a_url_with_information_from_call_options()
}

/** @test */
public function it_can_generate_a_url_with_summary_for_linkedin()
public function it_can_generate_a_url_with_summary_for_linkedin(): void
{
$expectedUrl = 'https://www.linkedin.com/sharing/share-offsite?mini=true&url=https%3A%2F%2Fmysite.com&title=Default+share+text&summary=Share+text';

Expand Down
Loading

0 comments on commit 6d771c3

Please sign in to comment.