/** * @param Application $app An Application instance */ public function register(Application $app) { $app['article_provider'] = $app->share(function ($app) { return new GithubArticleProvider(); }); $app['article_service'] = $app->share(function ($app) { $githubService = new \MMB\Github\GithubArticleService($app['config']['parameters']['github_user'], $app['config']['parameters']['github_repository'], $app['config']['parameters']['github_reference']); $githubService->setAuthUserToken($app['config']['parameters']['github_auth_user_token']); $githubService->setAuthMethod($app['config']['parameters']['github_auth_method']); if (!empty($app['config']['parameters']['github_auth_password'])) { $githubService->setAuthPassword($app['config']['parameters']['github_auth_password']); } $githubService->setArticleProvider($app['article_provider']); $githubService->setDocumentProvider($app['document_provider']); return $githubService; }); }
public function testObtainArticleMeta() { $github = new \MMB\Github\GithubArticleService(); $github->setArticleProvider(new MockArticleProvider()); $github->setDocumentProvider(new MockDocumentProvider()); $github->setRepository('mmb-github-example'); $github->setUser('cammanderson'); $result = $github->getArticle('2014-08-12_Hello-world.md'); $this->assertNotEmpty($result->getPublished()); $this->assertTrue(date('Y-m-d', $result->getPublished()->getTimestamp()) == date('Y-m-d', strtotime('2014-08-12'))); $this->assertNotEmpty($result->getAuthor()); $this->assertNotEmpty($result->getCurrentVersionId()); $this->assertNotEmpty($result->getCreated()); $this->assertNotEmpty($result->getUpdated()); $this->assertNotEmpty($result->getContributors()); }