Skip to content

Commit

Permalink
Merge pull request #139 from mpetty/fix-version-merge-rules
Browse files Browse the repository at this point in the history
Fixed bug when testing browser version for Opera or IE #138
  • Loading branch information
jenssegers committed Jan 19, 2019
2 parents 41cd1fd + ac5bfef commit bcb8953
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ public function version($propertyName, $type = self::VERSION_TYPE_STRING)
$properties[$propertyName] = (array) $properties[$propertyName];

foreach ($properties[$propertyName] as $propertyMatchString) {
if (is_array($propertyMatchString)) {
$propertyMatchString = implode("|", $propertyMatchString);
}

$propertyPattern = str_replace('[VER]', self::VER, $propertyMatchString);

// Identify and extract the version.
Expand Down
5 changes: 5 additions & 0 deletions tests/AgentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,11 @@ public function testVersions()
$platform = $agent->platform();
$this->assertEquals($version, $agent->version($platform), $ua);
}

foreach ($this->browsers as $ua => $browser) {
$agent->setUserAgent('FAKE');
$this->assertFalse($agent->version($browser));
}
}

public function testIsMethods()
Expand Down

0 comments on commit bcb8953

Please sign in to comment.