Skip to content
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

ENH Update AttributesHTML to output alt attribute even if it's empty #11217

Open
wants to merge 2 commits into
base: 5
Choose a base branch
from

Conversation

maxime-rainville
Copy link
Contributor

AttributeHTML want to suppress attributes with falsy values.

When rendering Images and the alt attribute contains a blank string, the attribute should be rendered anyway.

Arguably this should be on ImageManipulation instead, but it seems like an sensible exception to have across the board. I haven't decided yet.

Issue

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original AttributesHTML was only covered by indirect tests of classes using the trait. I decided to add an explicit test.

tests/php/View/AttributesHTMLTest.php Show resolved Hide resolved
class AttributesHTMLTest extends SapphireTest
{

public function singleAttributeProvider(): array
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public function singleAttributeProvider(): array
public function provideGetAttribute(): array

Follow the naming conventions for data providers

];
}

/** @dataProvider singleAttributeProvider */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** @dataProvider singleAttributeProvider */
/**
* @dataProvider provideTestAttribute
*/

/** @dataProvider singleAttributeProvider */
public function testGetAttribute($name, $value, $message): void
{
$dummy = new AttributesHTMLTest\DummyAttributesHTML();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$dummy = new AttributesHTMLTest\DummyAttributesHTML();
$dummy = DummyAttributesHTML();

Import this class. Make this change throughout this file

{
$dummy = new AttributesHTMLTest\DummyAttributesHTML();

$dummy->setAttribute('emptystring', '');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a data provider for this instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAttributesHTML takes all the attributes and combined them into one string.

I'm not trying to test individuals scenarios here. I'm trying to test the scenario where you combined all these attributes together.

tests/php/View/AttributesHTMLTest.php Show resolved Hide resolved
Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good

Copy link
Member

@emteknetnz emteknetnz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHPlinting failure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants