Blame view

tests/unit/Api/EndpointTest.php 1.93 KB
15479603   Alex Savenko   initialize
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  <?php
  
  namespace PhalconRest\Test\Unit\Api;
  
  use PhalconRest\Api\Endpoint;
  use PhalconRest\Constants\HttpMethods;
  use PhalconRest\Constants\PostedDataMethods;
  
  class EndpointTest extends \Codeception\TestCase\Test {
  
      const EXAMPLE_RESPONSE = '{"item":{"title": "A Sunny Holiday"}}';
  
      /** @var Endpoint */
      protected $endpoint;
  
      protected function _before() {
  
          $this->endpoint = Endpoint::get('/all', 'all')
              ->name('All')
              ->description('a short description')
              ->exampleResponse(self::EXAMPLE_RESPONSE);
      }
  
      public function testIdentifier() {
  
          $this->assertEquals($this->endpoint->getIdentifier(), 'GET /all');
      }
  
      public function testHttpMethod() {
  
          $this->assertEquals($this->endpoint->getHttpMethod(), HttpMethods::GET);
      }
  
      public function testHandlerMethod() {
  
          $this->assertEquals($this->endpoint->getHandlerMethod(), 'all');
      }
  
      public function testName() {
  
          $this->assertEquals($this->endpoint->getName(), 'All');
      }
  
      public function testDescription() {
  
          $this->assertEquals($this->endpoint->getDescription(), 'a short description');
      }
  
      public function testExampleResponse() {
  
          $this->assertEquals($this->endpoint->getExampleResponse(), self::EXAMPLE_RESPONSE);
      }
  
      public function testPath() {
  
          $this->assertEquals($this->endpoint->getPath(), '/all');
      }
  
      public function testGetDefaultPostedDataMethod() {
  
          $this->assertEquals($this->endpoint->getPostedDataMethod(), PostedDataMethods::AUTO);
      }
  
      public function testExpectsJsonData() {
  
          $this->endpoint->expectsJsonData();
          $this->assertEquals($this->endpoint->getPostedDataMethod(), PostedDataMethods::JSON_BODY);
      }
  
      public function testExpectsPostData() {
  
          $this->endpoint->expectsPostData();
          $this->assertEquals($this->endpoint->getPostedDataMethod(), PostedDataMethods::POST);
      }
  }