ProgressTest.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Test\CpChart;
  3. use Codeception\Test\Unit;
  4. use CpChart\Image;
  5. use UnitTester;
  6. class ProgressTest extends Unit
  7. {
  8. /**
  9. * @var UnitTester
  10. */
  11. protected $tester;
  12. public function testChartRender()
  13. {
  14. $image = new Image(700, 250);
  15. $image->setShadow(true, ["X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20]);
  16. /* Left Red bar */
  17. $progressOptions = ["R" => 209, "G" => 31, "B" => 27, "Surrounding" => 20, "BoxBorderR" => 0, "BoxBorderG" => 0, "BoxBorderB" => 0, "BoxBackR" => 255, "BoxBackG" => 255, "BoxBackB" => 255, "RFade" => 206, "GFade" => 133, "BFade" => 30, "ShowLabel" => true];
  18. $image->drawProgress(40, 60, 77, $progressOptions);
  19. $progressOptions = ["Width" => 165, "R" => 209, "G" => 125, "B" => 27, "Surrounding" => 20, "BoxBorderR" => 0, "BoxBorderG" => 0, "BoxBorderB" => 0, "BoxBackR" => 255, "BoxBackG" => 255, "BoxBackB" => 255, "NoAngle" => true, "ShowLabel" => true, "LabelPos" => LABEL_POS_RIGHT];
  20. $image->drawProgress(40, 100, 50, $progressOptions);
  21. $progressOptions = ["Width" => 165, "R" => 209, "G" => 198, "B" => 27, "Surrounding" => 20, "BoxBorderR" => 0, "BoxBorderG" => 0, "BoxBorderB" => 0, "BoxBackR" => 255, "BoxBackG" => 255, "BoxBackB" => 255, "ShowLabel" => true, "LabelPos" => LABEL_POS_LEFT];
  22. $image->drawProgress(75, 140, 25, $progressOptions);
  23. $progressOptions = ["Width" => 400, "R" => 134, "G" => 209, "B" => 27, "Surrounding" => 20, "BoxBorderR" => 0, "BoxBorderG" => 0, "BoxBorderB" => 0, "BoxBackR" => 255, "BoxBackG" => 255, "BoxBackB" => 255, "RFade" => 206, "GFade" => 133, "BFade" => 30, "ShowLabel" => true, "LabelPos" => LABEL_POS_CENTER];
  24. $image->drawProgress(40, 180, 80, $progressOptions);
  25. $progressOptions = ["Width" => 20, "Height" => 150, "R" => 209, "G" => 31, "B" => 27, "Surrounding" => 20, "BoxBorderR" => 0, "BoxBorderG" => 0, "BoxBorderB" => 0, "BoxBackR" => 255, "BoxBackG" => 255, "BoxBackB" => 255, "RFade" => 206, "GFade" => 133, "BFade" => 30, "ShowLabel" => true, "Orientation" => ORIENTATION_VERTICAL, "LabelPos" => LABEL_POS_BOTTOM];
  26. $image->drawProgress(500, 200, 77, $progressOptions);
  27. $progressOptions = ["Width" => 20, "Height" => 150, "R" => 209, "G" => 125, "B" => 27, "Surrounding" => 20, "BoxBorderR" => 0, "BoxBorderG" => 0, "BoxBorderB" => 0, "BoxBackR" => 255, "BoxBackG" => 255, "BoxBackB" => 255, "NoAngle" => true, "ShowLabel" => true, "Orientation" => ORIENTATION_VERTICAL, "LabelPos" => LABEL_POS_TOP];
  28. $image->drawProgress(540, 200, 50, $progressOptions);
  29. $progressOptions = ["Width" => 20, "Height" => 150, "R" => 209, "G" => 198, "B" => 27, "Surrounding" => 20, "BoxBorderR" => 0, "BoxBorderG" => 0, "BoxBorderB" => 0, "BoxBackR" => 255, "BoxBackG" => 255, "BoxBackB" => 255, "ShowLabel" => true, "Orientation" => ORIENTATION_VERTICAL, "LabelPos" => LABEL_POS_INSIDE];
  30. $image->drawProgress(580, 200, 25, $progressOptions);
  31. $progressOptions = ["Width" => 20, "Height" => 150, "R" => 134, "G" => 209, "B" => 27, "Surrounding" => 20, "BoxBorderR" => 0, "BoxBorderG" => 0, "BoxBorderB" => 0, "BoxBackR" => 255, "BoxBackG" => 255, "BoxBackB" => 255, "RFade" => 206, "GFade" => 133, "BFade" => 30, "ShowLabel" => true, "Orientation" => ORIENTATION_VERTICAL, "LabelPos" => LABEL_POS_CENTER];
  32. $image->drawProgress(620, 200, 80, $progressOptions);
  33. $filename = $this->tester->getOutputPathForChart('drawProgress.png');
  34. $image->render($filename);
  35. $image->stroke();
  36. $this->tester->seeFileFound($filename);
  37. }
  38. }