Skip to content

Commit efb9be7

Browse files
committed
test: add unit tests for various chart types in ChartTest.php and update README.md with Codecov badge
1 parent e22d026 commit efb9be7

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
44
[![Tests](https://github.com/bbsnly/chartjs-php/actions/workflows/php.yml/badge.svg)](https://github.com/bbsnly/chartjs-php/actions)
5+
[![codecov](https://codecov.io/gh/bbsnly/chartjs-php/graph/badge.svg?token=MTIBNP8BDT)](https://codecov.io/gh/bbsnly/chartjs-php)
56
[![Total Downloads](https://poser.pugx.org/bbsnly/chartjs-php/d/total.svg)](https://packagist.org/packages/bbsnly/chartjs-php)
67
[![Latest Stable Version](https://poser.pugx.org/bbsnly/chartjs-php/v/stable.svg)](https://packagist.org/packages/bbsnly/chartjs-php)
78
[![License](https://poser.pugx.org/bbsnly/chartjs-php/license.svg)](https://packagist.org/packages/bbsnly/chartjs-php)

tests/ChartTest.php

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22

33
namespace Tests;
44

5+
use Bbsnly\ChartJs\BarChart;
6+
use Bbsnly\ChartJs\BubbleChart;
57
use Bbsnly\ChartJs\Chart;
68
use Bbsnly\ChartJs\Config\Data;
79
use Bbsnly\ChartJs\Config\Dataset;
810
use Bbsnly\ChartJs\Config\Options;
11+
use Bbsnly\ChartJs\DoughnutChart;
12+
use Bbsnly\ChartJs\LineChart;
13+
use Bbsnly\ChartJs\PieChart;
14+
use Bbsnly\ChartJs\PolarAreaChart;
15+
use Bbsnly\ChartJs\RadarChart;
16+
use Bbsnly\ChartJs\ScatterChart;
917

1018
class ChartTest extends TestCase
1119
{
@@ -26,6 +34,78 @@ public function test_can_create_it()
2634
$this->assertInstanceOf(Chart::class, $this->chart);
2735
}
2836

37+
/**
38+
* Test if chart type is correctly set using helper class BarChart.
39+
*/
40+
public function test_can_create_bar_chart()
41+
{
42+
$this->chart = new BarChart;
43+
$this->assertEquals('bar', $this->chart->type);
44+
}
45+
46+
/**
47+
* Test if chart type is correctly set using helper class BubbleChart.
48+
*/
49+
public function test_can_create_bubble_chart()
50+
{
51+
$this->chart = new BubbleChart;
52+
$this->assertEquals('bubble', $this->chart->type);
53+
}
54+
55+
/**
56+
* Test if chart type is correctly set using helper class DoughnutChart.
57+
*/
58+
public function test_can_create_doughnut_chart()
59+
{
60+
$this->chart = new DoughnutChart;
61+
$this->assertEquals('doughnut', $this->chart->type);
62+
}
63+
64+
/**
65+
* Test if chart type is correctly set using helper class LineChart.
66+
*/
67+
public function test_can_create_line_chart()
68+
{
69+
$this->chart = new LineChart;
70+
$this->assertEquals('line', $this->chart->type);
71+
}
72+
73+
/**
74+
* Test if chart type is correctly set using helper class PieChart.
75+
*/
76+
public function test_can_create_pie_chart()
77+
{
78+
$this->chart = new PieChart;
79+
$this->assertEquals('pie', $this->chart->type);
80+
}
81+
82+
/**
83+
* Test if chart type is correctly set using helper class PolarAreaChart.
84+
*/
85+
public function test_can_create_polar_area_chart()
86+
{
87+
$this->chart = new PolarAreaChart;
88+
$this->assertEquals('polarArea', $this->chart->type);
89+
}
90+
91+
/**
92+
* Test if chart type is correctly set using helper class RadarChart.
93+
*/
94+
public function test_can_create_radar_chart()
95+
{
96+
$this->chart = new RadarChart;
97+
$this->assertEquals('radar', $this->chart->type);
98+
}
99+
100+
/**
101+
* Test if chart type is correctly set using helper class ScatterChart.
102+
*/
103+
public function test_can_create_scatter_chart()
104+
{
105+
$this->chart = new ScatterChart;
106+
$this->assertEquals('scatter', $this->chart->type);
107+
}
108+
29109
/**
30110
* Test if the chart is responsive.
31111
*

0 commit comments

Comments
 (0)