Skip to content

Conversation

@peter279k
Copy link

@peter279k peter279k commented Feb 5, 2018

changed log

  • implemnt the customized Iterator and IteratorAggregate interface to test the count and isEmpty function.
  • set correct .travis.yml.The default dist is trusty.
    Remove --prefer-dist because it should let composer check the dependency.

require __DIR__ . '/iter.rewindable.php';
require __DIR__ . '/iter.rewindable.php';
require __DIR__ . '/../test/MyIterator.php';
require __DIR__ . '/../test/MyIteratorAgg.php';
Copy link
Owner

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).

Copy link
Author

@peter279k peter279k Feb 28, 2018

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.

Copy link
Author

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.

}

public function testCountWithStringCount() {
$this->assertSame(3, count(new MyIterator()));
Copy link
Owner

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?

Copy link
Author

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.

}

public function testIsEmptyWithValidIteratorAgg() {
$this->assertFalse(isEmpty(new MyIteratorAgg()));
Copy link
Owner

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.

- 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.

@localheinz localheinz mentioned this pull request Aug 9, 2018
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants