laravel 4 cannot get phpunit testing to work - shell

I'v installed phpunit by adding it into my composer.js and running the update. The composer did it's thing and automatically installed phpunit and updated various scripts.
I then ran the 'phpunit' command (from the laravel folder) as instructed by the docs and received
'phpunit' is not recognized as an internal or external command operable program or batch file
Which is fustrating as the doc simply say
You may run all of the tests for your application by executing the phpunit command from your terminal.
Which seem to be false.
So after looking around trying out various things I managed to get a response from
php vendor/bin/phpunit
which I ran from the same folder where phpunit.xml is located.
The response I got was
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd "../phpunit/phpunit"
BIN_TARGET="`pwd`/phpunit"
cd "$SRC_DIR"
"$BIN_TARGET" "$#"
What is that?? That they what I'm expected to receive from the unit testing. I assume not.
My understanding is that it will run all the unit tests located in the laravel/app/test/ folder.
What is going on and how do I get this to work?
Note I am running from the windows CMD.

I tried installing the laravel homestead but this just introduced more headaches and problems.
To get phpunit working I edited the 'Path' environment variable.
Method for windows 7
1) Right click on 'My computer'->properties
2) In the left hand column click 'Advanced System Settings'
3) under the Advance tab click 'Enviroment Variables'
4) Under 'System Variable' local the 'Path' variable and click edit
5) Append the location of phpunit.bat to the end of the variable data.
IE C:/some/other/thing; C:/something/else; C:/myproject/laravel/vendor/bin/
6) Save it all.
This is what I've done and it seem to work fine.

Related

Windows Script Host Error: Invalid character - Code:800A03F6 - Source: Microsoft JScript compilation error

I'm having an issue with Powershell and CMD. When I try to execute Angular CLI commands in CMD like ng --version or ng new projectName, I get this error;
Windows Script Host Error: Invalid character
Code: 800A03F6
Source: Microsoft JScript compilation error
Update:
On Windows .js files are associated to Windows Scripting Host by default, so the script will not be run with Node.
Open a file explorer and find a JavaScript file, open the JavaScript file's properties and then "open with", select the Node.js program file to open that kind of files.
The error should stop after doing this.
This is how I solved it: (on windows 10)
Go to C:\Users\<your_username>\AppData\Roaming\npm\node_modules\#angular\cli\bin
Check for ng.js
Right click on ng.js file and click on "properties" option
You need to open it with node.exe so click on "Change" button go to node js installed directory and
(example: C:\Program Files\nodejs\node.exe)
Select node.exe
Click on OK
It should change the color of ng.js like below:
Now try ng -v and other ng commands
Installing this exact Angular version:
npm -g install #angular/cli#10.3.1
instead of the latest version:
npm -g install #angular/cli
fixed the above error.
I ran into this exact issue after updating to Angular CLI 13. Tried tons of different suggestions from other threads. What is described in the solutions here is essentially what worked for me, but I just want to point out a possible alternative method to applying the fix that doesn't associate all JS files with node.js.
Trying to execute a script from package.json on Windows throws a JScript error
In your windows system environment variables is one variable called PATHEXT. If the value contains .JS;, remove it. Then restart your CMD windows.
make sure you have proper path variable configured as shown below
Go to your system variable settings
path variable snapshot
make sure you have all these mentioned as part of path
C:\Users<userfolder>\AppData\Roaming\npm\node_modules#angular\cli
C:\Users<userfolder>\AppData\Roaming\npm
C:\Program Files\nodejs
make sure you have all these mentioned as part of path C:\Users\AppData\Roaming\npm\node_modules#angular\cli C:\Users\AppData\Roaming\npm C:\Program Files\nodejs
in my case, before npm install -g #angular/cli, the path of my system variable was:
C:\Users\AppData\Roaming\npm\node_modules#angular\cli\bin
I remove \bin and work!!!!!
Remember to fix this for the correct User
Associating .JS files to node.exe is the way to solve this.
BUT after struggling with the same issue, I wanted to add that the file association needs to be done with the same USER that you are working with the Terminal/Shell.
So if you use the Terminal as a Admin, you must login with your Admin Account just to fix the file association.
Cheers

Windows 10 golang setup. Error, Not in an environment

I am running into issues setting up go for the first time on a Windows 10 machine.
I followed the instructions from the install. https://golang.org/doc/install?download=go1.10.windows-386.msi
When I CD to my project E:\goProjects\goWebApp\src and run go build, I receive the following error.
C:\windows\system32>go version
Not in an environment
C:\Users\MyUser~1\AppData\Local\Temp\go_there.bat' is not recognized as an internal or external command,
operable program or batch file.
My system variables are as follows:
GOPATH=E:\goProjects\goWebApp
GOROOT=C:\Go
PATH=C:\Go\bin
If I run go version from C:\Go\bin everything works fine. Running go command from anywhere outside of this directory does not work. I have also tried restarting my cmd prompt and restarting my computer. Still no luck. Has anyone else ran into this issue? Or know what I might have done wrong?
Turns out I had two go locations in my PATH (sort of). When I ran the command where go from command prompt two paths were returned.
Something like this..
C:\tools\devTools\bin
C:\Go\bin\go.exe
There apparently was a bat file in devTools\bin called go.bat. This was unrelated to golang itself, just coincidental naming unfortunately.This was executing instead of the go binary, which in return was throwing the random error with the Not in an environment message.
To fix the issue I just removed the devTools path from my PATH variable for now.

phpunit command return "phpunit --help" screen

I'm trying to make some PhpUnit test on Magento with using ecomdev (https://github.com/EcomDev/EcomDev_PHPUnit).
I've correctly installed modman, PEAR and related packages dependencies (I'm on Ubuntu server 12.04 through a Virtualbox).
What is really strange is, after the step 2, from ecomdev procedure, when I'm trying to start a first "$ phpunit" command, it shows the screen as if I typed "$ phpunit --help".
When I type "$ phpunit --version" it correctly displaying the current version (mean it seems correctly installed).
All advices are welcome.
I have been similar problem on WAMP, WinXP SP3, Apache 2.4, PHP5.4.44, Xdebug v2.3.3, vc10+vc14
I downloaded phpunit.phar from phpunit.de
My error was wrong phpunit.cmd file.
I wrote
#php "%~dp0phpunit.phar"
Correct cmd is
#php "%~dp0phpunit.phar" %*
phpunit needs to know what to run. EcomDev_phpUnit includes a phpunit.xml.dist file that phpunit can use. Neither modman nor modgit installs it in Magento's root by default. You can copy the default version into Magento's webroot from the module's source folder or by installing the module manually.
I used modgit to install EcomDev_phpUnit. Here is the copy command I used to copy the file:
cp .modgit/ecomdev_phpunit/source/phpunit.xml.dist .
Once in place, phpunit should give you something like this:
$ phpunit
PHPUnit 3.7.28 by Sebastian Bergmann.
Configuration read from /path/to/your/magento/phpunit.xml.dist
There is likely a more correct way to use the included ecomdev-phpunit.php script to copy the phpunit.dist.xml file into place.

I cant get PHPUnit to work within NetBeans (Mac)

My NetBeans have an option to add a path to a script that runs PHPUnit, however when I try to add this script to my NetBeans I get the error that it doesn't recognize the version. Says that version is ?.?.? and that is not supported. However my PHPUnit version is supported by NetBeans and work perfectly when I run it from the pear installer folder (PHP).
"Selected PHPUnit (version ?.?.?) is too old, upgrade it if possible (the minimum version is 3.3.0)" - I got 3.6.4.
My script looks like this
#!/bin/sh
phpunit --bootstrap MyBootstrap.php --stderr $*
And it works great on linux NetBeans. Just not on my Mac.
And yes it works perfect when I run it in the console.
Thanks a milion
/Marcus
I'm not sure what php runner is, but to recognize valid PhpUnit, NetBeans run command "phpunit --version", so check what this command gives you in console.
Once I had problem with this, so I simply found the code of phpunit that is responsible for "phpunit --version" and manually type what should be printed when this command is executed. So NetBeans "saw" correct version and everybody is happy :)
I solved the phpunit problem (too old phpunit message on netbeans)
First open terminal and then:
cd /private/etc
cp php.ini.default php.ini
open php.ini file
change include_path to include_path = ".:/usr/share/pear"
Problem solved :)
If however the problem is not solved then try install netbeans for php from netbeans.org
Mate, that is error by Netbeans (see bug id 188240), and it looks like it is not fixed yet. It happens on Mac OSX.
What i did is to rename Application/NetBeans/NetBeans 7.1.1 to Application/NetBeans/NetBeans7.1.1 (note the lack of space)
as per Xdebug, read this:
http://xdebug.org/find-binary.php
when you get the version for your server, add these lines into your php.ini:
zend_extension = /opt/local/lib/php/extensions/<name of your extension>/xdebug.so
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
replacing <name of your extension> with, of course, the name of your extension :)
after this you should be ready to go.
Issue about version soved by reinstalling everything, however I now get this
PHPUnit 3.6.7 by Sebastian Bergmann.
The Xdebug extension is not loaded. No code coverage will be generated.
Cannot open file "/Applications/NetBeans/NetBeans".
How could I load Xdebug? Is that in php.ini or apache conf? or is that in NetBeans?

Code Igniter CLI vs crontab entry

When I launch a CodeIgniter controller via CLI, like so:
php index.php mycontroller method
everything works well (assume you are on the right paths, inside the code igniter folder)
However, when the same line is invoked from a crontab entry, the default controller is executed (as if the below line was asked)
php index.php welcome
I've attempted to create a bootstrap for my cron needs and done extensive research into this topic, to no avail.
One of the solutions attempted: http://www.asim.pk/2009/05/14/creating-and-installing-crontabs-using-codeigniter/
Code Igniter version: Reactor 2.0.2
Do you know why Code Igniter would react differently in CLI mode vs crontab? Olde versions of CI seems to operate well
When something that normally works, does not work when called from crontab it is nearly always a path issue.
Using /usr/local/bin/php instead of just php will make it work. The same is true for system calls inside the php script e.g. passthru, system, exec etc.
You can use the whereis command to find the absolute path to the executable you want to run by running e.g.:
whereis php

Resources