Example #1
0
 /**
  * test _handleVersion() method
  *
  * @test
  */
 public function _handleVersion()
 {
     $this->generateComponent();
     $this->Api->dispatchMethod('_handleVersion', [$this->controller]);
     $this->assertSame('1.0', $this->Api->version);
     $this->generateComponent();
     Configure::write('TEST_API_VERSION', '2.1');
     $this->Api->dispatchMethod('_handleVersion', [$this->controller]);
     $this->assertSame('2.1', $this->Api->version);
     $modelConfig = ClassRegistry::config('Model');
     ClassRegistry::config('Model', null);
     $this->generateComponent();
     $this->Api->dispatchMethod('_handleVersion', [$this->controller]);
     $this->assertSame('1.0', $this->Api->version);
     $this->generateComponent(['mocks' => ['request' => ['header']]]);
     $this->request->staticExpects($this->once())->method('header')->with('APIVersion')->will($this->returnValue('3.5'));
     $this->Api->dispatchMethod('_handleVersion', [$this->controller]);
     $this->assertSame('3.5', $this->Api->version);
     ClassRegistry::config('Model', $modelConfig);
     Configure::delete('TEST_API_VERSION');
 }