John Davidson

php - Symfony - deep cloning functional test

0 comments
Message:


I am trying to write I functional test for my deep cloning entity method __clone() on my Symfony project, which is defined in my method class..


I am new at writing tests and I can not find any source where I can get an info about this specific operation. This is what I got so far:


public function testDuplicate()
{

$userInProgress = $this->fixtureLoader->getReferenceRepository()->getReference(UserFixtures::USER_1);

$data = [
"name" => "John Doe"
];

$expected = [
"name" => "John Doe",
"status" => "IN_PROGRESS",
"assignee" => [
"uuid" => "4e7c77d5-8e36-4319-b250-050d241621dc",
]
"archived" => FALSE
];

$client->request('POST',
self::API_URL . self::USER_ENDPOINT . 'copy/' . $userInProgress->getId(),
[],
[],
[
'CONTENT_TYPE' => 'application/ld+json',
'HTTP_ACCEPT' => 'application/ld+json'
],
json_encode($data)
);

//assert
$this->assertEquals(200, $client->getResponse()->getStatusCode());

$response = $client->getResponse()->getContent();
$this->assertArraySubset($expected, json_decode($response, true));
}

This will run my test but I am not sure if it will actually test if deep cloning is set as it should?


Can anybody help?



My Answer:
>createUserInProgress();__ $userInProgressClone = clone $userInProgress;__ $this->assertEquals($userInProgress, $userInProgressClone);__}_I am not sure if this is the correct way to test the deep cloning functionality. Can someone please provide some guidance on how to properly test the deep cloning functionality in Symfony?

Rate this post

4 of 5 based on 8162 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us