Skip to content

Commit 6beb865

Browse files
committed
refactor: change notation type in methods
The notation type in the test function names has been changed from camel to snake case for readability. Closes #5
1 parent b876735 commit 6beb865

9 files changed

+107
-81
lines changed

Diff for: CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# CHANGELOG
22

3+
## [v2.0.2](https://github.com/josantonius/php-error/releases/tag/v2.0.2) (2022-XX-XX)
4+
5+
* The notation type in the test function names has been changed from camel to snake case for readability.
6+
7+
* Functions were added to document the methods and avoid confusion.
8+
9+
* Disabled the ´CamelCaseMethodName´ rule in ´phpmd.xml´ to avoid warnings about function names in tests.
10+
11+
* The alignment of the asterisks in the comments has been fixed.
12+
313
## [v2.0.1](https://github.com/josantonius/php-error/releases/tag/v2.0.1) (2022-08-11)
414

515
* Documentation was improved.

Diff for: tests/ErrorExceptionTest.php

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-error-handler repository.
5-
*
6-
* (c) Josantonius <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-error-handler repository.
5+
*
6+
* (c) Josantonius <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
12+
*/
1113

1214
namespace Josantonius\ErrorHandler\Tests\ErrorHandler;
1315

@@ -34,27 +36,27 @@ public function setUp(): void
3436
$this->errorException = new ErrorException($errorHandled);
3537
}
3638

37-
public function testShouldGetFile(): void
39+
public function test_should_get_file(): void
3840
{
3941
$this->assertEquals('Error.php', $this->errorException->getFile());
4042
}
4143

42-
public function testShouldGetMessage(): void
44+
public function test_should_get_message(): void
4345
{
4446
$this->assertEquals('Error message', $this->errorException->getMessage());
4547
}
4648

47-
public function testShouldGetLevel(): void
49+
public function test_should_get_level(): void
4850
{
4951
$this->assertEquals(E_ERROR, $this->errorException->getLevel());
5052
}
5153

52-
public function testShouldGetLine(): void
54+
public function test_should_get_line(): void
5355
{
5456
$this->assertEquals(8, $this->errorException->getLine());
5557
}
5658

57-
public function testShouldGetName(): void
59+
public function test_should_get_name(): void
5860
{
5961
$this->assertEquals('Error', $this->errorException->getName());
6062
}

Diff for: tests/ErrorHandledTest.php

+14-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-error-handler repository.
5-
*
6-
* (c) Josantonius <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-error-handler repository.
5+
*
6+
* (c) Josantonius <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
12+
*/
1113

1214
namespace Josantonius\ErrorHandler\Tests\ErrorHandler;
1315

@@ -31,27 +33,27 @@ public function setUp(): void
3133
);
3234
}
3335

34-
public function testShouldGetFile(): void
36+
public function test_should_get_file(): void
3537
{
3638
$this->assertEquals('Error.php', $this->errorHandled->getFile());
3739
}
3840

39-
public function testShouldGetMessage(): void
41+
public function test_should_get_message(): void
4042
{
4143
$this->assertEquals('Error message', $this->errorHandled->getMessage());
4244
}
4345

44-
public function testShouldGetLevel(): void
46+
public function test_should_get_level(): void
4547
{
4648
$this->assertEquals(E_ERROR, $this->errorHandled->getLevel());
4749
}
4850

49-
public function testShouldGetLine(): void
51+
public function test_should_get_line(): void
5052
{
5153
$this->assertEquals(8, $this->errorHandled->getLine());
5254
}
5355

54-
public function testShouldGetName(): void
56+
public function test_should_get_name(): void
5557
{
5658
$this->assertEquals('Error', $this->errorHandled->getName());
5759
}

Diff for: tests/ErrorHandler/CheckForShutdownErrorsTest.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-error-handler repository.
5-
*
6-
* (c) Josantonius <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-error-handler repository.
5+
*
6+
* (c) Josantonius <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
12+
*/
1113

1214
namespace Josantonius\ErrorHandler\Tests\ErrorHandler;
1315

@@ -32,7 +34,7 @@ public function setUp(): void
3234
$this->errorHandler = new ErrorHandler();
3335
}
3436

35-
public function testShouldSendTheHandlerAShutdownError(): void
37+
public function test_should_send_the_handler_a_shutdown_error(): void
3638
{
3739
$this->errorHandler->register($this->handler->init(...));
3840

@@ -44,7 +46,7 @@ public function testShouldSendTheHandlerAShutdownError(): void
4446
$this->assertEquals(E_ERROR, History::get(0)->errorHandled->getLevel());
4547
}
4648

47-
public function testShouldIgnoreAnythingOtherThanAShutdownError(): void
49+
public function test_should_ignore_anything_other_than_a_shutdown_error(): void
4850
{
4951
$this->errorHandler->register($this->handler->init(...));
5052

Diff for: tests/ErrorHandler/ConvertToExceptionsExceptTest.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-error-handler repository.
5-
*
6-
* (c) Josantonius <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-error-handler repository.
5+
*
6+
* (c) Josantonius <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
12+
*/
1113

1214
namespace Josantonius\ErrorHandler\Tests\ErrorHandler;
1315

@@ -31,7 +33,7 @@ public function setUp(): void
3133
$this->errorLevels = $this->getPrivateProperty($this->errorHandler, 'errorLevels');
3234
}
3335

34-
public function testShouldSetConvertToExceptionsAllErrorsExceptNone(): void
36+
public function test_should_set_convert_to_exceptions_all_errors_except_none(): void
3537
{
3638
$this->assertInstanceOf(
3739
ErrorHandler::class,
@@ -43,7 +45,7 @@ public function testShouldSetConvertToExceptionsAllErrorsExceptNone(): void
4345
$this->assertSame(array_keys($this->errorLevels), $exceptionable);
4446
}
4547

46-
public function testShouldSetConvertToExceptionsAllErrorsExceptSome(): void
48+
public function test_should_set_convert_to_exceptions_all_errors_except_some(): void
4749
{
4850
$this->assertInstanceOf(
4951
ErrorHandler::class,
@@ -57,7 +59,7 @@ public function testShouldSetConvertToExceptionsAllErrorsExceptSome(): void
5759
$this->assertSame(array_keys($this->errorLevels), $exceptionable);
5860
}
5961

60-
public function testShouldFailIfTheErrorLevelPassedToConvertToExceptionsExceptIsWrong(): void
62+
public function test_should_fail_if_error_level_passed_to_convert_is_wrong(): void
6163
{
6264
$this->expectException(WrongErrorLevelException::class);
6365

Diff for: tests/ErrorHandler/ConvertToExceptionsTest.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-error-handler repository.
5-
*
6-
* (c) Josantonius <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-error-handler repository.
5+
*
6+
* (c) Josantonius <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
12+
*/
1113

1214
namespace Josantonius\ErrorHandler\Tests\ErrorHandler;
1315

@@ -31,7 +33,7 @@ public function setUp(): void
3133
$this->errorLevels = $this->getPrivateProperty($this->errorHandler, 'errorLevels');
3234
}
3335

34-
public function testShouldSetConvertToExceptionsAllErrors(): void
36+
public function test_should_set_convert_to_exceptions_all_errors(): void
3537
{
3638
$this->assertInstanceOf(ErrorHandler::class, $this->errorHandler->convertToExceptions());
3739

@@ -40,7 +42,7 @@ public function testShouldSetConvertToExceptionsAllErrors(): void
4042
$this->assertSame(array_keys($this->errorLevels), $exceptionable);
4143
}
4244

43-
public function testShouldSetConvertToExceptionsSomeErrors(): void
45+
public function test_should_set_convert_to_exceptions_some_errors(): void
4446
{
4547
$this->assertInstanceOf(
4648
ErrorHandler::class,
@@ -52,7 +54,7 @@ public function testShouldSetConvertToExceptionsSomeErrors(): void
5254
$this->assertSame([E_WARNING, E_NOTICE], $exceptionable);
5355
}
5456

55-
public function testShouldFailIfTheErrorLevelPassedToConvertToExceptionsIsWrong(): void
57+
public function test_should_fail_if_error_level_passed_to_convert_is_wrong(): void
5658
{
5759
$this->expectException(WrongErrorLevelException::class);
5860

Diff for: tests/ErrorHandler/HandlerTest.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-error-handler repository.
5-
*
6-
* (c) Josantonius <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-error-handler repository.
5+
*
6+
* (c) Josantonius <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
12+
*/
1113

1214
namespace Josantonius\ErrorHandler\Tests\ErrorHandler;
1315

@@ -34,7 +36,7 @@ public function setUp(): void
3436
$this->errorHandler = new ErrorHandler();
3537
}
3638

37-
public function testShouldConvertErrorsToExceptions(): void
39+
public function test_should_convert_errors_to_exceptions(): void
3840
{
3941
$this->errorHandler->convertToExceptions();
4042

@@ -43,7 +45,7 @@ public function testShouldConvertErrorsToExceptions(): void
4345
$this->simulateError($this->errorHandler, E_ERROR);
4446
}
4547

46-
public function testShouldSendTheErrorToTheHandlerWhenOneIsRegistered(): void
48+
public function test_should_send_the_error_to_the_handler_when_one_is_registered(): void
4749
{
4850
$this->errorHandler->register($this->handler->init(...));
4951

@@ -60,7 +62,7 @@ public function testShouldSendTheErrorToTheHandlerWhenOneIsRegistered(): void
6062
$this->assertEquals(E_ERROR, History::get(0)->errorHandled->getLevel());
6163
}
6264

63-
public function testShouldUseErrorReportingLevelToHandleErrorsIfSet(): void
65+
public function test_should_use_error_reporting_level_to_handle_errors_if_set(): void
6466
{
6567
$handler = $this->errorHandler;
6668

Diff for: tests/ErrorHandler/RegisterTest.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<?php
22

33
/*
4-
* This file is part of https://github.com/josantonius/php-error-handler repository.
5-
*
6-
* (c) Josantonius <[email protected]>
7-
*
8-
* For the full copyright and license information, please view the LICENSE
9-
* file that was distributed with this source code.
10-
*/
4+
* This file is part of https://github.com/josantonius/php-error-handler repository.
5+
*
6+
* (c) Josantonius <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*
11+
* @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
12+
*/
1113

1214
namespace Josantonius\ErrorHandler\Tests\ErrorHandler;
1315

@@ -36,7 +38,7 @@ public function setUp(): void
3638
$this->errorLevels = $this->getPrivateProperty($this->errorHandler, 'errorLevels');
3739
}
3840

39-
public function testShouldRegisterCallbackToHandleErrors(): void
41+
public function test_should_register_callback_to_handle_errors(): void
4042
{
4143
$this->assertInstanceOf(
4244
ErrorHandler::class,
@@ -46,7 +48,7 @@ public function testShouldRegisterCallbackToHandleErrors(): void
4648
$this->assertInstanceOf(Closure::class, set_error_handler(null));
4749
}
4850

49-
public function testShouldRegisterCallbackAndSetExceptionsConversion(): void
51+
public function test_should_register_callback_and_set_exceptions_conversion(): void
5052
{
5153
$this->assertNull(set_error_handler(null));
5254

@@ -62,7 +64,7 @@ public function testShouldRegisterCallbackAndSetExceptionsConversion(): void
6264
$this->assertSame(array_keys($this->errorLevels), $exceptionable);
6365
}
6466

65-
public function testShouldRegisterCallbackAndSetExceptionsConversionExceptSome(): void
67+
public function test_should_register_callback_and_set_exceptions_conversion_except_some(): void
6668
{
6769
$this->assertNull(set_error_handler(null));
6870

0 commit comments

Comments
 (0)