-
Notifications
You must be signed in to change notification settings - Fork 59
[EUV2][GiangNV] Create UT for Ex3 -> Ex7 #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[EUV2][GiangNV] Create UT for Ex3 -> Ex7 #29
Conversation
use Modules\Exercise03\Repositories\ProductRepository; | ||
use Illuminate\Database\Eloquent\Collection; | ||
|
||
class ProductServiceTest extends TestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ở đâ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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Đ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 ạ
use InvalidArgumentException; | ||
use Modules\Exercise05\Services\OrderService; | ||
|
||
class OrderServiceTest extends TestCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
Purpose/Notes
Exercise03, Exercise04, Exercise05, Exercise06, Exercise07
Screenshot
Checklist (*)