Skip to content

Commit 897fa87

Browse files
committed
Merge remote-tracking branch 'joomla/master' into 2.0-dev
# Conflicts: # .drone.jsonnet # .drone.yml # .gitignore # README.md # Tests/GithubObjectTest.php # src/AbstractGithubObject.php
2 parents 5d766c6 + efed7df commit 897fa87

5 files changed

Lines changed: 49 additions & 12 deletions

File tree

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github: joomla
2+
custom: https://community.joomla.org/sponsorship-campaigns.html

Tests/GithubObjectTest.php

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,33 @@ protected function setUp(): void
4747
public function fetchUrlData()
4848
{
4949
return array(
50-
'Standard github - no pagination data' => array('https://api.github.com', '/gists', 0, 0, 'https://api.github.com/gists'),
51-
'Enterprise github - no pagination data' => array('https://mygithub.com', '/gists', 0, 0, 'https://mygithub.com/gists'),
52-
'Standard github - page 3' => array('https://api.github.com', '/gists', 3, 0, 'https://api.github.com/gists?page=3'),
50+
'Standard github - no pagination data' => array(
51+
'https://api.github.com',
52+
'/gists',
53+
0,
54+
0,
55+
'https://api.github.com/gists'
56+
),
57+
'Enterprise github - no pagination data' => array(
58+
'https://mygithub.com',
59+
'/gists',
60+
0,
61+
0,
62+
'https://mygithub.com/gists'
63+
),
64+
'Standard github - page 3' => array(
65+
'https://api.github.com',
66+
'/gists',
67+
3,
68+
0,
69+
'https://api.github.com/gists?page=3'
70+
),
5371
'Enterprise github - page 3, 50 per page' => array(
54-
'https://mygithub.com', '/gists', 3, 50, 'https://mygithub.com/gists?page=3&per_page=50'
72+
'https://mygithub.com',
73+
'/gists',
74+
3,
75+
50,
76+
'https://mygithub.com/gists?page=3&per_page=50'
5577
),
5678
);
5779
}
@@ -96,7 +118,8 @@ public function testFetchUrlBasicAuth()
96118

97119
$this->assertThat(
98120
$this->object->fetchUrl('/gists', 0, 0),
99-
$this->equalTo('https://MyTestUser:MyTestPass@api.github.com/gists')
121+
$this->equalTo('https://MyTestUser:MyTestPass@api.github.com/gists'),
122+
'URL is not as expected.'
100123
);
101124
}
102125

@@ -113,7 +136,14 @@ public function testFetchUrlToken()
113136

114137
$this->assertThat(
115138
$this->object->fetchUrl('/gists', 0, 0),
116-
$this->equalTo('https://api.github.com/gists?access_token=MyTestToken')
139+
$this->equalTo('https://api.github.com/gists'),
140+
'URL is not as expected.'
141+
);
142+
143+
$this->assertThat(
144+
$this->client->getOption('headers'),
145+
$this->equalTo(['Authorization' => 'token MyTestToken']),
146+
'Token should be propagated as a header.'
117147
);
118148
}
119149
}

Tests/bootstrap.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
require_once 'vendor/autoload.php';
3+
4+
// Turn off E_DEPRECATED caused by outdated PHPUnit
5+
$errorReporting = error_reporting();
6+
error_reporting($errorReporting & ~E_DEPRECATED);

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="vendor/autoload.php" colors="false">
2+
<phpunit bootstrap="Tests/bootstrap.php" colors="false">
33
<testsuites>
44
<testsuite name="Unit">
55
<directory>Tests</directory>

src/AbstractGithubObject.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
namespace Joomla\Github;
1010

1111
use Joomla\Http\Exception\UnexpectedResponseException;
12-
use Joomla\Http\Http;
13-
use Joomla\Http\HttpFactory;
12+
use Joomla\Http\Http as BaseHttp;
1413
use Joomla\Http\Response;
1514
use Joomla\Registry\Registry;
1615
use Joomla\Uri\Uri;
@@ -33,7 +32,7 @@ abstract class AbstractGithubObject
3332
/**
3433
* The HTTP client object to use in sending HTTP requests.
3534
*
36-
* @var Http
35+
* @var BaseHttp
3736
* @since 1.0
3837
*/
3938
protected $client;
@@ -83,11 +82,11 @@ abstract class AbstractGithubObject
8382
* Constructor.
8483
*
8584
* @param Registry $options GitHub options object.
86-
* @param Http $client The HTTP client object.
85+
* @param BaseHttp $client The HTTP client object.
8786
*
8887
* @since 1.0
8988
*/
90-
public function __construct(Registry $options = null, Http $client = null)
89+
public function __construct(Registry $options = null, BaseHttp $client = null)
9190
{
9291
$this->options = $options ?: new Registry;
9392
$this->client = $client ?: (new HttpFactory)->getHttp($this->options);

0 commit comments

Comments
 (0)