Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make pake phar-able, make tests use modern phpunit #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
19 changes: 8 additions & 11 deletions bin/pake
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,38 @@
function _pake_bin_init()
{
$loaded = false;
$_path = dirname(__FILE__); // php 5.2 compatibility

if (file_exists($_path.'/../../../../composer.json')) {
if (file_exists('composer.json')) {
// looks like we are installed as dependency via composer
$project_dir = realpath($_path . '/../../../..');

$data = json_decode(file_get_contents($project_dir . DIRECTORY_SEPARATOR . 'composer.json'), true);
$data = json_decode(file_get_contents('composer.json'), true);

if (isset($data['config']['vendor-dir'])) {
$vendor_dir = $data['config']['vendor-dir'];
} else {
$vendor_dir = 'vendor';
}

$autoload_file = $project_dir . '/' . $vendor_dir . '/autoload.php';
$autoload_file = $vendor_dir . '/autoload.php';

if (file_exists($autoload_file)) {
require_once $autoload_file;
require_once($autoload_file);
$loaded = true;
}
}

if (!$loaded and is_dir($_path . '/../vendor') and file_exists($_path . '/../vendor/autoload.php')) {
if (!$loaded and is_dir($__DIR__. '/../vendor') and file_exists($__DIR__. '/../vendor/autoload.php')) {
// looks like we are in composer dev-environment
require_once realpath($_path . '/..').'/vendor/autoload.php';
require_once(realpath($__DIR__. '/..').'/vendor/autoload.php');
$loaded = true;
}

if (!$loaded) {
// fallback to custom autoloader
require_once realpath($_path . '/..').'/lib/pake/autoload.php';
require_once('../lib/pake/autoload.php');
$loaded = true;
}

require_once realpath($_path . '/..').'/lib/pake/cli_init.php';
require_once('../lib/pake/cli_init.php');

$retval = pakeApp::get_instance()->run();

Expand Down
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"ext-mbstring": "*"
},
"require-dev": {
"simpletest/simpletest": "1.1.*"
"simpletest/simpletest": "1.1.*",
"phpunit/phpunit": "^7.5.18"
},
"suggest": {
"ext-bz2": "*",
Expand All @@ -43,7 +44,12 @@
"simpletest/simpletest": "1.1.*"
},
"autoload": {
"files": ["lib/pake/autoload.php"]
"classmap": ["lib/pake/"],
"files": ["lib/pake/pakeFunction.php"]
},
"autoload-dev": {
"classmap": ["tests/", "lib/pake/"],
"files": ["lib/pake/pakeFunction.php"]
},
"bin": ["bin/pake"]
}
Binary file added pake.phar
Binary file not shown.
Empty file modified pakefile.php
100644 → 100755
Empty file.
Binary file added phar-composer-1.1.0.phar
Binary file not shown.
1 change: 1 addition & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<phpunit colors="true" convertDeprecationsToExceptions="false" bootstrap="tests/autoload.php"/>
102 changes: 0 additions & 102 deletions test/pakeGlobToRegexTest.php

This file was deleted.

91 changes: 0 additions & 91 deletions test/pakePHPDocTest.php

This file was deleted.

8 changes: 5 additions & 3 deletions test/pakeTaskTest.php → tests/PakeTaskTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php
use PHPUnit\Framework\TestCase;

class pakeTaskTest extends UnitTestCase

class PakeTaskTest extends TestCase
{
public function test_abbrev()
public function testAbbrev()
{
$words = array('start', 'stop', 'queue', 'quit');
$result = pakeTask::abbrev($words);
Expand All @@ -17,6 +19,6 @@ public function test_abbrev()
'que' => array('queue'), 'queu' => array('queue'), 'queue' => array('queue'),
'qui' => array('quit'), 'quit' => array('quit')
);
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);
}
}
6 changes: 6 additions & 0 deletions tests/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
include_once __DIR__.'/../vendor/autoload.php';

$classLoader = new \Composer\Autoload\ClassLoader();
$classLoader->addPsr4("Your\\Test\\Namespace\\Here\\", __DIR__, true);
$classLoader->register();
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading