1414
1515/**
1616 * Class ApibFileParserTest
17- * @covers PHPDraft\In\ApibFileParser
17+ * @covers \ PHPDraft\In\ApibFileParser
1818 */
1919class ApibFileParserTest extends BaseTest
2020{
@@ -33,11 +33,49 @@ public function setUp()
3333 * Test if setup is successful
3434 * @return void
3535 */
36- public function testSetup ()
36+ public function testLocationSetup ()
3737 {
3838 $ property = $ this ->reflection ->getProperty ('location ' );
39- $ property ->setAccessible (TRUE );
39+ $ property ->setAccessible (true );
4040 $ this ->assertSame (__DIR__ . '/ ' , $ property ->getValue ($ this ->class ));
4141 }
4242
43+ /**
44+ * Test if setup is successful
45+ * @return void
46+ */
47+ public function testFilenameSetup ()
48+ {
49+ $ property = $ this ->reflection ->getProperty ('filename ' );
50+ $ property ->setAccessible (true );
51+ $ this ->assertSame (__DIR__ . '/ApibFileParserTest.php ' , $ property ->getValue ($ this ->class ));
52+ }
53+
54+ /**
55+ * Test if setup is successful
56+ * @return void
57+ */
58+ public function testParseBasic ()
59+ {
60+ $ property = $ this ->reflection ->getProperty ('filename ' );
61+ $ property ->setAccessible (true );
62+ $ property ->setValue ($ this ->class , TEST_STATICS . '/drafter/including_apib ' );
63+ $ loc_property = $ this ->reflection ->getProperty ('location ' );
64+ $ loc_property ->setAccessible (true );
65+ $ loc_property ->setValue ($ this ->class , TEST_STATICS . '/drafter/ ' );
66+
67+ $ this ->mock_function ('curl_exec ' , 'hello ' );
68+ $ this ->class ->parse ();
69+ $ this ->unmock_function ('curl_exec ' );
70+
71+ $ full_property = $ this ->reflection ->getProperty ('full_apib ' );
72+ $ full_property ->setAccessible (true );
73+
74+ $ text = "FORMAT: 1A \nHOST: https://owner-api.teslamotors.com \nEXTRA_HOSTS: https://test.owner-api.teslamotors.com \nSOMETHING: INFO \n\n" ;
75+ $ text .="# Tesla Model S JSON API \nThis is unofficial documentation of the Tesla Model S JSON API used by the iOS and Android apps. It features functionality to monitor and control the Model S remotely. \n\nTEST \nhello " ;
76+
77+ $ this ->assertSame ($ text , $ full_property ->getValue ($ this ->class ));
78+ $ this ->assertSame ($ text , $ this ->class ->__toString ());
79+ }
80+
4381}
0 commit comments