Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
badraxas committed Jan 23, 2024
1 parent 42135a8 commit 4bef1dc
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/AdsTxt.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class AdsTxt
*/
public function addLine(AbstractAdsTxtLine $line): self
{
if ($this->valid && !empty($line->getError())) {
if ($this->valid && (!empty($line->getError()) || $line instanceof Invalid)) {
$this->valid = false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Lines/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function getRelationship(): string

public function pretty(bool $withComment = true): string
{
$vendor = sprintf('%s, %s, %s', strtolower($this->domain), $this->publisherId, strtolower($this->relationship));
$vendor = sprintf('%s, %s, %s', strtolower($this->domain), $this->publisherId, strtoupper($this->relationship));

if (isset($this->certificationId)) {
$vendor = sprintf('%s, %s', $vendor, $this->certificationId);
Expand Down
4 changes: 2 additions & 2 deletions src/Lines/Variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public function getValue(): mixed
public function pretty(bool $withComment = true): string
{
if (!isset($this->comment)) {
return sprintf('%s=%s', $this->name, $this->value);
return sprintf('%s=%s', strtoupper($this->name), $this->value);
}

return sprintf('%s=%s%s', $this->name, $this->value, $this->comment->pretty($withComment));
return sprintf('%s=%s%s', strtoupper($this->name), $this->value, $this->comment->pretty($withComment));
}
}
4 changes: 2 additions & 2 deletions tests/AdsTxtParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function testParseFromMissingFile(): void

public function testParseFromString(): void
{
$adsTxtString = "# First line of file\n\ngreenadexchange.com, XF436, DIRECT, d75815a79# GreenAd certification ID\ncontact[email protected]";
$adsTxtString = "# First line of file\n\ngreenadexchange.com, XF436, DIRECT, d75815a79# GreenAd certification ID\nCONTACT[email protected]";

$adsTxtReference = (new AdsTxt())
->addLine(new Comment('First line of file'))
Expand Down Expand Up @@ -95,7 +95,7 @@ public function testParseFromString(): void

public function testParseFromStringWithInvalidLines(): void
{
$adsTxtString = "# First line of file\ngreenadexchange.com, XF436, DIRECT, d75815a79, GreenAd certification ID\ncontact[email protected]";
$adsTxtString = "# First line of file\ngreenadexchange.com, XF436, DIRECT, d75815a79, GreenAd certification ID\nCONTACT[email protected]";

$adsTxtReference = (new AdsTxt())
->addLine(new Comment('First line of file'))
Expand Down
2 changes: 1 addition & 1 deletion tests/AdsTxtTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function testAdsTxtOutput(): void
$this->assertEquals('# ads.txt file for example.com:
greenadexchange.com, 12345, DIRECT, d75815a79
blueadexchange.com, XF436, DIRECT
subdomain=divisionone.example.com', $adsTxt->pretty());
SUBDOMAIN=divisionone.example.com', $adsTxt->pretty());
}

public function testDiffMethodReturnsMissingLines(): void
Expand Down
4 changes: 2 additions & 2 deletions tests/Lines/VariableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public function testGetters(): void
public function testVariableOutput(): void
{
$variable = new Variable('contact', '[email protected]');
$this->assertEquals('contact[email protected]', $variable->pretty());
$this->assertEquals('CONTACT[email protected]', $variable->pretty());
}

public function testVariableWithComment(): void
{
$variable = new Variable('contact', '[email protected]', new Comment('a nice comment!'));
$this->assertEquals('contact[email protected]# a nice comment!', $variable->pretty());
$this->assertEquals('CONTACT[email protected]# a nice comment!', $variable->pretty());
}
}

0 comments on commit 4bef1dc

Please sign in to comment.