Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
phpunit.xml
.phpunit.result.cache
composer.lock

composer.phar
Expand Down
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,20 @@ matrix:
fast_finish: true
include:
# Test with lowest dependencies
- php: 7.2
- php: 8.0
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak"

# Test the latest stable release
- php: 7.2
- php: 8.1
env: COVERAGE=true TEST_COMMAND="./vendor/bin/simple-phpunit --coverage-text --coverage-clover=coverage.clover"
- php: 7.3
- php: 7.4
- php: 8.2

# Force some major versions of Symfony
- php: 7.2
- php: 8.1
env: DEPENDENCIES="dunglas/symfony-lock:^4"

# Latest commit to master
- php: 7.2
- php: 8.2
env: STABILITY="dev"

allow_failures:
Expand Down
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

## [Unreleased]

TBD

* Fix deprecated Tests for PHPUnit 10

### [1.7.0] - 2020-01-12

Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/ObHighchartsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ObHighchartsExtension extends Extension
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
public function load(array $configs, ContainerBuilder $container): void
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
Expand Down
38 changes: 26 additions & 12 deletions Tests/BundleInitializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,44 @@

namespace Ob\HighchartsBundle\Tests;

use Nyholm\BundleTest\BaseBundleTestCase;
use Nyholm\BundleTest\TestKernel;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Ob\HighchartsBundle\ObHighchartsBundle;
use Ob\HighchartsBundle\Twig\HighchartsExtension;
use Symfony\Component\HttpKernel\KernelInterface;

class BundleInitializationTest extends BaseBundleTestCase
class BundleInitializationTest extends KernelTestCase
{
protected function getBundleClass()
protected static function getKernelClass(): string
{
return ObHighchartsBundle::class;
return TestKernel::class;
}

public function testInitBundle()
protected static function createKernel(array $options = []): KernelInterface
{
// Create a new Kernel
$kernel = $this->createKernel();
/**
* @var TestKernel $kernel
*/
$kernel = parent::createKernel($options);
$kernel->addTestBundle(ObHighchartsBundle::class);
$kernel->addTestConfig(__DIR__.'/Resources/services.yml');
$kernel->addTestConfig(__DIR__.'/Resources/config.yml');
$kernel->handleOptions($options);

return $kernel;
}

// Add some configuration
$kernel->addConfigFile(__DIR__.'/Resources/services.yml');
protected function getBundleClass(): string
{
return ObHighchartsBundle::class;
}

// Boot the kernel.
$this->bootKernel();
public function testInitBundle(): void
{
$kernel = self::bootKernel();

// Get the container
$container = $this->getContainer();
$container = $kernel->getContainer();

// Test if you services exists
$this->assertTrue($container->has('test.ob_highcharts.twig.highcharts_extension'));
Expand Down
4 changes: 2 additions & 2 deletions Tests/Highcharts/ColorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class ColorsTest extends TestCase
/**
* Series output
*/
public function testColors()
public function testColors(): void
{
$linechart = new Highchart();

$colors = array('#FF0000', '#00FF00', '#0000FF');
$linechart->colors($colors);
$this->assertRegExp('/colors: \[\["#FF0000","#00FF00","#0000FF"\]\]/', $linechart->render());
$this->assertMatchesRegularExpression('/colors: \[\["#FF0000","#00FF00","#0000FF"\]\]/', $linechart->render());
}
}
42 changes: 21 additions & 21 deletions Tests/Highcharts/ExportingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Ob\HighchartsBundle\Tests\Highcharts;

use Ob\HighchartsBundle\Highcharts\Highchart;
use Zend\Json\Expr;
use Laminas\Json\Expr;
use PHPUnit\Framework\TestCase;

/**
Expand All @@ -14,21 +14,21 @@ class ExportingTest extends TestCase
/**
* buttons option
*/
public function testButtons()
public function testButtons(): void
{
$chart = new Highchart();

// align option (string - left/center/right)
$chart->exporting->buttons(array('exportButton' => array('align' => 'center')));
$this->assertRegExp('/exporting: \{"buttons":\{"exportButton":\{"align":"center"\}\}\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"buttons":\{"exportButton":\{"align":"center"\}\}\}/', $chart->render());
$chart->exporting->buttons(array('printButton' => array('align' => 'center')));
$this->assertRegExp('/exporting: \{"buttons":\{"printButton":\{"align":"center"\}\}\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"buttons":\{"printButton":\{"align":"center"\}\}\}/', $chart->render());

// backgroundColor option
$chart->exporting->buttons(array('exportButton' => array('backgroundColor' => 'blue')));
$this->assertRegExp('/exporting: \{"buttons":\{"exportButton":\{"backgroundColor":"blue"\}\}\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"buttons":\{"exportButton":\{"backgroundColor":"blue"\}\}\}/', $chart->render());
$chart->exporting->buttons(array('printButton' => array('backgroundColor' => 'blue')));
$this->assertRegExp('/exporting: \{"buttons":\{"printButton":\{"backgroundColor":"blue"\}\}\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"buttons":\{"printButton":\{"backgroundColor":"blue"\}\}\}/', $chart->render());

// borderColor option
// borderRadius option
Expand Down Expand Up @@ -59,7 +59,7 @@ public function testButtons()
/**
* chartOptions option
*/
public function testChartOptions()
public function testChartOptions(): void
{
$this->markTestIncomplete(
'This test has not been implemented yet.'
Expand All @@ -69,70 +69,70 @@ public function testChartOptions()
/**
* enabled option (true/false)
*/
public function testEnabled()
public function testEnabled(): void
{
$chart = new Highchart();

$chart->exporting->enabled(true);
$this->assertRegExp('/exporting: \{"enabled":true\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"enabled":true\}/', $chart->render());

$chart->exporting->enabled(false);
$this->assertRegExp('/exporting: \{"enabled":false\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"enabled":false\}/', $chart->render());
}

/**
* filename option (string)
*/
public function testFilename()
public function testFilename(): void
{
$chart = new Highchart();
$chart->exporting->filename("graph");

$this->assertRegExp('/exporting: \{"filename":"graph"\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"filename":"graph"\}/', $chart->render());
}

/**
* type option (string - image/png, image/jpeg, application/pdf or image/svg+xml)
*/
public function testType()
public function testType(): void
{
$chart = new Highchart();

// We need to use a Json Expr or else the slashes are escaped
$chart->exporting->type(new Expr('"image/png"'));
$this->assertRegExp('/exporting: \{"type":"image\/png"\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"type":"image\/png"\}/', $chart->render());

$chart->exporting->type(new Expr('"image/jpeg"'));
$this->assertRegExp('/exporting: \{"type":"image\/jpeg"\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"type":"image\/jpeg"\}/', $chart->render());

$chart->exporting->type(new Expr('"application/pdf"'));
$this->assertRegExp('/exporting: \{"type":"application\/pdf"\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"type":"application\/pdf"\}/', $chart->render());

$chart->exporting->type(new Expr('"image/svg+xml"'));
$this->assertRegExp('/exporting: \{"type":"image\/svg\+xml"\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"type":"image\/svg\+xml"\}/', $chart->render());
}

/**
* url option (string)
*/
public function testUrl()
public function testUrl(): void
{
$chart = new Highchart();

// We need to use a Json Expr or else the slashes are escaped
$chart->exporting->url(new Expr('"http://www.google.com"'));

$this->assertRegExp('/exporting: \{"url":"http:\/\/www.google.com"\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"url":"http:\/\/www.google.com"\}/', $chart->render());
}

/**
* width option (integer - width in px)
*/
public function testWidth()
public function testWidth(): void
{
$chart = new Highchart();
$chart->exporting->width(300);

$this->assertRegExp('/exporting: \{"width":300\}/', $chart->render());
$this->assertMatchesRegularExpression('/exporting: \{"width":300\}/', $chart->render());
}
}
10 changes: 5 additions & 5 deletions Tests/Highcharts/GlobalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ class GlobalTest extends TestCase
/**
* useUTC option (true/false)
*/
public function testGlobal()
public function testGlobal(): void
{
$chart = new Highchart();

$chart->global->useUTC("true");
$this->assertRegExp('/global: \{"useUTC":"true"\}/', $chart->render());
$this->assertMatchesRegularExpression('/global: \{"useUTC":"true"\}/', $chart->render());

$chart->global->useUTC("false");
$this->assertRegExp('/global: \{"useUTC":"false"\}/', $chart->render());
$this->assertMatchesRegularExpression('/global: \{"useUTC":"false"\}/', $chart->render());
}

/**
* noData option (string)
*/
public function testLang()
public function testLang(): void
{
$chart = new Highchart();

$chart->lang->noData("No data to display");
$this->assertRegExp('/"noData":"No data to display"/', $chart->render());
$this->assertMatchesRegularExpression('/"noData":"No data to display"/', $chart->render());
}
}
18 changes: 9 additions & 9 deletions Tests/Highcharts/HighchartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class HighchartTest extends TestCase
/**
* Render chart using jQuery
*/
public function testJquery()
public function testJquery(): void
{
$chart = new Highchart();
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/\$\(function\s?\(\)\s?\{\n?\r?\s*var chart = new Highcharts.Chart\(\{\n?\r?\s*\}\);\n?\r?\s*\}\);/',
$chart->render()
);
Expand All @@ -25,10 +25,10 @@ public function testJquery()
/**
* Render chart without library wrapper
*/
public function testNoEngine()
public function testNoEngine(): void
{
$chart = new Highchart();
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/var chart = new Highcharts.Chart\(\{\n?\r?\s*\}\);/',
$chart->render(null)
);
Expand All @@ -37,10 +37,10 @@ public function testNoEngine()
/**
* Render chart using Mootools
*/
public function testMooTools()
public function testMooTools(): void
{
$chart = new Highchart();
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/window.addEvent\(\'domready\', function\s?\(\)\s?\{\r?\n?\s*var chart = new Highcharts.Chart\(\{\n?\r?\s*\}\);\n?\r?\s*\}\);/',
$chart->render('mootools')
);
Expand All @@ -49,7 +49,7 @@ public function testMooTools()
/**
* Magic getters and setters
*/
public function testSetGet()
public function testSetGet(): void
{
$chart = new Highchart();

Expand All @@ -63,12 +63,12 @@ public function testSetGet()
/**
* Look for that mean trailing comma
*/
public function testIeFriendliness()
public function testIeFriendliness(): void
{
$chart = new Highchart();

$chart->chart->setTitle('Am I IE friendly yet?');
$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/\}(?<!,)\n?\r?\s*\}\);\n?\r?\s*\}\);/',
$chart->render()
);
Expand Down
12 changes: 6 additions & 6 deletions Tests/Highcharts/LangTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class LangTest extends TestCase
/**
* Set localized month names
*/
public function testMonths()
public function testMonths(): void
{
$chart = new Highchart();
$chart->lang->months(array('Janvier', 'Fevrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Aout', 'Septembre', 'Octobre', 'Novembre', 'Decembre'));

$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/lang: \{"months":\["Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre"\]\}/',
$chart->render()
);
Expand All @@ -27,12 +27,12 @@ public function testMonths()
/**
* Set abbreviated localized month names
*/
public function testShortMonths()
public function testShortMonths(): void
{
$chart = new Highchart();
$chart->lang->shortMonths(array('Jan', 'Fev', 'Mars', 'Avril', 'Mai', 'Juin', 'Juil', 'Aout', 'Sept', 'Oct', 'Nov', 'Dec'));

$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/lang: \{"shortMonths":\["Jan","Fev","Mars","Avril","Mai","Juin","Juil","Aout","Sept","Oct","Nov","Dec"\]\}/',
$chart->render()
);
Expand All @@ -41,12 +41,12 @@ public function testShortMonths()
/**
* Set localized weekday names
*/
public function testWeekDays()
public function testWeekDays(): void
{
$chart = new Highchart();
$chart->lang->weekdays(array('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'));

$this->assertRegExp(
$this->assertMatchesRegularExpression(
'/lang: \{"weekdays":\["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"\]\}/',
$chart->render()
);
Expand Down
Loading