[EUV2][GiangNV] Create UT for Ex3 -> Ex7#29
Open
giangnv-0040 wants to merge 1 commit intosun-unit-test-training:masterfrom
Open
[EUV2][GiangNV] Create UT for Ex3 -> Ex7#29giangnv-0040 wants to merge 1 commit intosun-unit-test-training:masterfrom
giangnv-0040 wants to merge 1 commit intosun-unit-test-training:masterfrom
Conversation
namttdh
reviewed
May 30, 2021
| use Modules\Exercise03\Repositories\ProductRepository; | ||
| use Illuminate\Database\Eloquent\Collection; | ||
|
|
||
| class ProductServiceTest extends TestCase |
There was a problem hiding this comment.
Ở đây thiếu miss mất 1 case.
Giả sử các trường hợp dưới đây không tồn tại thì ra sao?
$totalProducts[Product::CRAVAT_TYPE]
$totalProducts[Product::OTHER_TYPE]
$totalProducts[Product::WHITE_SHIRT_TYPE]
Ngoài thì cũng nên để ý các trương logic so sánh >= hiện tại chỉ đang test các trường hợp > nhưng đối với các trường hợp = thì đang không test
namttdh
reviewed
May 30, 2021
Comment on lines
+25
to
+58
| function test_index() | ||
| { | ||
| $calendars = []; | ||
| $j = 0; | ||
| $holidays = ['2020-09-26']; | ||
|
|
||
| $url = action([Exercise::class, 'index']); | ||
| $dummyClass = 'class'; | ||
|
|
||
| for ($i = 1; $i <= 30; $i++) { | ||
| $date = \Carbon\Carbon::createFromDate(2020, 9, $i); | ||
|
|
||
| $this->serviceMock | ||
| ->shouldReceive('getDateClass') | ||
| ->andReturn($dummyClass); | ||
|
|
||
| $calendars[$j][] = [ | ||
| 'label' => $i, | ||
| 'date' => $date, | ||
| 'class' => $dummyClass, | ||
| ]; | ||
|
|
||
| if ($i % 7 == 0) { | ||
| $j++; | ||
| } | ||
| } | ||
|
|
||
| $response = $this->get($url); | ||
|
|
||
| $response->assertViewIs('exercise04::calendar'); | ||
| $response->assertViewHasAll([ | ||
| 'calendars', | ||
| ]); | ||
| } |
There was a problem hiding this comment.
Đoạn này viết đơn giản thui ạ, không cần phải logic phức tạp như này đâu.
Anh chỉ cần assert data của calendars là đc, không cần phải viết logic để tạo ra cái data đấy ạ
namttdh
reviewed
May 30, 2021
| use InvalidArgumentException; | ||
| use Modules\Exercise05\Services\OrderService; | ||
|
|
||
| class OrderServiceTest extends TestCase |
There was a problem hiding this comment.
Các case logic >= thì hiện tại anh chỉ viết test cho các logic > còn các logic = thì hiện tại chưa thấy test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose/Notes
Exercise03, Exercise04, Exercise05, Exercise06, Exercise07Screenshot
Checklist (*)