public function testParsingJsonEndpoint() { $parser = new MentoringParser(array('')); $entries = $parser->parse(__DIR__ . '/__files/mentors.json'); $expected = array('name' => 'Tristan Bailey', 'github' => '', 'lat' => 0, 'lon' => 0, 'description' => '<p>I have been developing websites for 13+ years and worked though companies to Senior Dev. Middle/Backend developer and full stack team lead (PHP, MySQL, [Laravel, Slim, Joomla, EE, WP, Magento], DevOps, Agile). Moved to Freelance Developer about 4 years ago, and work with agencies and clients, on medium to large travel and eCommerce sites. When writing fresh projects I use Laravel or SlimPHP but often work on existing systems and integrations.' . "\n" . 'Happy to mentor others about php, full stack development, working with teams, coding, freelance work, DevOps, analytics, strategy etc</p>', 'type' => 'mentor', 'tags' => array('mentor' => ['PHP', 'full-stack', 'freelancing', 'behat', 'mysql', 'legacy', 'analytics'], 'apprentice' => ['']), 'thumbnail' => 'https://avatars0.githubusercontent.com/u/200137', 'id' => 6, 'githubUid' => '200137'); $this->assertEquals($expected, $entries[0]); }
/** * Parse the results of the new mentoring-app * * This method os the endpoint of the console-action * * @return void */ public function getmentoringAction() { echo sprintf('Generating mentoringapp.json-File' . "\n"); $config = $this->getServiceLocator()->get('config'); $mentoring = new Mentoringapp($config['php.ug.mentoringapp']); $infos = array(); $infos = array_merge($infos, $mentoring->parse('http://app.phpmentoring.org/api/v0/mentors')); $infos = array_merge($infos, $mentoring->parse('http://app.phpmentoring.org/api/v0/apprentices')); //$infos = $mentoring->parse('https://github.com/phpmentoring/phpmentoring.github.com/wiki/Mentors-and-Apprentices'); $file = $config['php.ug.mentoringapp']['file']; $fh = fopen($file, 'w+'); fwrite($fh, json_encode($infos)); fclose($fh); echo sprintf('File "%s" has been stored' . "\n", $file); }