Пример #1
0
 /**
  * Test for the validate() method.
  *
  * @return void
  */
 public function test_validate()
 {
     $action = 'action';
     $nonce = 'nonce';
     $testee = new Testee(compact('action', 'nonce'));
     Monkey\Functions::expect('wp_verify_nonce')->with($nonce, $action)->andReturn(true);
     $this->assertTrue($testee->validate());
 }
Пример #2
0
 /**
  * Test for the create() method.
  *
  * @return void
  */
 public function test_create()
 {
     $testee = new Testee();
     $action = 'action';
     /** @var Context $context */
     $context = Mockery::mock('Inpsyde\\Nonces\\Context')->shouldReceive('get_action')->andReturn($action)->getMock();
     Monkey\Functions::expect('wp_create_nonce')->with($action);
     $this->assertInstanceOf('Inpsyde\\Nonces\\Nonce', $testee->create($context));
 }
Пример #3
0
 /**
  * Test for the create() method.
  *
  * @return void
  */
 public function test_create()
 {
     $testee = new Testee();
     $action = 'action';
     Monkey\Functions::when('sanitize_title_with_dashes');
     $context = new Context($action);
     $nonce_value = 'nonce';
     Monkey\Functions::expect('wp_create_nonce')->with($action)->andReturn($nonce_value);
     $nonce = $testee->create($context);
     $this->assertSame($nonce_value, $nonce->get());
 }
 function test_check_admin_referral()
 {
     //Setup
     Functions::expect('wp_create_nonce')->once()->with('doing_some_admin_job')->andReturn('abged45fg');
     Functions::expect('check_admin_referer')->once()->with('doing_some_admin_job', '_wpnonce')->andReturn(1);
     //Act
     $nonce = new Nonce_Wrapper('doing_some_admin_job');
     $nonce_val = $nonce->create_nonce();
     $_REQUEST['_wpnonce'] = $nonce_val;
     //Verify
     $this->assertEquals($nonce->check_admin_referral(), 1);
 }
Пример #5
0
 /**
  * Test for the render() method.
  *
  * @return void
  */
 public function test_render()
 {
     $testee = new Testee();
     $action = 'action';
     $name = 'name';
     /** @var Context $context */
     $context = Mockery::mock('Inpsyde\\Nonces\\Context')->shouldReceive('get_action')->andReturn($action)->shouldReceive('get_name')->andReturn($name)->getMock();
     $nonce_field = 'nonce_field';
     Monkey\Functions::expect('wp_nonce_field')->with($action, $name, false, false)->andReturn($nonce_field);
     $this->expectOutputString($nonce_field);
     $testee->render($context);
 }
Пример #6
0
 /**
  * Test for the render() method.
  *
  * @return void
  */
 public function test_render()
 {
     $testee = new Testee();
     $action = 'action';
     $name = 'name';
     Monkey\Functions::when('sanitize_title_with_dashes')->returnArg();
     $context = new Context($action, $name);
     $nonce_field = 'nonce_field';
     Monkey\Functions::expect('wp_nonce_field')->with($action, $name, false, false)->andReturn($nonce_field);
     $this->expectOutputString($nonce_field);
     $testee->render($context);
 }
Пример #7
0
 /**
  * Test for the render() method.
  *
  * @return void
  */
 public function test_render()
 {
     $testee = new Testee();
     $action = 'action';
     $name = 'name';
     Monkey\Functions::when('sanitize_title_with_dashes')->returnArg();
     $context = new Context($action, $name);
     $nonce = 'nonce';
     Monkey\Functions::expect('wp_create_nonce')->with($action)->andReturn($nonce);
     Monkey\Functions::when('esc_attr')->returnArg();
     $this->expectOutputString("data-{$name}=\"{$nonce}\"");
     $testee->render($context);
 }
Пример #8
0
 /**
  * Test for the render() method.
  *
  * @return void
  */
 public function test_render()
 {
     $testee = new Testee();
     $action = 'action';
     $nonce = 'nonce';
     Monkey\Functions::expect('wp_create_nonce')->with($action)->andReturn($nonce);
     $name = 'name';
     /** @var Context $context */
     $context = Mockery::mock('Inpsyde\\Nonces\\Context')->shouldReceive('get_action')->andReturn($action)->shouldReceive('get_name')->andReturn($name)->getMock();
     Monkey\Functions::when('esc_attr')->returnArg();
     $this->expectOutputString("data-{$name}=\"{$nonce}\"");
     $testee->render($context);
 }