Skip to content

Commit

Permalink
Add gravatar and larvatar size tests
Browse files Browse the repository at this point in the history
This update introduces new test cases for both GravatarTest.php and LarvatarTest.php, mainly focusing on verification of different avatar types and size settings. Gravatar type tests have been implemented for InitialsAvatar, Gravatar, and MP types, while Larvatar size tests examine regular, large, and small sizes.
  • Loading branch information
renfordt committed Mar 31, 2024
1 parent f2fe786 commit a59c731
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
34 changes: 33 additions & 1 deletion tests/GravatarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,36 @@ public function testGravatarRobohashLink(): void
$gravatar->generateGravatarLink()
);
}
}
public function testSetTypeInitialsAvatar(): void
{
$gravatar = new Gravatar('user@example.com');
$defaultType = $gravatar->generateGravatarLink();

$gravatar->setType(LarvatarTypes::InitialsAvatar);
$this->assertEquals(
$defaultType,
$gravatar->generateGravatarLink(),
"Setting type as InitialsAvatar should not change gravatar link as it's not supported."
);
}

public function testSetTypeGravatar(): void
{
$gravatar = new Gravatar('user@example.com');
$gravatar->setType(LarvatarTypes::Gravatar);
$this->assertEquals(
'https://www.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af?d=&s=100',
$gravatar->generateGravatarLink()
);
}

public function testSetTypeMP(): void
{
$gravatar = new Gravatar('user@example.com');
$gravatar->setType(LarvatarTypes::mp);
$this->assertEquals(
'https://www.gravatar.com/avatar/b58996c504c5638798eb6b511e6f49af?d=mp&f=y&s=100',
$gravatar->generateGravatarLink()
);
}
}
46 changes: 45 additions & 1 deletion tests/LarvatarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,48 @@ public function testCreateRobohash(): void
);
}

}
/**
* testSetSize method
*
* This test ensures that the setSize method in the Larvatar class works correctly.
*/
public function testSetSize(): void
{
$larvatar = new Larvatar('Test Name', 'test@example.com', LarvatarTypes::mp);
$larvatar->setSize(50);
$this->assertEquals(
'<img src="https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mp&f=y&s=50" />',
$larvatar->getImageHTML()
);
}

/**
* testSetSizeWithLargeValue method
*
* This test ensures that the setSize method in the Larvatar class works correctly with large values.
*/
public function testSetSizeWithLargeValue(): void
{
$larvatar = new Larvatar('Test Name', 'test@example.com', LarvatarTypes::mp);
$larvatar->setSize(1000);
$this->assertEquals(
'<img src="https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mp&f=y&s=1000" />',
$larvatar->getImageHTML()
);
}

/**
* testSetSizeWithSmallValue method
*
* This test ensures that the setSize method in the Larvatar class works correctly with small values.
*/
public function testSetSizeWithSmallValue(): void
{
$larvatar = new Larvatar('Test Name', 'test@example.com', LarvatarTypes::mp);
$larvatar->setSize(1);
$this->assertEquals(
'<img src="https://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?d=mp&f=y&s=1" />',
$larvatar->getImageHTML()
);
}
}

0 comments on commit a59c731

Please sign in to comment.