| @@ 49-89 (lines=41) @@ | ||
| 46 | * Testing basic functionality |
|
| 47 | * @return void |
|
| 48 | */ |
|
| 49 | public function testIndex() |
|
| 50 | { |
|
| 51 | $client = static::createClient(); |
|
| 52 | ||
| 53 | // Let's get information from the schema |
|
| 54 | $client->request('GET', '/analytics/schema/app'); |
|
| 55 | $content = $client->getResponse()->getContent(); |
|
| 56 | $schema = json_decode($content); |
|
| 57 | ||
| 58 | // Check schema |
|
| 59 | $sampleSchema = json_decode( |
|
| 60 | '{ |
|
| 61 | "title": "Application usage", |
|
| 62 | "description": "Data use for application access", |
|
| 63 | "type": "object", |
|
| 64 | "representation": "pie", |
|
| 65 | "properties": { |
|
| 66 | "id": { |
|
| 67 | "title": "ID", |
|
| 68 | "description": "Unique identifier", |
|
| 69 | "type": "string" |
|
| 70 | }, |
|
| 71 | "count": { |
|
| 72 | "title": "count", |
|
| 73 | "description": "Sum of result", |
|
| 74 | "type": "integer" |
|
| 75 | } |
|
| 76 | } |
|
| 77 | }' |
|
| 78 | ); |
|
| 79 | $this->assertEquals($sampleSchema, $schema); |
|
| 80 | ||
| 81 | // Let's get information from the count |
|
| 82 | $client->request('GET', '/analytics/app'); |
|
| 83 | $content = $client->getResponse()->getContent(); |
|
| 84 | $data = json_decode($content); |
|
| 85 | ||
| 86 | // Counter data result of aggregate |
|
| 87 | $sampleData = json_decode('{"_id":"app-count","count":2}'); |
|
| 88 | $this->assertEquals($sampleData, $data); |
|
| 89 | } |
|
| 90 | ||
| 91 | /** |
|
| 92 | * Testing basic functionality |
|
| @@ 113-154 (lines=42) @@ | ||
| 110 | * Testing basic functionality |
|
| 111 | * @return void |
|
| 112 | */ |
|
| 113 | public function testCustomerCreateDateFilteringIndex() |
|
| 114 | { |
|
| 115 | $client = static::createClient(); |
|
| 116 | ||
| 117 | // Let's get information from the count |
|
| 118 | $client->request('GET', '/analytics/customer-created-by-date'); |
|
| 119 | $content = $client->getResponse()->getContent(); |
|
| 120 | $data = json_decode($content); |
|
| 121 | ||
| 122 | // Counter data result of aggregate |
|
| 123 | $sampleData = json_decode( |
|
| 124 | '[ |
|
| 125 | { |
|
| 126 | "_id": "100", |
|
| 127 | "customerNumber": 1100, |
|
| 128 | "name": "Acme Corps.", |
|
| 129 | "created_year": 2014, |
|
| 130 | "created_month": 7 |
|
| 131 | } |
|
| 132 | ]' |
|
| 133 | ); |
|
| 134 | $this->assertEquals($sampleData, $data); |
|
| 135 | ||
| 136 | // Let's get information from the count, but cached version |
|
| 137 | $client->request('GET', '/analytics/customer-created-by-date'); |
|
| 138 | $content = $client->getResponse()->getContent(); |
|
| 139 | $data = json_decode($content); |
|
| 140 | ||
| 141 | // Counter data result of aggregate |
|
| 142 | $sampleData = json_decode( |
|
| 143 | '[ |
|
| 144 | { |
|
| 145 | "_id": "100", |
|
| 146 | "customerNumber": 1100, |
|
| 147 | "name": "Acme Corps.", |
|
| 148 | "created_year": 2014, |
|
| 149 | "created_month": 7 |
|
| 150 | } |
|
| 151 | ]' |
|
| 152 | ); |
|
| 153 | $this->assertEquals($sampleData, $data); |
|
| 154 | } |
|
| 155 | } |
|
| 156 | ||