Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
dist: trusty
language: php

php:
- 7.1
- 7.2

install:
- composer install --prefer-dist
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about moving this to composer.json via

$ composer config preferred-install dist

?

Copy link
Author

@peter279k peter279k Aug 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@localheinz, thank you for your reply.
It looks like adding this --prefer-dist config in composer.json instead of letting this be the option in composer install command.

I think revert this option in composer install command is the proper way if this option is required.

What do you think? Thanks.

- composer install

script:
- vendor/bin/phpunit
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,16 @@
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "~7.0"
"phpunit/phpunit": "^7.0"
},
"autoload": {
"files": ["src/bootstrap.php"]
},
"autoload-dev": {
"psr-4": {
"iter\\": "test"
}
},
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
Expand Down
9 changes: 6 additions & 3 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="./src/bootstrap.php">
bootstrap="./vendor/autoload.php">
<testsuites>
<testsuite name="Iter Test Suite">
<directory>./test/</directory>
Expand All @@ -18,7 +18,10 @@

<filter>
<whitelist>
<directory suffix=".php">./lib/</directory>
<directory suffix=".php">src</directory>
<exclude>
<file suffix=".php">src/bootstrap.php</file>
</exclude>
</whitelist>
</filter>
</phpunit>
</phpunit>
2 changes: 1 addition & 1 deletion src/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

require __DIR__ . '/iter.fn.php';
require __DIR__ . '/iter.php';
require __DIR__ . '/iter.rewindable.php';
require __DIR__ . '/iter.rewindable.php';
36 changes: 36 additions & 0 deletions test/MyIterator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace iter;

class MyIterator implements \Iterator {
private $position = 0;
private $array = [
"firstelement",
"secondelement",
"lastelement",
];

public function __construct() {
$this->position = 0;
}

public function rewind() {
$this->position = 0;
}

public function current() {
return $this->array[$this->position];
}

public function key() {
return $this->position;
}

public function next() {
++$this->position;
}

public function valid() {
return isset($this->array[$this->position]);
}
}
17 changes: 17 additions & 0 deletions test/MyIteratorAgg.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace iter;

class MyIteratorAgg implements \IteratorAggregate {
public $property1 = "Public property one";
public $property2 = "Public property two";
public $property3 = "Public property three";

public function __construct() {
$this->property4 = "last property";
}

public function getIterator() {
return new \ArrayIterator($this);
}
}
5 changes: 5 additions & 0 deletions test/iterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ public function testIsEmpty() {
$this->assertFalse(isEmpty(toArray([null])));
$this->assertTrue(isEmpty(repeat(42, 0)));
$this->assertFalse(isEmpty(repeat(42)));
$this->assertFalse(isEmpty(new MyIteratorAgg()));
}

public function testCountWithValidIteratorAgg() {
$this->assertSame(4, count(new MyIteratorAgg()));
}

public function testToArray() {
Expand Down