11<?php
22
3+ use PHPUnit \Framework \TestCase ;
34use Wastukancana \Nim ;
45use Wastukancana \Student ;
5- use PHPUnit \Framework \TestCase ;
66
77final class NimParserTest extends TestCase
88{
99 const NIM_TEST = '211351143 ' ;
10+
1011 const EXPECTED_NAME = 'SULUH SULISTIAWAN ' ;
12+
1113 const EXPECTED_GENDER = 'M ' ;
14+
1215 const EXPECTED_GRADUATION = false ;
16+
1317 const EXPECTED_YEAR = 2021 ;
18+
1419 const EXPECTED_STUDY = 'Teknik Informatika ' ;
20+
1521 const EXPECTED_LEVEL = 'S1 ' ;
22+
1623 const EXPECTED_SEMESTER = 1 ;
24+
1725 const EXPECTED_SEQUENCE = 143 ;
1826
1927 private Nim $ nim ;
@@ -23,17 +31,17 @@ protected function setUp(): void
2331 $ this ->nim = new Nim (self ::NIM_TEST );
2432 }
2533
26- public function testIsValidAdmissionYear ()
34+ public function test_is_valid_admission_year ()
2735 {
2836 $ this ->assertTrue ($ this ->nim ->isValidAdmissionYear ());
2937 }
3038
31- public function testIsValidStudy ()
39+ public function test_is_valid_study ()
3240 {
3341 $ this ->assertTrue ($ this ->nim ->isValidStudy ());
3442 }
3543
36- public function testCanDump ()
44+ public function test_can_dump ()
3745 {
3846 $ dump = $ this ->nim ->dump ();
3947
@@ -51,72 +59,78 @@ public function testCanDump()
5159 $ this ->assertEquals ($ student , $ dump );
5260 }
5361
54- public function testCanGetNim ()
62+ public function test_can_get_nim ()
5563 {
5664 $ this ->assertEquals (self ::NIM_TEST , $ this ->nim ->getNIM ());
5765 }
5866
59- public function testCanGetName ()
67+ public function test_can_get_name ()
6068 {
6169 $ this ->assertEquals (self ::EXPECTED_NAME , $ this ->nim ->getName ());
6270 }
6371
64- public function testCanGetGender ()
72+ public function test_can_get_gender ()
6573 {
6674 $ this ->assertEquals (self ::EXPECTED_GENDER , $ this ->nim ->getGender ());
6775 }
6876
69- public function testCanGetIsGraduated ()
77+ public function test_can_get_is_graduated ()
7078 {
7179 $ this ->assertEquals (self ::EXPECTED_GRADUATION , $ this ->nim ->getIsGraduated ());
7280 }
7381
74- public function testCanGetFirstSemester ()
82+ public function test_can_get_first_semester ()
7583 {
7684 $ this ->assertEquals (self ::EXPECTED_SEMESTER , $ this ->nim ->getFirstSemester ());
7785 }
7886
79- public function testCanGetSequenceNumber ()
87+ public function test_can_get_sequence_number ()
8088 {
8189 $ this ->assertEquals (self ::EXPECTED_SEQUENCE , $ this ->nim ->getSequenceNumber ());
8290 }
8391
84- public function testCanGetAdmissionYear ()
92+ public function test_can_get_admission_year ()
8593 {
8694 $ this ->assertEquals (self ::EXPECTED_YEAR , $ this ->nim ->getAdmissionYear ());
8795 }
8896
89- public function testCanGetStudy ()
97+ public function test_can_get_study ()
9098 {
9199 $ this ->assertEquals (self ::EXPECTED_STUDY , $ this ->nim ->getStudy ());
92100 }
93101
94- public function testCanGetEducationLevel ()
102+ public function test_can_get_education_level ()
95103 {
96104 $ this ->assertEquals (self ::EXPECTED_LEVEL , $ this ->nim ->getEducationLevel ());
97105 }
98106
99- public function testNimWithInvalidLengthThrowsException ()
107+ public function test_nim_with_too_short_length_throws_exception ()
100108 {
101- $ this ->expectException (\ InvalidArgumentException::class);
109+ $ this ->expectException (InvalidArgumentException::class);
102110 new Nim ('1 ' );
103111 }
104112
105- public function testNimWithNonNumericCharactersThrowsException ()
113+ public function test_nim_with_too_long_length_throws_exception ()
114+ {
115+ $ this ->expectException (InvalidArgumentException::class);
116+ new Nim ('21135114300 ' );
117+ }
118+
119+ public function test_nim_with_non_numeric_characters_throws_exception ()
106120 {
107- $ this ->expectException (\ InvalidArgumentException::class);
121+ $ this ->expectException (InvalidArgumentException::class);
108122 new Nim ('2113511a3 ' );
109123 }
110124
111- public function testInvalidAdmissionYearThrowsException ()
125+ public function test_invalid_admission_year_throws_exception ()
112126 {
113- $ this ->expectException (\ InvalidArgumentException::class);
127+ $ this ->expectException (InvalidArgumentException::class);
114128 new Nim ('991351143 ' );
115129 }
116130
117- public function testNonExistentStudyThrowsException ()
131+ public function test_non_existent_study_throws_exception ()
118132 {
119- $ this ->expectException (\ InvalidArgumentException::class);
133+ $ this ->expectException (InvalidArgumentException::class);
120134 new Nim ('210001143 ' );
121135 }
122136}
0 commit comments