blob: bca2a50de502edbea47cbadb766e2667b7c4a9a8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<?php
require_once PIWIK_INCLUDE_PATH . '/plugins/DevicesDetection/UserAgentParserEnhanced/UserAgentParserEnhanced.php';
class UserAgentParserEnhancedTest extends PHPUnit_Framework_TestCase
{
/**
* @group Plugins
*/
public function testParse()
{
$fixturesPath = realpath(dirname(__FILE__) . '/../Fixtures/userAgentParserEnhancedFixtures.yml');
$fixtures = Spyc::YAMLLoad($fixturesPath);
foreach ($fixtures as $fixtureData) {
$ua = $fixtureData['user_agent'];
$uaInfo = UserAgentParserEnhanced::getInfoFromUserAgent($ua);
$parsed[] = $uaInfo;
}
if($fixtures != $parsed) {
$processed = Spyc::YAMLDump($parsed, false, $wordWrap = 0);
$processedPath = $fixturesPath . '.new';
file_put_contents($processedPath, $processed);
$diffCommand = "diff";
$command = "{$diffCommand} $fixturesPath $processedPath";
echo $command . "\n";
echo shell_exec($command);
echo "\nThe processed data was stored in: $processedPath ".
"\n $ cp $processedPath $fixturesPath ".
"\n to copy the file over if it is valid.";
$this->assertTrue(false);
}
$this->assertTrue(true);
}
}
|