コード例 #1
0
 public function test_should_not_update_post_if_unchanged()
 {
     $sha = '1234567890qwertyuiop';
     $this->blob->shouldReceive('sha')->andReturn($sha);
     $post_id = $this->factory->post->create();
     $post = new WordPress_GitHub_Sync_Post($post_id, $this->api);
     $this->blob->shouldReceive('path')->andReturn($post->github_path());
     $this->blob->shouldReceive('content_import')->andReturn($post->github_content());
     $tree = new WordPress_GitHub_Sync_Tree(new stdClass());
     $tree->add_blob($this->blob);
     $tree->add_post_to_tree($post);
     $this->assertCount(1, $blobs = $tree->blobs());
     $this->assertSame($this->blob, $blobs[0]);
     $this->assertFalse($tree->is_changed());
     $this->blob->shouldReceive('to_body')->andReturn(new stdClass());
     $body = $tree->to_body();
     $this->assertArrayHasKey('tree', $body);
     $this->assertCount(1, $body['tree']);
 }
コード例 #2
0
 public function test_should_build_github_content()
 {
     $post = new WordPress_GitHub_Sync_Post($this->id, $this->api);
     $this->assertStringStartsWith('---', $post->github_content());
     $this->assertStringEndsWith($this->post->post_content, $post->github_content());
 }
コード例 #3
0
ファイル: tree.php プロジェクト: rexcode/rexappz-wordpress
 /**
  * Creates a blob with the data required for the tree.
  *
  * @param WordPress_GitHub_Sync_Post $post
  *
  * @return stdClass
  */
 public function blob_from_post($post)
 {
     $blob = new stdClass();
     $blob->path = $post->github_path();
     $blob->mode = '100644';
     $blob->type = 'blob';
     $blob->content = $post->github_content();
     return $blob;
 }