$_SERVER['ZEND_PHPUNIT_TESTS_LOCATION'] not set correctly in Zend Studio - zend-framework

I set up unit testing in Zend Studio last week, and it was working fine.. until suddenly after some refactoring, I got an error that the following file was not found in ZendPHPUnit.php:
/var/folders/Td/Tdnh++2KEdWAsk8Y0O4N0k+++TI/-Tmp-/zend.phpunit.UserMapperTest.php.2428213892936827201.php
The file path is stored in $_SERVER['ZEND_PHPUNIT_TESTS_LOCATION'] in ZendPHPUnit.php
I checked the folder and I found
zend.phpunit.UserrMapperTest.php.6031927106542896607.php (the number is different)
I was a little desperate so I made it work by forcing
$_SERVER['ZEND_PHPUNIT_TESTS_LOCATION'] = '/var/folders/Td/Tdnh++2KEdWAsk8Y0O4N0k+++TI/-Tmp-/zend.phpunit.UserMapperTest.php.6031927106542896607.php';
Eventually, after I worked with a few other test cases, the problem fixed itself. Now, I refactored some code again, and the problem is back. None of my testcases work.
Restarting the comp doesnt help, Project -> Clean doesnt help. I am on a mac running Snow Leopard.
Any insights on what is causing this?
Thanks!

The problem is that PHPUnit doesn't work with the files themselves but with copies of the files that it creates on the fly and stores on directories that are also created on the fly. These files are modified to include PHPUnit logic. This goes for the test files themselves as well as for the php.ini (which forces you to load extensions in the main php.ini file for the tests, since additional .ini files are ignored). Every time you run the tests these files will be re-created with a new unique name (original name plus unique identifier).
The best way that I've found to work around this issue is to create launch configurations for the tests and save them as .launch files in your project (right click -> run as -> create new PHPUnit config -> select "shared file" in the common tab). Once you have the launch configs you can just run this by opening on the editor and clicking the Run button. You will see that after every time you run them there will be a line like the following on each launch file that has changed (easy to see if the configs are in version control):
<mapEntry key="ZEND_PHPUNIT_TESTS_LOCATION" value="/var/folders/my/ph9spb0s45z5_11l9tqw256r0000gn/T/DefaultWorkspace.phpunit.AssignmentRequestControllerDateCriteriaTest.php.4951739174960507380.php"/>
I usually just commit this change together with whatever other changes I've been working on at that time.
It's still kind of annoying that the file changes and thus the launch config, but at least in this way your tests will always run and you don't have to worry about having to re-run the manually, or clean the project, or anything like that.

Related

js source maps disappears after modifying any file

I have a project with coffeescript and brunch.
There is following config for files concatenation:
files:
javascripts:
joinTo:
'js/app.js': /^app(\/|\\)(?!templates)/
'js/vendor.js': /^vendor/
templates:
joinTo:
'js/templates.js': /^app\/templates/
When I just clone this project and build it, all works fine - I see all my source files in developer console.
Then I do some harmless modifications in any file in project (like adding a useless variable declaration or duplicating "return" statement), and strange things happens:
A builded code is valid and works fine, but there are no source maps available.
If I disable source maps at all, I still can see some wrong behaviour:
And in the same time, origin build file is absolutely valid (can't post third link, sorry): it has '//# sourceMappingURL=app.js.map' line in the end, without any trailing spaces or whatever else.
Any ideas what can this be and how to solve this problem?
I've found where I was wrong.
First. About broken files loaded by browser.
As I noticed in comment above, the problem was in environment. My files are served by nginx, running inside Vagrant VM - and it seems, that sync between local files and VM was broken.
My solution was following:
disable caching in VirtualBox (machine settings -> tab 'Storage' -> select controller -> uncheck 'Use Host I/O cache');
edit nginx config and set 'sendfile off' option in 'http' section.
Not sure this is absolutely right solution, but after this correct files was loaded by browser.
Second. About still absent maps for app.js in Chrome.
It's just my inattention. I'm using Webstorm, and periodically it proposes to enable watcher for coffeescript files I open. And if you agree (what I've accidentally did missing 'Agree' button instead of 'Dismiss'), it will compile that file at his own, creating .map and .js files alongside origin .coffee - of course, no matter to your brunch or whatever else settings. These additional files are displayed as subfolders of .coffee file, so it is very likely that you do not notice them. And exactly these files Chrome does not like. Until you remove them all, Chrome will not display any source maps, no matter to .map file created by brunch - while for FF it's not a problem.

Netbeans and PHPUnit Skeletion Generator: No such file or directory

I use netbeans 7.2.1 and newest phpunit. When I want to generate a unit test in netbeans by right-clicking on the php class then Tools-> Create phpUnit test the Skeleton generator throws an error: No such file or directory.
require_once(/sharedResources/connection.inc.php): failed to open stream: No such file or directory
The issue is that the path displayed in require_once is wrong. It is generatedliek this:
$sharedResources = getenv("DOCUMENT_ROOT") . "/sharedResources";
and should resolve to the absolute file path. This works fine when application is running in apache. However it seems that getenv("DOCUMENT_ROOT") is just wrong when running from netbeans. My question is how I can set it correctly? My application is under
getenv("DOCUMENT_ROOT") . "/MyApp";
and the file I'm creating a test for is in
"MyApp/services"
Under Project properties there is an option web root but it is greyed out and it is impossible to set it to a folder one level higher than your application.
How can I solve this?
EDIT:
Further clarification:
I initially had a relative filepath to sharedResources which did not work also. the I changed to this one and of coruse ti makes sense it is not working as DOCUMENT_ROOT is set by apache and hence not set when running in netbeans. So a temprary fix is to add
$docRoot = getenv("DOCUMENT_ROOT");
if(empty($docRoot)){
putenv("DOCUMENT_ROOT=C:/xampp/htdocs");
}
to the head of every class. of course that is not a very practical or good solution. I would need to tell netbeans to set this environment variable or to use correct relative path.
Well here is my solution. It's not ideal but simple and works. The issue is that DOCUMENT_ROOT is obviously empty when script is not called by Apache but by netbeans. Hence it must somehow be set. To do that I edited the php file phpunit-skelgen(it does not have a file ending but it's a php file).
Below the license text as first php line I added
putenv("DOCUMENT_ROOT=C:/xampp/htdocs");
That did the trick.

lexical or preprocessor issue file not found occurs while archiving?

I am new to this iPhone development and i have almost completed my first application but when i try for creating an archive it gives an error lexical or preprocessed issue file not found But it runs fine in simulator and also has also tested on device. I have included SDwebimage architecture for lazy loading of image in table view.Can any tell me what is the issue?
Few things to try, Ensure the Framework and all it's headers are imported into your project properly.
Also in your Build Settings set YES to Always search user paths, and make sure your User header paths are pointing to the Framework.
Finally, Build->Clean and Restart Xcode.
Hope this helps !
UPDATE: According to SDWebImage's installation, it's required you make a modification to Header Search Path and not User header paths, As seen below.
Have you done this as well? I suggest slowly, re-doing all the installation steps from the beginning.
Spaces in a folder name in your header search path can cause this problem. Make sure the folders in your project do not have spaces in their names.
My project was building fine until I updated to Xcode 10.1. After the Xcode update, started getting Lexical or preprocessor Issue errors on build. Some XCDataModel header files could not be found.
This fixed the issue.
Go to Build Settings, Header Search Paths
Change the appropriate value from $(SRCROOT) non-recursive to recursive.
This ensures that subfolders are also searched for headers during build.
I had this same issue now and found that my sub-projects 'Public Header Folder Path' was set to an incorrect path (when compared with what my main project was using as its 'Header Search Path' and 'User Header Search Path').
e.g.
My main project had the following:
Header Search Paths
Debug "build/Debug-iphoneos/../../Headers"
Release "build/Debug-iphoneos/../../Headers"
And the same for the User Header Search Paths
Whereas my sub-project (dependency) had the following:
Public Header Folder Path
Debug "include/BoxSDK"
Release "include/BoxSDK"
Changing the 'Public Header Folder Path' to "../../Headers/BoxSDK" fixed the problem since the main project was already searching that folder ('../../Headers').
PS: I took some good screenshots, but I am not allowed to post an answer with images until I hit reputation 10 :(
I had this problem after changed project name. I used all the methods mentioned on the internet but still doesn't work. Then I realized that all the header files not found was from cocoapods, so I re-installed the cocoapods using pod install, and thus solved the problem.
Hope this could help.
In my case I was developing a framework and had a test application inside it, what was missing is inside the test application target -> build settings -> Framework Search Paths:
The value needed to be the framework path (the build output - .framework) which is in my case:
"../FrameworkNameFolder/" - the 2 points indicates to go one folder up.
Also, inside the test application target -> Build Phases -> Link Binary With Libraries:
I had to remove the framework file, clean the project, add the framework file again, compile and this also solved the issue.
The new version contain fix for this, feel free to update.
Or you can just replace
#include "iPhone_View.h"
with
#if UNITY_VERSION < 450
#include "iPhone_View.h"
#endif
Delete the unit testing from your project follow the below steps this will solve the issue.
select your project from the project navigator to open the project editor. From the target delete the test from the left side of the project editor and press the Delete key.
I know this is old, but I'm gonna chime in anyway because it may be useful to someone. If you can still see the file in Finder, then click on the file in your project and delete it, selecting "remove references" and not "move to trash".
Once the reference is removed, drag and drop the file from finder into your project again and it should sort itself out.
Just adding another thing that worked for me :
react-native link
Evidently my ReactNative files were no longer there. I could figure that out by clicking on
Build Phases -> Link Binary with Libraries ->
Then right clicking a file I knew was responsible for React, and clicking Show In Finder .
But nothing opened. So assuming the library went missing, I just ran the above command which relinked everything again.
Also if you havn't, try :
rm -rf node_modules/ && npm install
This happened to me after I renamed a file. For some reason it was still looking for the file with the old name. What I did was create the file that it was complaining about and added to the project. Then I did a Project->clean, then Project->Build and verified the error was gone. Then I selected the newly added files and deleted them. This removed all references and I no longer see the error.
I fixed mine. The fb sdk downloaded (from my browser) as 'FacebookSDKs-iOS-4.22.0' -- I just had to rename the folder to FacebookSDK. So now in Build
Settings --> Framework Search Paths
the path looks something like /Users/.../Documents/FacebookSDK (where as before it was /Users/.../Documents/FacebookSDKs-iOS-4.22.0)
Hope this helps!
For what it's worth, my problem was completely unrelated to the error Xcode was giving. I stumbled onto a solution by deleting the .h reference, compiling, adding the reference back and compiling again. The actual error then became evident.

Why can't I step into or set a breakpoint in my XCode source?

I have several source files (all in one Group) that seem to compile with the project, but I cannot step into them or set any breakpoints within.
These files are newer versions of the same files I had in my project. (I updated the code I am using from a 3rd party). After the update, these newer files seem to compile with the project, but somehow they don't seem to be the ones the linker is putting in my final object (its like its using the older files).
So I can do this:
1. forcibly create a syntax error in one of these file and the compiler complains
I cannot do this:
1. hit a breakpoint in any of these files
2. step into any code in these files from a breakpoint outside
3. add a NSLog statement and see the output
Its like the project file (or something else) has its hand on the old compiled files (hence the project compiles fine and runs) and won't replace with these files.
help!
Sometimes it happens that the new version gets put in some unexpected place and that you indeed have two versions of the file in your project without noticing.
Do a project wide search of some unique content in the old and new files. You should get both files displayed and you can delete the old one.
Are you running in release mode? Breakpoints and NSLog statements don't execute when you build and run in release mode.
Set your Active Build Configuration to Debug.

Synchronise files between Eclipse and FTP Site

I am currently coding with Eclipse PDT, and I need to synchronise the files on my workstation with the files on the FTP server.
I've installed RSE, but I can only download and edit files as far as I can see it. What I want to happen is when I hit save, the file is saved locally, and the file to be updated on the FTP site.
Any ideas of how I can achieve this?
Create an ant builder on your project. See this article about how to do that. The important things you should know after you read the article:
You can use Ant FTP task to
transfer the files.
You can define properties given by
the Eclipse platform to get project
root, list of changed files, change
type (add, modify, delete) and so on.
Use them wisely. You will need
project_loc, resource_loc and so on.
See picture at end to see how to get
other available variables that can be
passed to the script.
Tune your Ant script, since if it run
for each file update, then it can be
slow. If it is slow anyway, then you can create a builder plugin for eclipse, which is not so complicated. I created some before.
Be prepared, that ant script can get
not only one file as changed, but a
list.