PHPUnit - how to ignore code coverage for classloader? - phpunit

When I generate code coverage for my PHP project, I always get the Symfony autoloader.
I tried adding this to my PHPUnit config with no luck:
<filter>
<blacklist>
<directory>/Symfony/Component</directory>
</blacklist>
</filter>

First of all you didn't specified suffix attribute to search for specific type of file in blacklist
so it should be
<filter>
<blacklist>
<directory suffix=".php">/Symfony/Component</directory>
</blacklist>
</filter>
if this is not working for you then you can use exclude tag in whitelist block
<filter>
<whitelist>
<directory suffix=".php">../src/library/</directory>
<!-- add more directories -->
<exclude>
<directory suffix=".php">./Zend/</directory>
<!-- add more directories with relative or absolute path -->
</exclude>
</whitelist>
</filter>
Reference: How can PHPUnit code coverage ignore my autoloader?

I'm using composer and tried several variations including the exclusion within a whitelist:
My directory structure is thus:
...
/project/tests
/project/vendor
/project/vendor/composer
...
I tried to get whitelist working:
<whitelist>
<exclude>
<directory suffix=".php">..\vendor\composer\</directory>
<directory suffix=".php">../vendor/composer/</directory>
<directory suffix=".php">..\composer\</directory>
<directory suffix=".php">../composer/</directory>
</exclude>
</whitelist>
That did not work. But this did:
<filter>
<blacklist>
<directory suffix=".php">../vendor/composer</directory>
</blacklist>
</filter>
My configuration xml file is within the tests folder along with a bootstrap file that loads in composer's autoloader.
<?php
require_once(__DIR__. str_repeat(DIRECTORY_SEPARATOR. '..', 1) . DIRECTORY_SEPARATOR . 'vendor'. DIRECTORY_SEPARATOR . 'autoload.php');

Related

Wix installer CopyFile move file not working

I want to move a file from one Directory to another and it simply does nothing.
Here is the part from my Product.wxs:
<Feature Id="ProductFeature" Title="$(var.ProductName)" Level="1">
<ComponentRef Id="testCopy"/>
</Feature>
<DirectoryRef Id="dirConfigs">
<Component Id="web.config" Guid="8736259D-4FEE-4826-B109-76DD3B0EDAE7">
<CopyFile Id="CopyWebConfig"
SourceProperty="dirProject"
SourceName="Web.config"
DestinationProperty="dirConfigs"
DestinationName="Web.config"
/>
</Component>
</DirectoryRef>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="$(var.PlatformProgramFilesFolder)">
<Directory Id="dirParent" Name="$(var.CustomerName)">
<Directory Id="dirProject" Name="$(var.ProductName)">
<Directory Id="dirConfigs" Name="$(var.ConfigFolderName)">
</Directory>
</Directory>
</Directory>
</Directory>
</Directory>
Edit
I also tried with Source/DestinationDirectory instead of Source/DestinationProperty
Any ideas?
Thanks in advance!
I would rely on a deferred CustomAction invoking the command line "copy" command rather than using CopyFile and execute it, like in this SO question.
You'll need admin permissions if you are going to write the file in a protected folder or a folder requiring administrative access (on Windows Vista+, anything outside the %USER% folder.

How to prevent users from navigating to symfony project directories?

How to prevent users from navigating to symfony project directories?
I see vendor directory content when I visit:
http://localhost/myproject/vendor/
You should configure your web server's document root directory to /web folder to avoid this issue. Sample configuration snippet for Apache:
DocumentRoot /var/www/project/web
<Directory /var/www/project/web>
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>

Trying to install asp.net on xampp

im trying to run aspx files on my xampp installation But the Apache Server doesn't Start.
What i did:
Installed a clean Xampp.
Installted the mod_aspdotnet-2.2.0.2006-setup-r2.msi
changed my httpd.conf:
#asp.net
LoadModule aspdotnet_module modules/mod_aspdotnet.so
AddHandler asp.net asax ascx ashx asmx aspx axd config cs csproj licx rem resources resx soap vb vbproj vsdisco webinfo
<IfModule mod_aspdotnet.cpp>
AspNetMount /SampleASP "C:\xamppASP\htdocs"
Alias /SampleASP "C:\xamppASP\htdocs"
<Directory "C:\xamppASP\htdocs">
Options FollowSymlinks ExecCGI
Order allow,deny
Allow from all
DirectoryIndex index.htm index.aspx
</Directory>
AliasMatch /aspnet_client/system_web/(\d+)_(\d+)_(\d+)_(\d+)/(.*) "C:/Windows/Microsoft.NET/Framework/v$1.$2.$3/ASP.NETClientFiles/$4"
<Directory "C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles">
Options FollowSymlinks
Order allow,deny
Allow from all
</Directory>
</IfModule>
#asp.net
After this steps the Server doesn't start anymore.
Even if i just run:
LoadModule aspdotnet_module modules/mod_aspdotnet.so
The Server doesn't start.
I already checked the Folder C:\xamppASP\apache\modules
The file exists.
What am i doing wrong?
Im pretty sure that this:
AspNetMount /SampleASP "C:\xamppASP\htdocs"
Alias /SampleASP "C:\xamppASP\htdocs"
<Directory "C:\xamppASP\htdocs">
Should be:
AspNetMount /SampleASP "C:\xamppASP\SampleASP"
Alias /SampleASP "C:\xamppASP\SampleASP"
<Directory "C:\xamppASP\SampleASP">
That is, that you change your directory name to the one you give as 'SampleASP'.
The reason it won't start anymore is probably because the directory you set doesn't exist.
"C:/Windows/Microsoft.NET/Framework/v*/ASP.NETClientFiles"
I have been trying to get the same thing to work and I found that I don't have ASP.NETClientFiles, if you remove your changes it will start again.
Or if you figure out where ASP.NETClientFIles comes from and install that. Then it will work.

Only create directory for a certain install (feature) level

I am creating an msi with WiX. I only want to create certain directories if the install level is higher than 1. Here is my Directory structure:
<!--DIRECTORIES-->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Product" />
<Directory Id="Documents" Name="Documents">
<Directory Id="Help" Name="Help" />
<Directory Id="Other" Name="Other" />
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="Shortcuts" Name="Product">
<Directory Id="DocumentShortcuts" Name="Documents">
<Directory Id="HelpShortcut" Name="Help"/>
<Directory Id="OtherShortcut" Name="Other"/>
</Directory>
</Directory>
</Directory>
</Directory>
I only want the "DocumentShortcuts" directory to be created on the start menu if the install level is above 1. Any suggestions would be greatly appreciated!
Directory elements only define directory structure not any instructions that they should be created. Windows Installer only creates directories when needed:
A file is being installed to a directory (Component and File elements)
The installer is explicitly told to create the directory (Component and CreateFolder elements)
A sub directory needs to be created for reasons 1 and/or 2.
The component elements that contain said resources then needs to be linked to Feature elements using the ComponentRef element ( or indirectly through ComponentGroup and ComponentGroupRef elements).

Change default directory in wix

How do I change the default installation directory (such as D:/ or E:/) in a WiX installer where the components have auto generated guid?
I have found the solution. It works for me.
Add the following property inside the product tag
<Property Id="ROOTDRIVE"><![CDATA[D:\]]></Property>
Inside your directory tag add the 'ComponentGuidGenerationSeed' attribute and give a initial guid.
Sample of the directory structure
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="Folder1" Name="Folder1">
<Directory Id="INSTALLFOLDER" Name="Folder2" ComponentGuidGenerationSeed="PUT-YOUR-GUID"/>
</Directory>
</Directory>

Resources