SplineTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Test\CpChart;
  3. use Codeception\Test\Unit;
  4. use CpChart\Data;
  5. use CpChart\Image;
  6. use UnitTester;
  7. class SplineTest extends Unit
  8. {
  9. /**
  10. * @var UnitTester
  11. */
  12. protected $tester;
  13. public function testChartRender()
  14. {
  15. $data = new Data();
  16. $data->addPoints([], "Serie1");
  17. $image = new Image(700, 230, $data);
  18. $image->setShadow(
  19. true,
  20. ["X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 20]
  21. );
  22. $firstCoordinates = [[40, 80], [280, 60], [340, 166], [590, 120]];
  23. $fistSplineSettings = ["R" => 255, "G" => 255, "B" => 255, "ShowControl" => true];
  24. $image->drawSpline($firstCoordinates, $fistSplineSettings);
  25. $secondCoordinates = [[250, 50], [250, 180], [350, 180], [350, 50]];
  26. $secondSplineSettings = [
  27. "R" => 255,
  28. "G" => 255,
  29. "B" => 255,
  30. "ShowControl" => true,
  31. "Ticks" => 4
  32. ];
  33. $image->drawSpline($secondCoordinates, $secondSplineSettings);
  34. $filename = $this->tester->getOutputPathForChart('drawSpline.png');
  35. $image->render($filename);
  36. $image->stroke();
  37. $this->tester->seeFileFound($filename);
  38. }
  39. }