1010
1111class CustomFieldsTest extends TestCase
1212{
13- public function testGetFields ()
13+ /**
14+ * @test
15+ * @return array
16+ */
17+ public function get_all_custom_fields () : array
1418 {
1519 try {
1620 $ fieldService = new FieldService ();
1721
1822 $ ret = $ fieldService ->getAllFields (Field::CUSTOM );
19- Dumper::dump ($ ret );
2023
21- file_put_contents ("custom-field.json " , json_encode ($ ret , JSON_UNESCAPED_UNICODE |JSON_PRETTY_PRINT ));
24+ // file_put_contents("custom-field.json", json_encode($ret, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));
2225
2326 $ ids = array_map (function ($ cf ) {
2427 // extract custom field id
2528 preg_match ('/\d+/ ' , $ cf ->id , $ matches );
2629 return $ matches [0 ];
2730 }, $ ret );
2831
29- return $ ids ;
32+ $ this ->assertNotNull ($ ids );
33+ $ this ->assertIsArray ($ ids );
3034
35+ return $ ids ;
3136 } catch (JiraException $ e ) {
32- $ this ->assertTrue ( false , ' testSearch Failed : ' .$ e ->getMessage ());
37+ $ this ->fail ( ' get_all_custom_fields Failed : ' .$ e ->getMessage ());
3338 }
3439 }
3540
3641 /**
37- * @depends testGetFields
42+ * @test
43+ * @depends get_all_custom_fields
3844 *
39- * @param $ids
45+ * @param array $ids
4046 */
41- public function testGetFieldOptions ( $ ids )
47+ public function get_customer_field_options ( array $ ids ) : void
4248 {
4349 try {
4450 $ fieldService = new FieldService ();
4551
4652 foreach ($ ids as $ id ) {
4753 try {
4854 $ ret = $ fieldService ->getCustomFieldOption ($ id );
49- Dumper::dump ($ ret );
55+
56+ $ this ->assertNotNull ($ ret ->self );
5057 }catch (JiraException $ e ) {}
5158 }
5259 } catch (JiraException $ e ) {
53- $ this ->assertTrue ( false , ' testGetFieldOptions Failed : ' .$ e ->getMessage ());
60+ $ this ->fail ( ' get_customer_field_options Failed : ' .$ e ->getMessage ());
5461 }
5562 }
5663
57- public function testCreateFields ()
64+ /**
65+ * @test
66+ * @depends get_customer_field_options
67+ * @return string
68+ * @throws \JsonMapper_Exception
69+ */
70+ public function create_customer_field () : string
5871 {
5972 //$this->markTestSkipped();
6073 try {
@@ -69,9 +82,29 @@ public function testCreateFields()
6982 $ fieldService = new FieldService ();
7083
7184 $ ret = $ fieldService ->create ($ field );
72- Dumper::dump ($ ret );
85+
86+ return $ ret ->id ;
87+ } catch (JiraException $ e ) {
88+ $ this ->fail ('create_customer_field Failed : ' .$ e ->getMessage ());
89+ }
90+ }
91+
92+ /**
93+ * @test
94+ * @depends create_customer_field
95+ * @param string $id
96+ * @return \stdClass
97+ */
98+ public function get_created_customer_field_options (string $ id ) :\stdClass
99+ {
100+ try {
101+ $ fieldService = new FieldService ();
102+
103+ $ ret = $ fieldService ->getCustomFieldOption ($ id );
104+
105+ return $ ret ;
73106 } catch (JiraException $ e ) {
74- $ this ->assertTrue ( false , ' Field Create Failed : ' .$ e ->getMessage ());
107+ $ this ->fail ( ' get_created_customer_field_options Failed : ' .$ e ->getMessage ());
75108 }
76109 }
77110}
0 commit comments