Skip to content

Commit 4ef88e4

Browse files
committed
Proper naming for removal of repository, fixed git data tree creation
1 parent d11a367 commit 4ef88e4

File tree

4 files changed

+21
-38
lines changed

4 files changed

+21
-38
lines changed

lib/Github/Api/AbstractApi.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,4 @@ protected function delete($path, array $parameters = array(), $requestOptions =
6666
{
6767
return $this->client->delete($path, $parameters, $requestOptions);
6868
}
69-
70-
/**
71-
* Translates array to object, for proper json data (forcing `[]` instead of `{}`)
72-
*
73-
* @param array $params
74-
*
75-
* @return object
76-
*/
77-
protected function translateArrayToObject(array $params)
78-
{
79-
$object = new \stdClass();
80-
foreach ($params as $key => $param) {
81-
$object->$key = $param;
82-
}
83-
84-
return $object;
85-
}
8669
}

lib/Github/Api/GitData/Trees.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ public function create($username, $repository, array $params)
3535
if (!isset($tree['sha']) && !isset($tree['content'])) {
3636
throw new MissingArgumentException("tree.$key.content");
3737
}
38-
39-
$params['tree'][$key] = $this->translateArrayToObject($tree);
4038
}
4139

4240
return $this->post('repos/'.urlencode($username).'/'.urlencode($repository).'/git/trees', $params);

lib/Github/Api/Repo.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ public function update($username, $repository, array $values)
9090
* Delete a repository
9191
* @link http://developer.github.com/v3/repos/
9292
*
93-
* @param string $username the user who owns the repository
94-
* @param string $repository the name of the repository
93+
* @param string $username the user who owns the repository
94+
* @param string $repository the name of the repository
9595
*
96-
* @return mixed null on success, arrray on error with 'message'
96+
* @return mixed null on success, array on error with 'message'
9797
*/
98-
public function delete($username, $repository)
98+
public function remove($username, $repository)
9999
{
100-
return parent::delete('repos/'.urlencode($username).'/'.urlencode($repository));
100+
return $this->delete('repos/'.urlencode($username).'/'.urlencode($repository));
101101
}
102102

103103
/**

test/Github/Tests/Api/RepoTest.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Github\Tests\Api;
44

55
/**
6-
* Repository api test case
6+
* Repository api test case
77
*
88
* @author Leszek Prabucki <[email protected]>
99
*/
@@ -50,16 +50,17 @@ public function shouldSearchRepositories()
5050
public function shouldPaginateFoundRepositories()
5151
{
5252
$expectedArray = array(
53-
array('id' => 1, 'name' => 'php'),
54-
array('id' => 2, 'name' => 'php-cs')
53+
array('id' => 3, 'name' => 'fork of php'),
54+
array('id' => 4, 'name' => 'fork of php-cs')
5555
);
5656

5757
$api = $this->getApiMock();
5858
$api->expects($this->once())
5959
->method('get')
60-
->with('legacy/repos/search/php', array('start_page' => 2));
60+
->with('legacy/repos/search/php', array('start_page' => 2))
61+
->will($this->returnValue($expectedArray));
6162

62-
$api->find('php', array('start_page' => 2));
63+
$this->assertEquals($expectedArray, $api->find('php', array('start_page' => 2)));
6364
}
6465

6566
/**
@@ -269,36 +270,37 @@ public function shouldUpdate()
269270

270271
$this->assertEquals($expectedArray, $api->update('l3l0Repo', 'test', array('description' => 'test', 'homepage' => 'http://l3l0.eu')));
271272
}
272-
273-
/**
273+
274+
/**
274275
* @test
275276
*/
276277
public function shouldDelete()
277278
{
278279
$api = $this->getApiMock();
279280
$api->expects($this->once())
280281
->method('delete')
281-
->with('l3l0Repo', 'test')
282+
->with('repos/l3l0Repo/test')
282283
->will($this->returnValue(null));
283284

284-
$this->assertNull($api->delete('l3l0Repo', 'test'));
285+
$this->assertNull($api->remove('l3l0Repo', 'test'));
285286
}
286287

287-
/**
288+
/**
288289
* @test
289290
*/
290291
public function shouldNotDelete()
291292
{
292-
$expectedArray = array('message'=>'Not Found');
293+
$expectedArray = array('message' => 'Not Found');
293294

294295
$api = $this->getApiMock();
295296
$api->expects($this->once())
296297
->method('delete')
297-
->with('l3l0Repo', 'uknown-repo')
298-
->will($this->returnValue(array('message'=>'Not Found')));
298+
->with('repos/l3l0Repo/uknown-repo')
299+
->will($this->returnValue($expectedArray));
299300

300-
$this->assertEquals($expectedArray, $api->delete('l3l0Repo', 'uknown-repo'));
301+
$this->assertEquals($expectedArray, $api->remove('l3l0Repo', 'uknown-repo'));
301302
}
303+
302304
/**
303305
* @test
304306
*/

0 commit comments

Comments
 (0)