stuartherbert / sublime-phpunit Goto Github PK
View Code? Open in Web Editor NEWPHPUnit Support for Sublime Text 2
Home Page: https://github.com/stuartherbert/sublime-phpunit
License: Other
PHPUnit Support for Sublime Text 2
Home Page: https://github.com/stuartherbert/sublime-phpunit
License: Other
No matter what I try or where I search to try and find a setup to get this to work, whenever I try to run a test or right click to set xml file I get the below error
Running in folder: C:\Users\Chris\Desktop\UNIT testing
$ phpunit -c phpunit.xml
'phpunit' is not recognized as an internal or external command,
operable program or batch file.
--- PROCESS COMPLETE ---
There is an important setting in phpunit.py - "path_to_phpunit" that allows me to change path to PHPUnit.
But unfortunately, there is no default value in plugin settings.
when i run tests this this is what shows in the console.
Traceback (most recent call last):
File "./sublime_plugin.py", line 362, in run_
File "./phpunit.py", line 769, in run
File "./phpunit.py", line 276, in run
File "./phpunit.py", line 234, in start_async
File "./phpunit.py", line 101, in init
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 623, in init
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1141, in _execute_child
raise child_exception
This might not be an issue per se, however the $_SERVER array is usually populated with some useful values when php (and indeed phpunit) is run from the command line. It seems that your plug-in does not set any such values?
I use $_SERVER['PWD'] in some of my test code to find the current directory. This is different to dirname() as it doesn't resolve symbolic links.
Anyway my main point is that it is useful to populate $_SERVER with useful values. For some examples try display this array from the command line using PHP. PHPUnit also honours this.
Your script would be far more compatible and have a broader reach if it did populate this system array.
Do you think you might consider it? :-) And if not is there another alternative to getting this information?
several issues related to moving to Python 3.3
File "C:\Users\Bill\AppData\Roaming\Sublime Text 3\Packages\sublime-phpunit\phpunit.py", line 7, in <module>
import thread
ImportError: No module named 'thread'
I commented out the import thread line to see if I could make further progress.
That leads to this not-very-helpful error:
reloading plugin sublime-phpunit.phpunit
TypeError: String required
However, the right-click phpunit options show up. I try clicking "Run these tests", and get error:
File "C:\Users\Bill\AppData\Roaming\Sublime Text 3\Packages\sublime-phpunit\phpunit.py", line 118, in clear_output_view
edit = self.output_view.begin_edit()
TypeError: begin_edit() missing 2 required positional arguments: 'edit_token' and 'cmd'
TypeError: String required
The sublime text 3 porting guide (http://www.sublimetext.com/docs/3/porting_guide.html) says:
Restricted begin_edit() and end_edit()
begin_end() and end_edit() are no longer directory accessible, except in some special circumstances. The only way to get a valid instance of an Edit object is to place your code in a TextCommand subclass. In general, most code can be refactored by placing the code between begin_edit() and end_edit() in a TextCommand, and then calling run_command on that TextCommand.
This approach removes the issue of dangling Edit objects, and ensures the repeat command and macros work as they should.
And now I'm lost as I'm not really python-literate
When I run "Run All Unit Tests..." from the context menu I get the following error (both from phpunit.xml and from a .php file somewhere in the tree):
Traceback (most recent call last):
File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_
return self.run(edit)
File "/Users/XXXXX/Library/Application Support/Sublime Text 3/Packages/sublime-phpunit-feature-st3-support/phpunit.py", line 956, in run
cmd = PhpunitCommand(self.view.window())
TypeError: __init__() missing 1 required positional argument: 'edit'
Is there any known workaround for this? Any help is appreciated.
Individual tests work fine. Also, acc. to the console the plugin does find phpunit.xml, so that does not seem to be the problem.
Thanks for a great plugin.
Could we have an option to automatically run the tests for the current file whenever it is saved?
It doesn't seem to start. In the console I get this output:
File "phpunit in D:\apps\Sublime\Data\Installed Packages\PHPUnit.sublime-package", line 35
print "[PHPUnit Plugin " + Msgs.operation + "()] " + msg
^
SyntaxError: invalid syntax
Hi all,
I'm following this tutorial to get the PHPUnit running:
https://jtreminio.com/2013/03/unit-testing-tutorial-part-2-assertions-writing-a-useful-test-and-dataprovider/
For a simple start, I've declared just a class and its tester. As it was told in the tutorial (part 1), I have installed PHPUnit via Composer. My tests work just fine when I use the PHPUnit like:
$ ./vendor/bin/phpunit
However, when I try to run tests from Sublime Text 3 command palette or like $ phpunit
, I get the following error:
Fatal error: Class 'MyNamespace\MyClass' not found in /Users/k/Sites/Project/MyNamespace/Test/MyClassTest.php on line 14
No errors when I include the class file with require_once
.
Global instance of PHPUnit is under /usr/local/bin
. Is there a way to force the plugin to use phpunit
command from the project root, like /vendor/bin/phpunit
?
I have a setup where I use a virtual machine (with vagrant) to run my development environment and so I need a way to trigger phpunit tests on a remote host collect output and show it there. Is there an easy way to do this? Can I just pass ssh credentials somewhere and have it run the commands there?
Probably replace AsyncProcess func somehow to use a ssh connection? I'm not really that proficient with python at the moment but I could try to hack it out. Would be really great if this can be done natively - I have a feeling there might be a lot of people using vagrant for their projects
Thanks
Hello,
this plugin slows down the context menü when i right click into an php file.
The contextmenu hangs for about 2-3 seconds and than it appears.
It onlyhappens by right clicking into the code-view-part of an php file.
Can you please take a look into this ? Thanks!
best regards....
but I have php 5.6
php -v
PHP 5.6.10 (cli) (built: Jul 6 2015 14:28:54)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
Thanks for a great plugin.
I'm running unit tests with sublime-phpunit for ST3 which mostly works great. The one issue I'm having is with some integration tests that don't correspond to specific class files. I.e. for unit tests I have MyClass
and MyClassTest
, but then I have a class MyIntegrationTests
, but there is no class called MyIntegration
(by design, or at least, I'm not in a position to change the structure freely). I'm unable to run these tests from sublime, because the context menu/command palette "Run Tests..." option now says
Cannot find file containing unit tests
The current file in the editor, when right-clicking, is the file with the test cases (i.e. MyIntegrationTests
. Is there a workaround, or a way to override this behavior, and just run the tests in the file?
I was working good, but after several updates, when I run tests over my phpunit.xml file, this isn't detected and isn't taken as argument to phpunit, to get works on sublime text 2 I modified some lines on this way:
#if os.path.isfile(os.path.join(folder, configfile)): //211 line
args.append("-c")
args.append('"' + folder + configfile + '"')
I would like to know a suggestion, because on sublime text 3 I can't do it; and I would appreciate know the cause to don't have to modify the files, if someone have some idea thanks a lot.
PD. Sorry my bad English.
As a developer, I'd like to be able to create a test case file from the current class I'm working on, so that I don't have to create the file manually.
Example:
If im working on application/models/fancy/FancyModel.php
I'd like to right click and select "Create test Case"
that will generate the file application/test/models/fancy/FancyModelTest.php
and open it in the editor
Is it possible to just run one test or a group of tests at a time from the context menu? Running my tests on some classes takes a while and I would appreciate the shorter feedback loop. This could be implemented either via the --filter or --group flag.
Get this error in the sublime console (ST3) when right clicking an open file and selecting PHPUnit\Run Tests...
The open file is a test
I'm using ST3 on Windows 7 and had some trouble with PHPUnit not picking up the files properly.
I've ultimately traced it to the PhpunitCommand class with, for example,:
# remove the folder from the configfile
if configfile.startswith(folder):
configfile = configfile[len(folder):]
if configfile[0] == "/":
configfile = configfile[1:]`
Which I replaced with
# remove the folder from the configfile
if configfile.startswith(folder):
configfile = configfile[len(folder):]
if configfile[0] == os.path.sep:
configfile = configfile[1:]
which brought everything back into line. Am I the only one that's run into this?
My phpunit.xml is buried under folders in the project, so it's not in the 'top folder', which I've seen people recommend...
I am using ST2 on OSX 10.9 (Macbook Air 2012) and I decided to use ST2 as my main editor of choice.
After installing the necessary plugins (wish PHPUnit was one of) I noticed that when I opened ST2 and I pressed CMD+shift+P (super+shift+p) I had to wait 10+ seconds before ST2 was done and could react on my input again.
I almost got crazy over not being able to find the cause of this. I found it after disabling all plugins and activating the plugins one by one until I reached PHPUnit.
I havent adjusted anything with the PHPUnit settings. I also not using PEAR, but composer with globally installed PHPUnit (~/.composer/vendor/bin).
Anyone have the same experience? What could it be and how could this be solved?
Hey guys, i'm installed the phpunit plugin on st3 and saw the following error in the console, maybe it's helpful for you:
reloading plugin PHPUnit.phpunit
Traceback (most recent call last):
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 73, in reload_plugin
m = importlib.import_module(modulename)
File "X/importlib/__init__.py", line 88, in import_module
File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 671, in load_module
exec(compile(source, source_path, 'exec'), mod.__dict__)
File "phpunit in C:\....\Sublime Text 3\Installed Packages\PHPUnit.sublime-package", line 35
print "[PHPUnit Plugin " + Msgs.operation + "()] " + msg
^
SyntaxError: invalid syntax
First I want to say thanks for creating this plugin.
I'm not able to get tests to actually run on my 32-bit Windows 7 box at work.
When I run the test, this is what I see, but no results are shown. I can copy that command into a shell in the specified directory and the test runs.
# Running in folder: C:\www\autopaf\tests
$ phpunit -c phpunit.xml C:\www\autopaf\tests\application\controllers\VendorControllerTest.php
Console log output:
Traceback (most recent call last):
File ".\sublime_plugin.py", line 362, in run_
File ".\phpunit.py", line 825, in run
File ".\phpunit.py", line 183, in run
File ".\phpunit.py", line 150, in start_async
File ".\phpunit.py", line 39, in __init__
File ".\subprocess.py", line 633, in __init__
File ".\subprocess.py", line 842, in _execute_child
WindowsError: [Error 2] The system cannot find the file specified
Are you interested in merging https://github.com/gerardroche/sublime-phpunit ?
It is an ST3 only package. There are a few differences, not many other than >=ST3 only and some extra features.
It seems to be defaulting to using /usr/bin/php
, which is not the desired behaviour for my setup. I would like it to use /usr/bin/env php
or simply php
. Is it possible to change the path to PHP in the environment in Sublime or this package?
Console shows errors after saving a phpunit test file:
AttributeError: 'RunPhpunitOnSave' object has no attribute 'top_folder'
Hi, I try this plugin and I lanch test but no colors shows in console and show caracters.
--- PROCESS COMPLETE ---.
Time: 0 seconds, Memory: 4.00Mb
�[30;42m�[2KOK (1 test, 1 assertion)
�[0m�[2K
Thanks!
Hello, I installed the sublime-phpunit plugin over package control. I didn't changed the configuration so its just default. PHP and PHPUnit works fine from command promt.
PHP and PHPUnit can be found under my PATH variable.
If I "right click: Run all tests" the execution command is correct.
Running in folder: C:\Users\createproblem\Documents\projects\web\mn-webapp\app
$ phpunit -c phpunit.xml.dist
This is the error I got in Sublime Text 2
Traceback (most recent call last):
File ".\sublime_plugin.py", line 362, in run_
return self.run(edit)
File ".\phpunit.py", line 721, in run
File ".\phpunit.py", line 232, in run
File ".\phpunit.py", line 190, in start_async
File ".\phpunit.py", line 74, in __init__
File ".\subprocess.py", line 633, in __init__
File ".\subprocess.py", line 842, in _execute_child
TypeError: environment can only contain strings
Maybe a problem in my setup?
Some tips to get this plugin work would be nice.
so long
createproblem
It would be nice to run a test suite from within the plugin.
Considering a TestSuite (AllTests.php) like this:
<?php
class AllTests {
static public function suite() {
$suite = new PHPUnit_Framework_TestSuite('Foo');
$suite->addTestCase('BarTest');
return $suite;
}
}
I already tried to modify the plugin (allowing to run the PHPUnit: Run these tests
command to show up in a file called *Tests.php
), but I failed miserably due to my lacking python knowledge.
Hello, I'm using ST2 on OSX 10.9.2.
After I wrote my tests and the phpunit.xml, and "Run Tests..." from right-click menu, the console log appears in the bottom and shows the phpunit command but not the results.
When I copy the command and paste it on the Terminal, it works fine. What possibly did I do wrong? Because when I click "Open Class Being Tested" and "Open phpunit.xml" they just works well.
Here's the screenshot of the console:
Sorry for bad English
I would like to have the option to select a phpunit xml file with other names, as for example phpunit-test-this.xml
. Actually, only phpunit.xml
is accepted in the sidebar right-button command.
I'm running into a problem where my full test suite always runs, regardless of whether I ask it to 'Test This Class…' or 'Run All Unit Tests…'.
My phpunit.xml looks like this:
<?xml version="1.0"?>
<phpunit bootstrap="bootstrap.php" backupGlobals="false" backupStaticAttributes="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" syntaxCheck="true" testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader" verbose="true" strict="true">
<php>
<ini name="date.timezone" value="Europe/London"/>
</php>
<testsuites>
<testsuite name="Commerce">
<directory suffix=".php">.</directory>
</testsuite>
</testsuites>
<filter>
<blacklist>
<directory>.</directory>
<directory>../src/lib</directory>
</blacklist>
</filter>
</phpunit>
Does this support colored output? Cause at the moment I don't? Not sure if there is something I need to set?
edit:
Nevermind! There seem to be more problems with this package (like for instance it stops working after you installed it and restart sublime). I will have to find me something else (outside of ST).
I think this is as simple as me not having the phpunit.xml file at the time of installation, but after installing the package sublime hangs on my system when opening a command palette or right clicking. Removing the package manually from my system fixed the problem.
Ubuntu 12.10, 64bit
Sublime Text 2 v2.0.1 build 2217
Seems like the folder exclusion setting is not used, so it goes into vendor/
and grabs the first it finds...
Even though app/phpunit.xml.dist
is "closer" than vendor/.../phpunit.xml
I use the default plugin settings and I don't have a app/phpunit.xml
file.
When you rely on top_folder_hints usign files or folders like .git and .gitignore the search stops at wrong places, like.
Its very common that people leave an empty .gitignore file in folders that they want in the repo. but in which they dont want to track files inside. (empty folders in git repo)
since .gitignore is a hint on searching top folders, the plugin will stop at wront places and wont be able to find phpunit.xml or classes to be tested.-
Instead, allow the user to configure the top level folder, or/and phpunit.xml location. so you can also save some processing on searching for those.
I'm developing a Symfony 2 app. the phpunit file lives under the app directory which is one level in from the root.
Usually i have to run phpunit from the root as such
phpunit -c app
Would it be possible to save the location of the dist file in the sublime projects file so that you first look there and then start searching for it up the path?
First of all, congratulations for this awesome and helpful plugin!
There is something I thing it is simple to solve. Let's go:
If I have two classes with same name in different namespaces:
with it's respective tests:
when i'm in Service\MyClass
and trigger 'phpunit_toggle_class_test_class' it was suppose to open the respective Service\MyClassTest
but it it's always openning one of them: Service\MyClassTest
, even if i'm in the other class Command\MyClass
it will open the Service\MyClassTest
.
I think it's always openning the first match in the 'phpunit_toggle_class_test_class' command. My suggestion is to show a list of options to toggle when in these cases.
I hope i was clear. Sorry about my english.
Thanks a lot!
Hi,
I wanted two things that the plugin didn't easily satisfy:
When a test fails, it prints the file and line number in the console. It would be great if we could click on that to take us straight there.
is it possible to execute remote phpunit, I have a vagrant box which has my project files, I would like to run tests on that box from sublime text.
Thank you
Project Framework: Laravel
I have a phpunit.xml in my root with the following code:
<?xml version="1.0"?>
<phpunit colors="true" bootstrap="artisan" backupGlobals="false">
<testsuites>
<testsuite name="Tests">
<directory suffix=".test.php">application/tests</directory>
</testsuite>
</testsuites>
</phpunit>
When I right click on my file example.test.php the PHPUnit selection states "Cannot find file containing unit tests".
Hi,
I tried to run phpunit on my laravel 4.2 project with Sublime 3 on Windows 10. (Before I upgraded to Windows 10, everything worked fine)
I got this error :
PHPUnit 3.7.21 by Sebastian Bergmann.
Class 'SubjectTest' could not be found in '\app\tests\models\SubjectTest.php'.
[Finished in 0.2s]
And here is my SubjectTest.php
<?php
class SubjectTest extends TestCase {
...
}
Do you have any idea how to solve this problem?
Thank you.
I just tried to run some unit tests and I'm getting the following error.
"
Error loading color scheme
Packages/phpunit/color-schemes/phix-dark.hidden-tmTheme: Unable
to open Packages/phpunit/color-schemes/phix-dark.hidden-tmTheme
"
my mac $PATH is '/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin'
; but the plugin's path is [path: /usr/bin:/bin:/usr/sbin:/sbin], and it keeps telling me 'env: php: No such file or directory' due to that i installed my php under the '/usr/loca/bin/' directory. i've tried adding my $PATH to the "override_env" variable in the user's setting.
Here 's my user setting :
{ "path_to_phpunit": "/usr/local/bin/phpunit", "override_env": {"PATH" : "/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"} }
. But it still not working.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.