-
Notifications
You must be signed in to change notification settings - Fork 1
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
[WIP] Initial phpunit setup #10
base: master
Are you sure you want to change the base?
Conversation
* some unit tests
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.
Here are my 2 cents on that. We should probably introduce VCR to stub the network code.
|
||
public function testInstance() | ||
{ | ||
static::assertInstanceOf('JK\Mittagstisch\MenuItem', $this->instance); |
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.
- A regular user of PHPUnit should use $this-> instead of self::
|
||
public function testInstance() | ||
{ | ||
static::assertInstanceOf('JK\Mittagstisch\Scrapers\Bullerei', $this->instance); |
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.
More or less pointless test. You would have a point in testing it for implementing the new Restaurant interface, though.
{ | ||
$menus = $this->invokeScrape($this->instance, 'scrape'); | ||
static::assertInternalType('array', $menus); | ||
static::assertContainsOnlyInstancesOf('JK\Mittagstisch\MenuItem', $menus); |
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.
Technically this is a functional test and not a unit test anymore. If that's the case, the network code should be stubbed.
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.
You are right.
Propably there is some kind of method-splitting necessary to test the regex-matching. I will have look at this "network-stubbing", I don't have any experience about that.
It would be really useful to check or parse against given HTML from the past, so that we can catch several "kinds of postings", e.g. extra <p>
-tags, changed string-formatting.
$method = $reflection->getMethod($methodName); | ||
$method->setAccessible(true); | ||
|
||
return $method->invokeArgs($object, $parameters); |
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.
Not to happy about something like this in a test suite. I understand where you're heading, but since we can change the code, we rather want to do that instead.
Feel free to comment 🎉