public function test_process_command() { $co = new command(array('C', '20', '4')); //create a canvas $result = $co->process_command(); $this->assertSame($result, $co->process_command()); //draw a line $result = $co->process_command(array('L', '1', '2', '6', '2')); $this->assertSame($result, $co->process_command(array('L', '1', '2', '6', '2'))); //draw a rectangle $result = $co->process_command(array('R', '1', '1', '6', '4')); $this->assertSame($result, $co->process_command(array('L', '1', '2', '6', '2'))); }
case 'B': if (!$this->canvas->get_canvas_state()) { $messages->set_message('line-error-1'); } elseif (count($this->command_array) == 4) { $command = $this->command_array; $this->canvas->bucket_fill(array($command[1], $command[2]), $command[3]); $messages->set_message('general-ok-0'); } else { $messages->set_message('general-error-0'); } break; //Restart the app //Restart the app case 'Q': $messages->set_message('general-ok-0'); $messages->is_reload(); break; default: break; } } else { return false; } return $this->canvas->get_canvas_string($messages) . '<br/>' . $messages->get_current_message(); } } if (isset($_GET['command'])) { //Initialization of the object with the params given by the ajax call (GET). $obj_command = new command(explode(' ', trim(preg_replace('/\\s+/', ' ', $_GET['command']))), $_GET['canvas']); echo $obj_command->process_command(); }