From 26c52f1df6aba9b911c154b82cf24b06df26a348 Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Thu, 19 Sep 2019 14:43:29 +0200 Subject: [PATCH 1/2] Coding standards --- src/wccta/Car.php | 2 +- tests/wccta/CarTest.php | 4 ++-- tests/wccta/RegistryTest.php | 4 ---- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/wccta/Car.php b/src/wccta/Car.php index d0fb210..678f419 100644 --- a/src/wccta/Car.php +++ b/src/wccta/Car.php @@ -10,7 +10,7 @@ public function __construct( object $data ) { $this->data = $data; } - public function getPrice() { + public function get_price() { $price = $this->data->price ?? 0; return sprintf( '€ %s', number_format_i18n( $price ) ); diff --git a/tests/wccta/CarTest.php b/tests/wccta/CarTest.php index e9223e6..829f068 100644 --- a/tests/wccta/CarTest.php +++ b/tests/wccta/CarTest.php @@ -18,7 +18,7 @@ public function getData() { /** * @dataProvider getData */ - public function test_getPrice( $intPrice, $stringPrice, $expected ) { + public function test_get_price( $intPrice, $stringPrice, $expected ) { // Arrange Functions\expect( 'number_format_i18n' )->andReturn( $stringPrice ); @@ -26,7 +26,7 @@ public function test_getPrice( $intPrice, $stringPrice, $expected ) { $sut = new Car( $obj ); // Act - $actual = $sut->getPrice(); + $actual = $sut->get_price(); // Assert $this->assertEquals( $expected, $actual ); diff --git a/tests/wccta/RegistryTest.php b/tests/wccta/RegistryTest.php index c23ea7b..362331d 100644 --- a/tests/wccta/RegistryTest.php +++ b/tests/wccta/RegistryTest.php @@ -6,10 +6,6 @@ class RegistryTest extends WcctaTestCase { - public function get_sut() { - return new Registry(); - } - public function test_get() { $test = new Registry(); From 67087ecedd221d0406230f0c3a42cdbc4acc4415 Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Thu, 19 Sep 2019 15:13:39 +0200 Subject: [PATCH 2/2] Refactoring --- tests/wccta/CarTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/wccta/CarTest.php b/tests/wccta/CarTest.php index 829f068..16d7023 100644 --- a/tests/wccta/CarTest.php +++ b/tests/wccta/CarTest.php @@ -7,7 +7,7 @@ class CarTest extends WcctaTestCase { - public function getData() { + public function get_data() { return [ [ 14500, '14.500', '€ 14.500' ], [ 12345.67, '12345', '€ 12345' ], @@ -16,13 +16,13 @@ public function getData() { } /** - * @dataProvider getData + * @dataProvider get_data */ - public function test_get_price( $intPrice, $stringPrice, $expected ) { + public function test_get_price( $int_price, $string_price, $expected ) { // Arrange - Functions\expect( 'number_format_i18n' )->andReturn( $stringPrice ); + Functions\expect( 'number_format_i18n' )->andReturn( $string_price ); - $obj = (object) [ 'price' => $intPrice ]; + $obj = (object) [ 'price' => $int_price ]; $sut = new Car( $obj ); // Act