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

PHPStorm variables ${TESTED_CLASS_RELATIVE_PATH} and ${TESTED_CLASS} #27

Open
SendiMyrkr opened this issue Jun 13, 2017 · 2 comments
Open

Comments

@SendiMyrkr
Copy link

What about add variables for template which contains path to tested class and full class name? When you make unit tests right, you should need only class which you test and don't use autoloaders. Am I right?

so template like this:

<?php
#parse("PHP File Header.php")

#if (${NAMESPACE})
namespace ${NAMESPACE};
#end

use Tester\Assert;
use Tester\TestCase;
#if (${TESTED_CLASS})
use ${TESTED_CLASS};
#end

#if (${TESTED_CLASS_FILE_RELATIVE_PATH})
require_once __DIR__ . '/${TESTED_CLASS_FILE_RELATIVE_PATH}';
#end

#if (${BOOTSTRAP_RELATIVE_PATH})
require_once __DIR__ . '/${BOOTSTRAP_RELATIVE_PATH}';
#end



/**
 * @testCase
 */
class ${NAME} extends TestCase
{

}


(new ${NAME}())->run();

will generate test class like this one

<?php
/**
 * @author ...
 */

namespace SomeNSTests;

use Tester\Assert;
use Tester\TestCase;
use ClassNamespace\ClassName;

require_once __DIR__ . '/../../../bootstrap.php';
require_once __DIR__ . '/../../../../path/to/class/file.php';


/**
 * @testCase
 */
class ClassNameTest extends TestCase
{

}


(new ClassNameTest())->run();

Do you think it's good for something?

@jiripudil
Copy link
Collaborator

jiripudil commented Jun 13, 2017

tbh it doesn't make that much sense to me, usually you want to mock dependencies or the tested class may use other classes internally etc. Using a configured autoloader seems far more convenient. That's why I don't feel like changing the template.

I can add the variables though so that people can use them in a customized template.

@jiripudil jiripudil self-assigned this Jun 13, 2017
@jiripudil jiripudil added this to the 2.0.0 milestone Jun 13, 2017
@SendiMyrkr
Copy link
Author

Ok, i think we can put this issue to sleep until others wil request this feature then.

@jiripudil jiripudil removed this from the 2.0.0 milestone Jun 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants