Example #1
0
 /**
  * Sets up the test fixture
  */
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->matcher = $this->getMock('Phake_Matchers_MethodMatcher', array(), array(), '', false);
     $this->stubMapper = Phake::mock('Phake_Stubber_StubMapper');
     $this->binder = new Phake_Stubber_AnswerBinder($this->matcher, $this->stubMapper);
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     $this->template = new LaunchKey_WP_Template(__DIR__ . '/__fixtures', $this->facade, 'test-language-domain');
     Phake::when($this->facade)->__(Phake::anyParameters())->thenReturnCallback(function ($method, $parameters) {
         return sprintf('Translated [%s]', $parameters[0]);
     });
 }
Example #3
0
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->registry = new Phake_Mock_InfoRegistry();
     $this->registry->addInfo($this->info1);
     $this->registry->addInfo($this->info2);
     $this->registry->addInfo($this->info3);
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     Phake::when($this->wpdb)->get_var(Phake::anyParameters())->thenReturn('true');
     $this->wpdb->usermeta = 'usermeta_table_name';
     $this->user->ID = 'User ID';
     $this->client = new LaunchKey_WP_SSO_Client($this->facade, $this->template, static::ENTITY_ID, $this->saml_response_service, $this->saml_request_service, $this->wpdb, static::LOGIN_URL, static::LOGOUT_URL, static::ERROR_URL, false);
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     Phake::when($this->container)->generateId(Phake::anyParameters())->thenReturn(static::UNIQUE_ID);
     SAML2_Compat_ContainerSingleton::setContainer($this->container);
     $this->service = new LaunchKey_WP_SAML2_Request_Service(self::$key);
     $this->service->load_saml_request(self::$request_data);
 }
Example #6
0
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->mock = $this->getMock('Phake_IMock');
     $this->stubMapper = Phake::mock('Phake_Stubber_StubMapper');
     $this->defaultAnswer = Phake::mock('Phake_Stubber_IAnswer');
     Phake::when($this->defaultAnswer)->getAnswerCallback('foo')->thenReturn(function () {
         return '24';
     });
     $this->answerCollection = Phake::mock('Phake_Stubber_AnswerCollection');
     $answer = Phake::mock('Phake_Stubber_IAnswer');
     Phake::when($this->answerCollection)->getAnswer()->thenReturn($answer);
     Phake::when($answer)->getAnswerCallback($this->anything(), 'foo')->thenReturn(function () {
         return '42';
     });
     Phake::when($this->stubMapper)->getStubByCall(Phake::anyParameters())->thenReturn($this->answerCollection);
     $this->handler = new Phake_ClassGenerator_InvocationHandler_StubCaller($this->stubMapper, $this->defaultAnswer);
 }
 protected function setUp()
 {
     $that = $this;
     $this->options_data = array(LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE => LaunchKey_WP_Implementation_Type::NATIVE, LaunchKey_WP_Options::OPTION_ROCKET_KEY => 12345, LaunchKey_WP_Options::OPTION_SECRET_KEY => 'Secret Key', LaunchKey_WP_Options::OPTION_PRIVATE_KEY => 'Private Key', LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME => 'LaunchKey', LaunchKey_WP_Options::OPTION_SSL_VERIFY => true);
     Phake::initAnnotations($this);
     Phake::when($this->admin)->check_option(Phake::anyParameters())->thenReturn(array(array(), array()));
     Phake::when($this->facade)->get_option(LaunchKey_WP_Admin::OPTION_KEY)->thenReturnCallback(function () use($that) {
         return $that->options_data;
     });
     Phake::when($this->facade)->wp_create_nonce(Phake::anyParameters())->thenReturn('Nonce');
     Phake::when($this->facade)->wp_verify_nonce(Phake::anyParameters())->thenReturn(true);
     Phake::when($this->facade)->__(Phake::anyParameters())->thenReturnCallback(function ($method, $parameters) {
         return sprintf('TRANSLATED [%s]', $parameters[0]);
     });
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_POST['action'] = null;
     $this->wizard = new LaunchKey_WP_Configuration_Wizard($this->facade, $this->admin, $this->client);
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     $this->client = new LaunchKey_WP_Native_Client($this->sdk_client, $this->facade, $this->template, $this->language_domain = 'Test Language Domain');
     Phake::when($this->sdk_client)->auth()->thenReturn($this->sdk_auth);
     Phake::when($this->sdk_auth)->authenticate(Phake::anyParameters())->thenReturn($this->auth_request);
     Phake::when($this->template)->render_template(Phake::anyParameters())->thenReturnCallback(function ($template) {
         return 'Rendered: ' . $template;
     });
     Phake::when($this->facade)->__(Phake::anyParameters())->thenReturnCallback(function ($method, $parameters) {
         return sprintf('Translated [%s] with [%s]', $parameters[0], $parameters[1]);
     });
     Phake::when($this->facade)->get_wpdb()->thenReturn($this->wpdb);
     Phake::when($this->facade)->get_user_by(Phake::anyParameters())->thenReturn($this->user);
     $this->user->launchkey_username = null;
     $this->user->ID = 'User ID';
     Phake::when($this->wpdb)->get_var(Phake::anyParameters())->thenReturn('true');
     $this->wpdb->usermeta = 'usermeta_table_name';
     Phake::when($this->facade)->is_debug_log()->thenReturn(false);
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     $this->options = array(LaunchKey_WP_Options::OPTION_SSL_VERIFY => false, LaunchKey_WP_Options::OPTION_ROCKET_KEY => 'Rocket Key', LaunchKey_WP_Options::OPTION_SECRET_KEY => 'Secret Key', LaunchKey_WP_Options::OPTION_REQUEST_TIMEOUT => 'Timeout Value');
     $_COOKIE['launchkey_access_token'] = 'Access Token';
     $_COOKIE['launchkey_refresh_token'] = 'Refresh Token';
     Phake::when($this->facade)->wp_get_current_user()->thenReturn((object) array('data' => (object) array('ID' => 12345, 'user_pass' => 'password')));
     Phake::when($this->facade)->wp_login_url()->thenReturn('LoginURL');
     Phake::when($this->facade)->admin_url(Phake::anyParameters())->thenReturn('AdminURL');
     $that = $this;
     Phake::when($this->facade)->get_option(Phake::anyParameters())->thenReturnCallback(function () use($that) {
         return $that->options;
     });
     Phake::when($this->facade)->wp_remote_post('https://oauth.launchkey.com/resource/ping', $this->anything())->thenReturn(array('body' => '{"message": "invalid"}'));
     Phake::when($this->facade)->wp_remote_post('https://oauth.launchkey.com/access_token', $this->anything())->thenReturn($this->wp_remote_get_response = array('body' => '{"refresh_token": "New Refresh Token", "access_token": "New Access Token", "expires_in": 9999}'));
     Phake::when($this->facade)->current_time(Phake::anyParameters())->thenReturn(1000000);
     $this->client = new LaunchKey_WP_OAuth_Client($this->facade, $this->template, false);
 }
Example #10
0
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->freezer = new Phake_Mock_Freezer();
 }
Example #11
0
 public function setUp()
 {
     Phake::initAnnotations($this);
     Phake::when($this->machinist)->getStore(Phake::equalTo('default'))->thenReturn($this->store);
 }
Example #12
0
 /**
  * Sets up the mock generator
  */
 public function setup()
 {
     Phake::initAnnotations($this);
     $this->mockGenerator = $this->getMock('Phake_ClassGenerator_MockClass');
     $this->facade = new Phake_Facade($this->infoRegistry);
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     $this->client = Phake::partialMock('LaunchKey_WP_OAuth_Client', $this->facade, $this->template, false);
 }
Example #14
0
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->handler = new Phake_ClassGenerator_InvocationHandler_CallRecorder($this->callRecorder);
 }
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->matcher = Phake::partialMock('Phake_Matchers_AbstractChainableArgumentMatcher');
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     $that = $this;
     $this->options = array(LaunchKey_WP_Options::OPTION_ROCKET_KEY => 'Original Rocket Key', LaunchKey_WP_Options::OPTION_SECRET_KEY => 'Original Secret Key', LaunchKey_WP_Options::OPTION_PRIVATE_KEY => 'Original Private Key', LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME => 'Original App Display Name', LaunchKey_WP_Options::OPTION_SSL_VERIFY => null, LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE => LaunchKey_WP_Implementation_Type::WHITE_LABEL);
     Phake::when($this->facade)->get_option(Phake::anyParameters())->thenReturnCallback(function () use($that) {
         return $that->options;
     });
     Phake::when($this->facade)->__(Phake::anyParameters())->thenReturnCallback(function ($ignore, $args) {
         return sprintf('TRANSLATED [%s]', array_shift($args));
     });
     foreach (array_keys($_FILES) as $key) {
         unset($_FILES[$key]);
     }
     $this->client = new LaunchKey_WP_Admin($this->facade, $this->template, $this->language_domain = 'launchkey', false);
 }
 protected function setUp()
 {
     $that = $this;
     Phake::initAnnotations($this);
     Phake::when($this->facade)->wp_login_url()->thenReturn('loginURL');
     Phake::when($this->facade)->admin_url(Phake::anyParameters())->thenReturn('admin.url');
     Phake::when($this->facade)->get_option(Phake::anyParameters())->thenReturnCallback(function () use($that) {
         return $that->options;
     });
     $this->options[LaunchKey_WP_Options::OPTION_ROCKET_KEY] = 12345;
     $this->options[LaunchKey_WP_Options::OPTION_SECRET_KEY] = 'secret key';
     $this->options[LaunchKey_WP_Options::OPTION_SSL_VERIFY] = true;
     $this->options[LaunchKey_WP_Options::OPTION_REQUEST_TIMEOUT] = 'Timeout Value';
     $_GET['code'] = str_repeat('a1', 32);
     $this->oauth_response = array('user' => 'OAuth User', 'access_token' => 'OAuth Access Token', 'refresh_token' => 'OAuth Refresh_token', 'code' => $_GET['code'], 'expires_in' => $this->expires_in = rand(100, 999));
     Phake::when($this->facade)->wp_remote_get(Phake::anyParameters())->thenReturnCallback(function () use($that) {
         return array('body' => json_encode($that->oauth_response));
     });
     Phake::when($this->facade)->current_time(Phake::anyParameters())->thenReturn($this->timestamp = rand(10000, 99999));
     $this->client = new LaunchKey_WP_OAuth_Client($this->facade, $this->template, false);
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     Phake::when($this->facade)->get_launchkey_options()->thenReturn($this->options);
     $this->client = new LaunchKey_WP_OAuth_Client($this->facade, $this->template);
 }
Example #19
0
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->info = $this->getSUT();
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     $this->options = LaunchKey_WP_Options::get_defaults();
     Phake::when($this->facade)->settings_fields(Phake::anyParameters())->thenReturn('settings_fields response');
     Phake::when($this->facade)->do_settings_sections(Phake::anyParameters())->thenReturn('do_settings_sections response');
     Phake::when($this->facade)->submit_button(Phake::anyParameters())->thenReturn('submit_button response');
     $that = $this;
     Phake::when($this->facade)->get_option(Phake::anyParameters())->thenReturnCallback(function () use($that) {
         return $that->options;
     });
     Phake::when($this->template)->render_template(Phake::anyParameters())->thenReturnCallback(function ($template) {
         return sprintf('Rendered [%s]', $template);
     });
     Phake::when($this->facade)->__(Phake::anyParameters())->thenReturnCallback(function ($method, $parameters) {
         return sprintf('TRANSLATED [%s]', $parameters[0]);
     });
     Phake::when($this->facade)->admin_url(Phake::anyParameters())->thenReturnCallback(function ($method, $parameters) {
         return sprintf('AdminURL [%s]', isset($parameters[0]) ? $parameters[0] : "ROOT");
     });
     Phake::when($this->facade)->wp_login_url(Phake::anyParameters())->thenReturnCallback(function ($method, $parameters) {
         return sprintf('LoginURL [%s]', isset($parameters[0]) ? $parameters[0] : "ROOT");
     });
     Phake::when($this->facade)->parse_url(Phake::anyParameters())->thenReturn("Parsed URL");
     Phake::when($this->facade)->wp_get_current_user()->thenReturn((object) array('user_login' => "login"));
     $this->admin = new LaunchKey_WP_Admin($this->facade, $this->template, $this->language_domain, false);
 }
 protected function setUp()
 {
     \Phake::initAnnotations($this);
     $this->event = new PingResponseEvent($this->pingResponse);
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     $this->container = new LaunchKey_WP_SAML2_Container($this->logger);
 }
 protected function setUp()
 {
     $that = $this;
     $this->options_data = array(LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE => LaunchKey_WP_Implementation_Type::NATIVE, LaunchKey_WP_Options::OPTION_ROCKET_KEY => 12345, LaunchKey_WP_Options::OPTION_SECRET_KEY => 'Secret Key', LaunchKey_WP_Options::OPTION_PRIVATE_KEY => 'Private Key', LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME => 'LaunchKey', LaunchKey_WP_Options::OPTION_SSL_VERIFY => true);
     Phake::initAnnotations($this);
     Phake::when($this->facade)->get_option(LaunchKey_WP_Admin::OPTION_KEY)->thenReturnCallback(function () use($that) {
         return $that->options;
     });
     Phake::when($this->facade)->wp_get_current_user()->thenReturn($this->user);
     Phake::when($this->facade)->wp_create_nonce(Phake::anyParameters())->thenReturn('Nonce');
     Phake::when($this->facade)->wp_verify_nonce(Phake::anyParameters())->thenReturn(true);
     Phake::when($this->facade)->get_wpdb()->thenReturn($this->wpdb);
     $this->wpdb->usermeta = 'usermeta_table';
     Phake::when($this->client)->auth()->thenReturn($this->auth);
     Phake::when($this->auth)->authorize(Phake::anyParameters())->thenReturn($this->auth_request);
     Phake::when($this->client)->whiteLabel()->thenReturn($this->white_label_service);
     Phake::when($this->white_label_service)->createUser(Phake::anyParameters())->thenReturn($this->white_label_user);
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $_POST['action'] = null;
     $this->wizard = new LaunchKey_WP_Configuration_Wizard($this->facade, $this->admin, $this->client);
 }
Example #24
0
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->classGen = new Phake_ClassGenerator_MockClass();
 }
 protected function setUp()
 {
     $that = $this;
     Phake::initAnnotations($this);
     Phake::when($this->facade)->get_user_meta(Phake::anyParameters())->thenReturn(array('launchkey_user' => 'awesome_launchkey_user'));
     Phake::when($this->facade)->admin_url(Phake::anyParameters())->thenReturnCallback(function ($func, $args) {
         return 'AdminURL' . $args[0];
     });
     Phake::when($this->facade)->get_option(Phake::anyParameters())->thenReturnCallback(function () use($that) {
         return $that->options;
     });
     Phake::when($this->facade)->get_site_option(Phake::anyParameters())->thenReturnCallback(function () use($that) {
         return $that->options;
     });
     Phake::when($this->facade)->wp_create_nonce(Phake::anyParameters())->thenReturnCallback(function ($func, $args) {
         return $args[0] . '_value';
     });
     Phake::when($this->facade)->__(Phake::anyParameters())->thenReturnCallback(function ($func, $args) {
         return sprintf('Translated [%s]', $args[0]);
     });
     Phake::when($this->template)->render_template(Phake::anyParameters())->thenReturnCallback(function ($template) {
         return "Rendered [{$template}]";
     });
     Phake::when($this->facade)->wp_get_current_user()->thenReturn($this->user);
     Phake::when($this->facade)->get_wpdb()->thenReturn($this->wp_db);
     $this->options = array(LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME => 'App Display Name', LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE => LaunchKey_WP_Implementation_Type::OAUTH);
     $this->user->ID = 12345;
     $this->user->user_pass = '******';
     $this->launguage_domain = 'Expected Language Domain';
     $this->client = new LaunchKey_WP_User_Profile($this->facade, $this->template, $this->launguage_domain, false);
 }
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->matcher = Phake::partialMock('Phake_Matchers_SingleArgumentMatcher');
     $this->matcher->setNextMatcher($this->nextMatcher);
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     $this->options = array(LaunchKey_WP_Options::OPTION_ROCKET_KEY => 12345, LaunchKey_WP_Options::OPTION_APP_DISPLAY_NAME => 'App Display Name');
     $that = $this;
     Phake::when($this->facade)->get_option(Phake::anyParameters())->thenReturnCallback(function () use($that) {
         return $that->options;
     });
     Phake::when($this->template)->render_template(Phake::anyParameters())->thenReturnCallback(function ($template) {
         return "Rendered [{$template}]";
     });
     $this->client = new LaunchKey_WP_OAuth_Client($this->facade, $this->template);
 }
 protected function setUp()
 {
     Phake::initAnnotations($this);
     $that = $this;
     $this->options = array(LaunchKey_WP_Options::OPTION_SSO_ENTITY_ID => 'Original Entity ID', LaunchKey_WP_Options::OPTION_SSO_CERTIFICATE => 'Original Certificate', LaunchKey_WP_Options::OPTION_SSO_LOGIN_URL => 'Original Login URL', LaunchKey_WP_Options::OPTION_SSO_LOGOUT_URL => 'Original Logout URL', LaunchKey_WP_Options::OPTION_SSO_ERROR_URL => 'Original Error URL', LaunchKey_WP_Options::OPTION_IMPLEMENTATION_TYPE => LaunchKey_WP_Implementation_Type::SSO);
     Phake::when($this->facade)->get_option(Phake::anyParameters())->thenReturnCallback(function () use($that) {
         return $that->options;
     });
     Phake::when($this->facade)->__(Phake::anyParameters())->thenReturnCallback(function ($ignore, $args) {
         return sprintf('TRANSLATED [%s]', array_shift($args));
     });
     foreach (array_keys($_FILES) as $key) {
         unset($_FILES[$key]);
     }
     $_FILES['sso_idp']['tmp_name'] = realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . "__fixtures" . DIRECTORY_SEPARATOR . "idp.xml");
     $this->admin = new LaunchKey_WP_Admin($this->facade, $this->template, $this->language_domain = 'launchkey', false);
 }
Example #29
0
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->matcher = new Phake_Matchers_MethodMatcher('foo', $this->rootArgumentMatcher);
 }
 public function setUp()
 {
     Phake::initAnnotations($this);
     $this->matcher = new Phake_Matchers_ChainedArgumentMatcher($this->adapted);
     $this->matcher->setNextMatcher($this->nextMatcher);
 }