Ejemplo n.º 1
0
 public function testGetListOfCountedTags()
 {
     $gist1 = new Gist();
     $gist1->setDescriptionAndTags('description #BBB_tag #ddd_tag #aaa10_tag');
     $gist1->setPublic(false);
     $gist1->setOwner(['id' => 0]);
     $gist1->setStarred(false);
     $gist2 = new Gist();
     $gist2->setDescriptionAndTags('description #BBB_tag #ddd_tag #aaa2_tag');
     $gist2->setPublic(false);
     $gist2->setOwner(['id' => 0]);
     $gist2->setStarred(false);
     $gist3 = new Gist();
     $gist3->setDescriptionAndTags('description #aaa1_tag #ccc_tag');
     $gist3->setPublic(false);
     $gist3->setOwner(['id' => 0]);
     $gist3->setStarred(true);
     $gist4 = new Gist();
     $gist4->setDescriptionAndTags('description');
     $gist4->setPublic(true);
     $gist4->setOwner(['id' => 1]);
     $gist4->setStarred(true);
     $gist5 = new Gist();
     $gist5->setDescriptionAndTags('description');
     $gist5->setPublic(true);
     $gist5->setOwner(['id' => null]);
     $gist5->setStarred(true);
     $gists = [$gist1, $gist2, $gist3, $gist4, $gist5];
     $gistCounter = new GistCounter($gists, 0);
     $this->assertEquals(2, $gistCounter->getPublic());
     $this->assertEquals(3, $gistCounter->getPrivate());
     $this->assertEquals(2, $gistCounter->getWithoutTag());
     $this->assertEquals(5, $gistCounter->getAll());
     $this->assertEquals(3, $gistCounter->getOwned());
     $this->assertEquals(3, $gistCounter->getStarred());
     $this->assertEquals([0 => ['name' => '#aaa1_tag', 'count' => 1], 1 => ['name' => '#aaa2_tag', 'count' => 1], 2 => ['name' => '#aaa10_tag', 'count' => 1], 3 => ['name' => '#BBB_tag', 'count' => 2], 4 => ['name' => '#ccc_tag', 'count' => 1], 5 => ['name' => '#ddd_tag', 'count' => 2]], $gistCounter->getTags());
 }
Ejemplo n.º 2
0
 public function testBackup()
 {
     $this->githubApiMock->shouldReceive('getGistFileContents')->twice()->andReturn('test');
     $user = new User();
     $user->setId(1);
     $user->setLogin('test');
     $userFolderPath = storage_path() . '/backups/' . $user->getId();
     $gist1 = new Gist();
     $gist1->setUpdatedAt('2014-06-12 12:30:15');
     $gist1->setFiles(['test.md' => ['filename' => 'test.md', 'size' => 1000, 'raw_url' => 'https://gist.githubusercontent.com/raw/365370/7f2ac0ff512853564e/ring.erl']]);
     $gist2 = new Gist();
     $gist2->setUpdatedAt('2000-06-12 12:30:15');
     $gist2->setFiles(['test.md' => ['filename' => 'test.md', 'size' => 1000, 'raw_url' => 'https://gist.githubusercontent.com/raw/365370/7f2ac0ff512853564e/ring.erl']]);
     $gists = [$gist1, $gist2];
     $gistBackupHandler = new GistBackupHandler($this->githubApiMock, $user, $gists);
     $zipPath = $gistBackupHandler->backup();
     $this->assertFileExists($zipPath);
     $this->assertFileNotExists($userFolderPath . '/files/20140612123015-test.md');
     $this->assertFileNotExists($userFolderPath . '/files/20000613123015-test.md');
     unlink($zipPath);
     rmdir($userFolderPath . '/files');
     rmdir($userFolderPath . '/zip');
     rmdir($userFolderPath);
 }
Ejemplo n.º 3
0
 function applyGist($matches)
 {
     $url = "{$matches['1']}.js";
     $gist = new Gist($url);
     return $gist->code();
 }
Ejemplo n.º 4
0
<?php

namespace li3_github\models;

class Gist extends \lithium\data\Model
{
    protected $_meta = array('connection' => 'github', 'source' => 'gist');
}
Gist::finder('comments', function ($self, $params, $chain) {
    $params['options']['conditions']['type'] = 'comments';
    $data = $chain->next($self, $params, $chain);
    return $data;
});