public function testListCatalogues() { $client = $this->createAuthenticatedClient(); $client->request('GET', '/api/catalogues?flat=true&fields=id,locale&packageId=' . $this->package->getId()); $this->assertEquals('200', $client->getResponse()->getStatusCode()); $response = json_decode($client->getResponse()->getContent()); $this->assertEquals($this->catalogue->getId(), $response->_embedded->catalogues[0]->id); $this->assertEquals('EN', $response->_embedded->catalogues[0]->locale); }
public function testPut() { $request = ['code' => 'test.code.4', 'frontend' => '1', 'backend' => '0', 'length' => '20', 'package' => ['id' => $this->package2->getId()], 'location' => ['id' => $this->location2->getId()], 'translations' => [['value' => 'Test Code 1.1', 'catalogue' => ['id' => $this->catalogue1->getId()]], ['value' => 'Test Code 1.2', 'catalogue' => ['id' => $this->catalogue2->getId()]], ['value' => 'Test Code 1.3', 'catalogue' => ['id' => $this->catalogue3->getId()]]]]; $this->client->request('PUT', '/api/codes/' . $this->code1->getId(), $request); $response = json_decode($this->client->getResponse()->getContent()); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->client->request('GET', '/api/codes/' . $this->code1->getId()); $response = json_decode($this->client->getResponse()->getContent()); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $this->assertNotNull($response->id); $this->assertEquals($request['code'], $response->code); $this->assertEquals($request['backend'] == '0' ? false : true, $response->backend); $this->assertEquals($request['frontend'] == '0' ? false : true, $response->frontend); $this->assertEquals($request['length'], $response->length); $this->assertEquals($request['location']['id'], $response->location->id); $this->assertEquals(3, sizeof($response->translations)); $values = [$request['translations'][0]['value'], $request['translations'][1]['value'], $request['translations'][2]['value']]; $this->assertTrue(in_array($response->translations[0]->value, $values)); $values = array_diff($values, [$response->translations[0]->value]); $this->assertTrue(in_array($response->translations[1]->value, $values)); $values = array_diff($values, [$response->translations[1]->value]); $this->assertTrue(in_array($response->translations[2]->value, $values)); $values = array_diff($values, [$response->translations[2]->value]); $this->assertEquals(0, sizeof($values)); }