Skip to content

Commit

Permalink
Fix mess detections
Browse files Browse the repository at this point in the history
  • Loading branch information
terremoth committed Feb 21, 2024
1 parent d94038d commit 2a1299c
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 20 deletions.
3 changes: 2 additions & 1 deletion demos/drawing.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,5 @@
echo $output_filtered($rectangle->draw($doubleBorder));
} catch (SideLessThanOneException $e) {
echo $output_filtered($e->getMessage());
}
}//end try

8 changes: 5 additions & 3 deletions src/BoxDesigner/Rectangle.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,14 @@ public function draw(LineAsciiCharsInterface|null $lineDrawerProvider = null): s
if ($column == 0 || $column == ($columns - 1)) {
$rectangleBox .= $lineDrawerProvider->verticalLine();
} else {
$add = ' ';

if ($this->content != ' ' && $contentCharPosition < $contentLength) {
$rectangleBox .= $this->content[$contentCharPosition];
$add = $this->content[$contentCharPosition];
$contentCharPosition++;
} else {
$rectangleBox .= ' ';
}

$rectangleBox .= $add;
}
}

Expand Down
12 changes: 6 additions & 6 deletions tests/BoxDesigner/DoubleLineBorderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ final class DoubleLineBorderTest extends TestCase
public function testLinesOutput(): void
{
$border = new DoubleLineBorder();
TestCase::assertEquals('', $border->topLeft());
TestCase::assertEquals('', $border->topRight());
TestCase::assertEquals('', $border->bottomLeft());
TestCase::assertEquals('', $border->bottomRight());
TestCase::assertEquals('', $border->horizontalLine());
TestCase::assertEquals('', $border->verticalLine());
self::assertEquals('', $border->topLeft());
self::assertEquals('', $border->topRight());
self::assertEquals('', $border->bottomLeft());
self::assertEquals('', $border->bottomRight());
self::assertEquals('', $border->horizontalLine());
self::assertEquals('', $border->verticalLine());
}
}
4 changes: 2 additions & 2 deletions tests/BoxDesigner/SingleBorderBoxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#[CoversClass(Rectangle::class)]
#[UsesClass(SingleLineBorder::class)]
final class SingleLineRectanglesDrawingTest extends TestCase
final class SingleBorderBoxTest extends TestCase
{
/**
* @return array[]
Expand Down Expand Up @@ -82,6 +82,6 @@ public static function boxValuesProvider(): array
public function testSidesLessThanOne(string $box, int $rows, int $columns): void
{
$rectangle = new Rectangle($rows, $columns);
$this->assertEquals($box, $rectangle->draw());
self::assertEquals($box, $rectangle->draw());
}
}
4 changes: 2 additions & 2 deletions tests/BoxDesigner/SingleBorderWithContentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

#[CoversClass(Rectangle::class)]
#[UsesClass(SingleLineBorder::class)]
final class SingleLineRectangleDrawingWithContentTest extends TestCase
final class SingleBorderWithContentTest extends TestCase
{
/**
* @return array[]
Expand Down Expand Up @@ -80,6 +80,6 @@ public function testSidesLessThanOne(string $box, int $rows, int $columns, strin
$rectangle = new Rectangle($rows, $columns);
$rectangle->setContentInsideBox($content);
$draw = $rectangle->draw();
$this->assertEquals($box, $draw);
self::assertEquals($box, $draw);
}
}
12 changes: 6 additions & 6 deletions tests/BoxDesigner/SingleLineBorderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ final class SingleLineBorderTest extends TestCase
public function testLinesOutput(): void
{
$border = new SingleLineBorder();
TestCase::assertEquals('', $border->topLeft());
TestCase::assertEquals('', $border->topRight());
TestCase::assertEquals('', $border->bottomLeft());
TestCase::assertEquals('', $border->bottomRight());
TestCase::assertEquals('', $border->horizontalLine());
TestCase::assertEquals('', $border->verticalLine());
self::assertEquals('', $border->topLeft());
self::assertEquals('', $border->topRight());
self::assertEquals('', $border->bottomLeft());
self::assertEquals('', $border->bottomRight());
self::assertEquals('', $border->horizontalLine());
self::assertEquals('', $border->verticalLine());
}
}

0 comments on commit 2a1299c

Please sign in to comment.