Created
October 5, 2012 02:43
-
-
Save vexus2/3837775 to your computer and use it in GitHub Desktop.
[PHP]UserAgent切り替え for Behat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @var $world FeatureContext | |
*/ | |
$steps->Given( '/^"([^"]*)" でアクセスしている$/', function ( $world, $table ) { | |
switch ( $table ) { | |
case "フィーチャフォン": | |
$user_agent = "KDDI-CA39 UP.Browser/6.2.0.13.1.5 (GUI) MMP/2.0"; | |
break; | |
case "スマートフォン": | |
$user_agent = "Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_0_1 like Mac OS X; ja-jp) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5B108 Safari/525.20"; | |
break; | |
default: | |
$user_agent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.13 (KHTML, like Gecko) Chrome/24.0.1284.0 Safari/537.13"; | |
break; | |
} | |
$world->getSession()->getDriver()->getClient()->setServerParameters( array( 'HTTP_USER_AGENT' => $user_agent ) ); | |
} ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment