-
Notifications
You must be signed in to change notification settings - Fork 2
Feat/collection #72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Feat/collection #72
Conversation
| public function up(Schema $schema): void | ||
| { | ||
| // this up() migration is auto-generated, please modify it to your needs | ||
| $this->addSql('ALTER TABLE book CHANGE id id BINARY(16) NOT NULL COMMENT \'(DC2Type:uuid)\''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se nella tabella sono già presenti dei dati, i valori non vengono automaticamente convertiti in uuid ma rimangono gli interi dei vecchi id.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ci piacerebbe approfondire l'argomento insieme quando avete tempo su quale il modo migliore di approcciare questa situazione.
| $entity = $this->bookRepository->find(Uuid::fromString($id)); | ||
|
|
||
| if (!$entity) { | ||
| throw new HttpException(404, 'Book not found'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se volete evitare di passare ogni volta il codice dell'eccezione esistono anche delle eccezioni specifiche come NotFoundHttpException, BadRequestHttpException, ecc.
Inoltre in questo caso esiste anche un metodo specifico dentro AbstractController per lanciare delle 404: $this->createNotFoundException('Book not found')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ottimo suggerimento! Buono a sapersi! Sistemato
| ], | ||
| ]); | ||
| self::assertNotFalse($body); | ||
| $this->client->xmlHttpRequest('POST', '/api/collections', [], [], $headers, $body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perchè avete usato xmlHttpRequest piuttosto che request come già fatto per Book?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All'inizio avevamo utilizzato xmlHttpRequest poi siamo passati a request e ci siamo dimenticati di aggiornare tutto.
PS che differenza c'è tra i due metodi?
| self::assertNotFalse($body); | ||
| $this->client->xmlHttpRequest('POST', '/api/collections', [], [], $headers, $body); | ||
| $res = $this->client->getResponse(); | ||
| self::assertEquals(201, $res->getStatusCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In alternativa a queste due righe potreste usare anche $this->assertResponseStatusCodeSame(Response::HTTP_CREATED);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixato anche questo!
| ->expects($this->exactly(2)) | ||
| ->method('storeBook') | ||
| ->withConsecutive([Book::newBookFrom($book1)], [Book::newBookFrom($book2)]); | ||
| ->withAnyParameters(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perchè avete scelto di passare ad una condizione meno stringente?
Prima il controllo era esatto sul libro mentre adesso viene accettata qualunque cosa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se non ricordo male era un workaround temporaneo che poi volevamo vedere insieme a voi (commento riga 31), perché se si utilizza la condizione precedente il test fallisce sul campo uid a causa del mock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confermo che volevamo vederla con voi, abbiamo spostato il commento nella riga interessata.
No description provided.