Ejemplo n.º 1
0
 public function test_it_clears_canvas()
 {
     $canvas = new Canvas(3, 2);
     $canvas->markPoint(2, 2);
     $canvas->clear();
     $canvasContent = $canvas->getContent();
     $this->assertEquals(Canvas::POINT_EMPTY, $canvasContent[2][2]);
 }
 public function test_it_draws_requested_horizontal_line()
 {
     $canvas = new Canvas(5, 9);
     $initialContent = $canvas->getContent();
     $args = [4, 2, 3];
     $this->command->draw($canvas, $args);
     $this->assertNotEquals($initialContent, $canvas->getContent());
     $expectedContent = $initialContent;
     for ($i = 2; $i <= 3; ++$i) {
         $expectedContent[$i][4] = Canvas::POINT_MARKED;
     }
     $this->assertEquals($expectedContent, $canvas->getContent());
 }
 public function test_it_draws_requested_vertical_line()
 {
     $canvas = new Canvas(5, 9);
     $initialContent = $canvas->getContent();
     $args = [4, 2, 7];
     $this->command->draw($canvas, $args);
     $this->assertNotEquals($initialContent, $canvas->getContent());
     $expectedContent = $initialContent;
     for ($j = 2; $j <= 7; ++$j) {
         $expectedContent[4][$j] = Canvas::POINT_MARKED;
     }
     $this->assertEquals($expectedContent, $canvas->getContent());
 }
 public function test_it_draws_requested_rectangle()
 {
     $canvas = new Canvas(5, 9);
     $initialContent = $canvas->getContent();
     $args = [2, 3, 4, 7];
     $this->command->draw($canvas, $args);
     $this->assertNotEquals($initialContent, $canvas->getContent());
     $expectedContent = $initialContent;
     for ($i = 2; $i <= 4; ++$i) {
         for ($j = 3; $j <= 7; ++$j) {
             $expectedContent[$i][$j] = Canvas::POINT_MARKED;
         }
     }
     $this->assertEquals($expectedContent, $canvas->getContent());
 }