Permalink
Browse files

單元測試 : 黑貓、新竹、郵局測試案例

  • Loading branch information...
1 parent a9c46e5 commit 7aa22622f57b13eb58cf659c2e7f89910c6c1461 Sam.IO.Hsiao committed Nov 27, 2016
Showing with 54 additions and 0 deletions.
  1. +54 −0 tests/ShippingServiceTest.php
@@ -0,0 +1,54 @@
+<?php
+
+use App\Services\ShippingService;
+
+class ShippingServiceTest extends TestCase
+{
+ /** @test */
+ public function 黑貓_當重量為1_2_3_費用為360()
+ {
+ /** arrange */
+ /** @var ShippingService $target */
+ $target = App::make(ShippingService::class);
+
+ /** act */
+ $weights = [1, 2, 3];
+ $actual = $target->calculateFee($weights, 'BlackCat');
+
+ /** assert */
+ $expected = 360;
+ $this->assertEquals($expected, $actual);
+ }
+
+ /** @test */
+ public function 新竹_當重量為1_2_3_費用為330()
+ {
+ /** arrange */
+ /** @var ShippingService $target */
+ $target = App::make(ShippingService::class);
+
+ /** act */
+ $weights = [1, 2, 3];
+ $actual = $target->calculateFee($weights, 'Hsinchu');
+
+ /** assert */
+ $expected = 330;
+ $this->assertEquals($expected, $actual);
+ }
+
+ /** @test */
+ public function 郵局_當重量為1_2_3_費用為300()
+ {
+ /** arrange */
+ /** @var ShippingService $target */
+ $target = App::make(ShippingService::class);
+
+ /** act */
+ $weights = [1, 2, 3];
+ $actual = $target->calculateFee($weights, 'PostOffice');
+
+ /** assert */
+ $expected = 300;
+ $this->assertEquals($expected, $actual);
+ }
+}

0 comments on commit 7aa2262

Please sign in to comment.