Skip to content

Commit

Permalink
Merge pull request #30 from harikt/patch-issue-28
Browse files Browse the repository at this point in the history
Patch issue 28
  • Loading branch information
harikt authored Jan 16, 2018
2 parents a00a2bf + d5d4432 commit e3b4ae3
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
filter:
paths: ["src/*"]
tools:
external_code_coverage: true
php_code_coverage: true
php_sim: true
php_mess_detector: true
php_pdepend: true
php_analyzer: true
php_cpd: true
43 changes: 39 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
language: php
php:
- 5.4
- 5.5

matrix:
include:
- os: linux
dist: precise
sudo: false
php: 5.4
- os: linux
dist: precise
sudo: false
php: 5.5
- os: linux
dist: precise
sudo: false
php: 5.6
- os: linux
dist: trusty
sudo: false
php: 7
- os: linux
dist: trusty
sudo: false
php: 7.1
- os: linux
dist: trusty
sudo: false
php: 7.2
env:
- TEST_COVERAGE=true
- os: linux
dist: trusty
php: nightly

before_script:
- composer self-update
- composer install
- cd tests
script: phpunit
script:
- if [[ $TEST_COVERAGE == 'true' ]]; then ../vendor/bin/phpunit --coverage-clover=coverage.clover ; else ../vendor/bin/phpunit ; fi
after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then wget https://scrutinizer-ci.com/ocular.phar; php ocular.phar code-coverage:upload --format=php-clover coverage.clover ; fi
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
"php": ">=5.4.0",
"aura/installer-default": "1.0.0"
},
"require-dev": {
"phpunit/phpunit": "~5.7 || ~4.8"
},
"autoload": {
"psr-0": {
"Aura\\Uri": "src/"
Expand Down
16 changes: 16 additions & 0 deletions src/Aura/Uri/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
*/
class Query extends \ArrayObject
{

/**
*
* ArrayObject constructor used to setFlags
* @see https://github.com/auraphp/Aura.Uri/issues/28
*
* @param mixed $input
* @param int $flags
* @param string $iterator_class
*/
public function __construct($input = [], $flags = 0, $iterator_class = "ArrayIterator")
{
parent::__construct($input, $flags, $iterator_class);
$this->setFlags(\ArrayObject::ARRAY_AS_PROPS);
}

/**
*
* Returns the query portion as a string.
Expand Down
1 change: 1 addition & 0 deletions src/Aura/Uri/Url/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Aura\Uri\Query;
use Aura\Uri\Host;
use Aura\Uri\PublicSuffixList;
use ArrayObject;

/**
*
Expand Down
20 changes: 20 additions & 0 deletions tests/Aura/Uri/QueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,24 @@ public function test_deepArrays()
$actual = $this->query->__toString();
$this->assertEquals($expect, $actual);
}

public function testSetQueryString()
{
$query_string = 'foo=bar&baz=dib';
$this->query->setFromString($query_string);
$this->query->offsetSet('foo', 'another');
$this->query->offsetUnset('baz');
$this->query->page = 1;
$this->query['limit'] = 50;
$actual = $this->query->getArrayCopy();
$expected = [
'foo' => 'another',
'page' => 1,
'limit' => 50,
];
$this->assertEquals($actual, $expected);
$expect = 'foo=another&page=1&limit=50';
$actual = $this->query->__toString();
$this->assertEquals($expect, $actual);
}
}

0 comments on commit e3b4ae3

Please sign in to comment.