for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace PhpOffice\PhpSpreadsheetTests\Sample;
use PhpOffice\PhpSpreadsheet\Helper\Sample;
use PHPUnit_Framework_TestCase;
class SampleTest extends PHPUnit_Framework_TestCase
{
/**
* @runInSeparateProcess
* @preserveGlobalState disabled
* @dataProvider providerSample
*
* @param mixed $sample
*/
public function testSample($sample)
// Suppress output to console
$this->setOutputCallback(function () {
});
require $sample;
}
public function providerSample()
$skipped = [
'Chart/32_Chart_read_write_PDF.php', // Unfortunately JpGraph is not up to date for latest PHP and raise many warnings
'Chart/32_Chart_read_write_HTML.php', // idem
];
// Unfortunately some tests are too long be ran with code-coverage
// analysis on Travis, so we need to exclude them
global $argv;
global
Instead of relying on global state, we recommend one of these alternatives:
function myFunction($a, $b) { // Do something }
class MyClass { private $a; private $b; public function __construct($a, $b) { $this->a = $a; $this->b = $b; } public function myFunction() { // Do something } }
if (in_array('--coverage-clover', $argv)) {
$tooLongToBeCovered = [
'Basic/06_Largescale.php',
'Basic/13_CalculationCyclicFormulae.php',
$skipped = array_merge($skipped, $tooLongToBeCovered);
$helper = new Sample();
$result = [];
foreach ($helper->getSamples() as $samples) {
foreach ($samples as $sample) {
$samples
string
if (!in_array($sample, $skipped)) {
$file = '../samples/' . $sample;
$result[] = [$file];
return $result;
Instead of relying on
global
state, we recommend one of these alternatives:1. Pass all data via parameters
2. Create a class that maintains your state