-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test enhancement #62
base: master
Are you sure you want to change the base?
test enhancement #62
Conversation
src/bootstrap.php
Outdated
require __DIR__ . '/iter.rewindable.php'; | ||
require __DIR__ . '/../test/MyIterator.php'; | ||
require __DIR__ . '/../test/MyIteratorAgg.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These files shouldn't be included here, as they are only needed for tests. Either we should have a separate bootstrap file in the test directory, or we can explicitly include the files in the test, or we can place the class definitions in the test file (like _CountableTestDummy
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, I will move the related test
class bootstrap.php
file to the test
folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use the autoload-dev
in composer.json
to autoload the required *Test.php
files.
test/iterTest.php
Outdated
@@ -359,6 +359,10 @@ public function testCount() { | |||
$this->assertSame(42, count(new _CountableTestDummy)); | |||
} | |||
|
|||
public function testCountWithStringCount() { | |||
$this->assertSame(3, count(new MyIterator())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand the purpose of this test. This is testing counting of an iterator, which is also tested by the $this->assertSame(5, count(toIter([1, 2, 3, 4, 5])))
line above. I'm also not clear on why this is called "testCountWithStringCount". How is this related to strings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's my fault to create the duplicated tests.
I will remove this test method.
test/iterTest.php
Outdated
@@ -368,6 +372,10 @@ public function testIsEmpty() { | |||
$this->assertFalse(isEmpty(repeat(42))); | |||
} | |||
|
|||
public function testIsEmptyWithValidIteratorAgg() { | |||
$this->assertFalse(isEmpty(new MyIteratorAgg())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should test count()
with an iterator aggregate as well, looks like that case isn't present yet.
language: php | ||
|
||
php: | ||
- 7.1 | ||
- 7.2 | ||
|
||
install: | ||
- composer install --prefer-dist |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
changed log
Iterator
andIteratorAggregate
interface to test thecount
andisEmpty
function..travis.yml
.The default dist is trusty.Remove
--prefer-dist
because it should let composer check the dependency.