mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
Don't break people's code just because they don't have Composer
This commit is contained in:
@@ -1,20 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// This file should not be used at all! It purely exists to reduce the
|
// This file should not be used at all! Instead, please use Composer's autoload.
|
||||||
// maintenance burden for existing code using this repo.
|
// It purely exists to reduce the maintenance burden for existing code using
|
||||||
|
// this repository.
|
||||||
|
|
||||||
// Check if people used Composer to include this project in theirs
|
// Check if people used Composer to include this project in theirs
|
||||||
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
|
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
|
||||||
die(
|
require __DIR__ . '/src/extensions/DatatypeTrait.php';
|
||||||
"Please run `composer dump-autoload` to build the autoloader.\n\n" .
|
require __DIR__ . '/src/Csv.php';
|
||||||
"Actually, you should consider not including/requiring this file \n" .
|
} else {
|
||||||
" " . __FILE__ . "\n" .
|
require __DIR__ . '/vendor/autoload.php';
|
||||||
"Just run `composer require parsecsv/php-parsecsv` and look at the \n" .
|
|
||||||
"'examples' directory of this repository."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require __DIR__ . '/vendor/autoload.php';
|
|
||||||
|
|
||||||
// This wrapper class should not be used by new projects. Please look at the
|
// This wrapper class should not be used by new projects. Please look at the
|
||||||
// examples to find the up-to-date way of using this repo.
|
// examples to find the up-to-date way of using this repo.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ParseCsv;
|
namespace ParseCsv;
|
||||||
|
|
||||||
use ParseCsv\extensions\DatatypeTrait;
|
use ParseCsv\extensions\DatatypeTrait;
|
||||||
|
|||||||
28
tests/methods/OldRequireTest.php
Normal file
28
tests/methods/OldRequireTest.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace ParseCsv\tests\methods;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
class OldRequireTest extends TestCase {
|
||||||
|
|
||||||
|
protected function setUp() {
|
||||||
|
rename('vendor/autoload.php', '__autoload');
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function tearDown() {
|
||||||
|
rename('__autoload', 'vendor/autoload.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess because download.php uses header()
|
||||||
|
*/
|
||||||
|
public function testOldLibWithoutComposer() {
|
||||||
|
|
||||||
|
file_put_contents('__eval.php', '<?php require "parsecsv.lib.php"; new \ParseCsv\Csv;');
|
||||||
|
exec("php __eval.php", $output, $return_var);
|
||||||
|
unlink('__eval.php');
|
||||||
|
$this->assertEquals($output, []);
|
||||||
|
$this->assertEquals(0, $return_var);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user