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

PHPUnit_Framework_TestCase not found #727

Closed
AnzeDspot opened this issue Feb 3, 2017 · 2 comments
Closed

PHPUnit_Framework_TestCase not found #727

AnzeDspot opened this issue Feb 3, 2017 · 2 comments
Labels

Comments

@AnzeDspot
Copy link
Contributor

Following documentation for creating functional tests with Phalcon and Incubator error in the title is thrown and can be fixed by changing namespace of the PHPUnit TestCase.

https://docs.phalconphp.com/en/3.0.0/reference/unit-testing.html

Currently Phalcon Incubator UnitTestCase extends PHPUnit TestCase in following way:

use PHPUnit_Framework_TestCase as TestCase;

which does not work, since it's not loaded in that way anymore, however

use PHPUnit\Framework\TestCase as TestCase;

works as supposed.

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in /my_app_folder/vendor/phalcon/incubator/Library/Phalcon/Test/UnitTestCase.php on line 36

Looking at composer autoloader it only contains this regarding the PHPUnit TestCase and is loaded that way only.

  • 'PHPUnit\Framework\TestCase' => $vendorDir . '/phpunit/phpunit/src/Framework/TestCase.php',

and according to composer it's loaded that way by default:

name     : phpunit/phpunit
descrip. : The PHP Unit Testing framework.
keywords : phpunit, testing, xunit
versions : * 6.0.0
type     : library
license  : BSD 3-clause "New" or "Revised" License (BSD-3-Clause) (OSI approved) https://spdx.org/licenses/BSD-3-Clause.html#licenseText
source   : [git] https://github.com/sebastianbergmann/phpunit.git 9d0c024d2099531442d862b66b0ad7cf35ed8e78
dist     : [zip] https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9d0c024d2099531442d862b66b0ad7cf35ed8e78 9d0c024d2099531442d862b66b0ad7cf35ed8e78
names    : phpunit/phpunit

autoload
classmap
src/

TestHelper.php is my bootstrap and looks like this:

<?php

use Phalcon\Di;
use Phalcon\Di\FactoryDefault;
use Phalcon\Loader;

ini_set("display_errors", 1);
error_reporting(E_ALL);
define("ROOT_PATH", __DIR__);
set_include_path(
    ROOT_PATH . PATH_SEPARATOR . get_include_path()
);

// Required for phalcon/incubator
include __DIR__ . "/../../vendor/autoload.php"; // 2x /../../ is ok since it's in subfolder, autloader is loaded at this point

// Use the application autoloader to autoload the classes
// Autoload the dependencies found in composer
$loader = new Loader();
$loader->registerDirs([ROOT_PATH,]);
$loader->registerNamespaces([
    'MYAPP\\Tests' => __DIR__
]);

$loader->register();
$di = new FactoryDefault();

Di::reset();

// Add any needed services to the DI here
Di::setDefault($di);

Details

php --ri phalcon

phalcon

Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 3.0.3
Build Date => Jan 24 2017 16:09:18
Powered by Zephir => Version 0.9.5a-dev

Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.events => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.orm.column_renaming => On => On
phalcon.orm.not_null_validations => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.enable_literals => On => On
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.ignore_unknown_columns => Off => Off

Composer version 1.3.2 2017-01-27 18:23:41

name     : phalcon/incubator
descrip. : Adapters, prototypes or functionality that can be potentially incorporated to the C-framework.
keywords : framework, incubator, phalcon
versions : * v3.0.3
type     : library
license  : BSD 3-clause "New" or "Revised" License (BSD-3-Clause) (OSI approved) https://spdx.org/licenses/BSD-3-Clause.html#licenseText
source   : [git] https://github.com/phalcon/incubator.git d34e982db3c754712328f5bfff69611fd9a675f1
dist     : [zip] https://api.github.com/repos/phalcon/incubator/zipball/d34e982db3c754712328f5bfff69611fd9a675f1 d34e982db3c754712328f5bfff69611fd9a675f1
names    : phalcon/incubator
php -v

PHP 7.0.15 (cli) (built: Jan 24 2017 16:07:08) ( ZTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.15, Copyright (c) 1999-2017, by Zend Technologies
@AnzeDspot
Copy link
Contributor Author

Hello,

I can prepare merge request for this if you want.

@sergeyklay
Copy link
Contributor

It will be fine!

AnzeDspot added a commit to AnzeDspot/incubator that referenced this issue Feb 9, 2017
AnzeDspot added a commit to AnzeDspot/incubator that referenced this issue Feb 10, 2017
AnzeDspot added a commit to AnzeDspot/incubator that referenced this issue Feb 10, 2017
AnzeDspot added a commit to AnzeDspot/incubator that referenced this issue Feb 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants