/** * Tests if the class have been generated correctly */ public function testClassIsGeneratedCorrectly() { $apigee = new ApiGeenerator('reddit', 'RedditAwesomeApi'); $endpoints = $apigee->getEndpoints(); $path = $apigee->generateClassForEndpoint($endpoints[0])->write(sys_get_temp_dir(), true); //File is created $this->assertTrue(file_exists($path)); //Test that an string can be returned $this->assertTrue(is_string($apigee->toString())); //Test that the generated file is correct $commandReturnValue = null; $output = array(); //Test syntax errors, may be moved to another method exec('php -l ' . $path, $output, $commandReturnValue); $this->assertEquals($commandReturnValue, 0); }
<?php require __DIR__ . '/../vendor/autoload.php'; use Jnonon\Tools\ApiGeenerator\Client\ApiGeenerator; $apigee = new ApiGeenerator('reddit', 'RedditApi'); $endpoints = $apigee->getEndpoints(); //Write to a path, overriding if exists //$apigee->generateClassForEndpoint($endpoints[0])->write('/desirable/path', true); echo $apigee->generateClassForEndpoint($endpoints[0])->toString();