Skip to content

Commit

Permalink
More test cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
allebb committed Jan 31, 2016
1 parent 225712b commit 3baab8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function tags($type = null)
if (isset($this->gatherTags()[$type])) {
return $this->gatherTags()[$type];
}
throw new \InvalidArgumentException(sprintf('The tag "%s" is not registered!', $type));
throw new \InvalidArgumentException(sprintf('The tag "%s" has no results.', $type));
}

/**
Expand All @@ -84,12 +84,12 @@ public function tags($type = null)
* @return array
* @throws InvalidArgumentException
*/
public function tag($name = null)
public function tag($name)
{
if (!is_null($name) && isset($this->configuration->get()[$name])) {
if (isset($this->configuration->get()[$name])) {
return $this->configuration->get()[$name];
}
throw new \InvalidArgumentException('A tag type was not specified!');
throw new \InvalidArgumentException(sprintf('The tag "%s" is not registered!', $name));
}

/**
Expand Down
9 changes: 8 additions & 1 deletion tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,14 @@ public function testGetTopicConfigurationArray()
public function testGetInvalidTagArray()
{
$instance = new TagParser(self::EXAMPLE_TWEET_1, (new TagConfiguration)->loadDefault());
$this->setExpectedException('\InvalidArgumentException', 'The tag "locations" is not registered!');
$this->setExpectedException('\InvalidArgumentException', 'The tag "locations" has no results.');
$instance->tags('locations');
}

public function testGetInvalidTagConfigurationArray()
{
$instance = new TagParser(self::EXAMPLE_TWEET_1, (new TagConfiguration)->loadDefault());
$this->setExpectedException('\InvalidArgumentException', 'The tag "locations" is not registered!');
$instance->tag('locations');
}
}

0 comments on commit 3baab8c

Please sign in to comment.