title: Mock get parameters symfony2 and phpunit
body: <p>I would like to test one controller that it has:</p>
  
  <p>$deviceGet = strtolower($request->query->get('device'));</p>
  
  <p>My question is: How can I mock it to test in my controller?</p>
  
  <pre><code>class SetDeviceListenerTest extends \PHPUnit_Framework_TestCase {
  
  
       /**
       * @test
       * @dataProvider deviceGetCases
       */
  public function shouldSetRequestDeviceWithDeviceGetOnMasterRequest(
      ?string $device
  ): void {
      $request = $this-&gt;getRequestMock();
  
      $request-&gt;expects($this-&gt;once())
          -&gt;method('get')
          -&gt;with('device')
          -&gt;willReturn($device);
  
  
      /* @var Request $request */
      $request-&gt;server = new ServerBag();
      $request-&gt;headers = new HeaderBag();
  
      $event = $this-&gt;getEventMock();
      $event-&gt;expects($this-&gt;once())
          -&gt;method('isMasterRequest')
          -&gt;willReturn(true);
  </code></pre>
  
  <p>It return error because</p>
  
  <pre><code> $request-&gt;expects($this-&gt;once())
          -&gt;method('get')
          -&gt;with('device')
          -&gt;willReturn($device);
  </code></pre>
  
  <p>fails</p>
  
  <p>thank you!!</p>