In my application, I have the phpunit tests next to the source code. So in all maps next to let's say DoSometing.class.php I have a DoSomethingTest.class.php.
I want to configure phpunit.xml to test all these *Test.class.php files.
How do I do that in phpunit.xml?
I have something like this at the moment:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="true"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="true"
syntaxCheck="false">
<testsuites>
<testsuite name="My Test Suite">
<directory>./*Test.class.php</directory>
</testsuite>
</testsuites>
<groups />
<filter />
<logging />
<listeners />
</phpunit>
We use a similar structure, only our test files end with the extension .TEST, or .QTEST, .JTEST based on the testing framework since we have JavaScript and other embedded code as well that needs testing. As such, we use the suffix option on the directory node as shown below.
<phpunit>
<testsuites>
<testsuite name="Your Test Suite Name">
<directory suffix=".test">.</directory>
</testsuite>
</testsuites>
</phpunit>
For the PHP Unit tests (*.TEST) we use the following PHPUNIT.xml (this is edited for size)
<!-- PHPUnit Core Settings -->
<phpunit backupStaticAttributes="false"
bootstrap="PeriScope-Bootstrap.php"
...
<testsuites>
<testsuite name="ICAP User Interface Library">
<directory suffix=".test">lib/.</directory>
</testsuite>
<testsuite name="Enterprise Scale Manager">
<directory suffix=".test">ESM/.</directory>
</testsuite>
...
</testsuites>
<!-- Add files not covered with tests into Code Coverage Analysis -->
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
<directory suffix=".class">lib/.</directory>
<directory suffix=".fn">lib/.</directory>
<directory suffix=".php">lib/.</directory>
...
<exclude>
<directory>ExternalLibraries</directory>
</exclude>
</whitelist>
</filter>
<logging>
...
</logging>
</phpunit>
Related
I use PHP 7.4.13, PhpStorm 2020.1.4, PHPUnit 9.5.8.
I try to use PHPUnit code coverage tool with PCOV, but I don't get it to work.
I installed pcov:
pecl install pcov
I enabled the extension in the php.ini file:
extension="pcov.so"
My phpunit.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
<testsuite name="Integration">
<directory suffix="Test.php">./tests/Integration</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_DRIVER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="DB_DATABASE" value="testing"/>
</php>
</phpunit>
When I try to run phpunit --coverage-html coverage I get the following:
I think the problem is the missing coverage driver. But where does the problem come from and how can I fix it?
I'm trying to solve this problem since 3 hours now, but I cant find a way.
I hope someone can help :)
In an attempt to simplify our web.config, I wanted to break out the NWebsec configuration into a separate file using the configSource attribute:
web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="nwebsec">
<section name="httpHeaderSecurityModule" type="NWebsec.Modules.Configuration.HttpHeaderSecurityConfigurationSection, NWebsec, Version=4.2.0.0, Culture=neutral, PublicKeyToken=3613da5f958908a1" requirePermission="false" />
</sectionGroup>
</configSections>
<nwebsec configSource="App_Config\NWebsec.config" />
<!--- remainder of file omitted for brevity -->
</configuration>
App_Config\NWebsec.config
<?xml version="1.0"?>
<nwebsec>
<httpHeaderSecurityModule xmlns="http://nwebsec.com/HttpHeaderSecurityModuleConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<redirectValidation enabled="true">
<!-- omitted for brevity -->
</redirectValidation>
<securityHttpHeaders>
<!-- omitted for brevity -->
</securityHttpHeaders>
</httpHeaderSecurityModule>
</nwebsec>
When I make a request to the application I now receive a HTTP 500 error with no other details. There is also nothing related in the Windows Event Viewer.
Is what I'm attempting possible with NWebsec configuration?
How do I get more detail on the error which is occurring and causing the HTTP 500 response?
I believe this is because the nwebsec element is defined as a sectionGroup:
<sectionGroup name="nwebsec">
<section name="httpHeaderSecurityModule" type="..." />
</sectionGroup>
The configSource attribute works for the section element only.
Amending the web.config:
<nwebsec>
<httpHeaderSecurityModule configSource="App_Config\NWebsec.config" />
</nwebsec>
In addition to amending the root element of the referenced file (App_Config\NWebsec.config), enables this to work as desired:
<?xml version="1.0"?>
<httpHeaderSecurityModule xmlns="http://nwebsec.com/HttpHeaderSecurityModuleConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<redirectValidation enabled="true">
...
I have such problem. I want to exclude all files in SomeBundle\Entity but don't want to exclude SomeBundle\Entity\Repository and SomeBundle\Entity\Factory.
SomeBundle\Entity
SomeBundle\Entity\Repository
SomeBundle\Entity\Factory
SomeBundle\Entity\File1.php
SomeBundle\Entity\File2.php
SomeBundle\Entity\File3.php
I trying to do it with
<filter>
<whitelist>
<directory>./../src/SomeBundle</directory>
<exclude>
<directory suffix=".php">./../src/SomeBundle/Entity</directory>
</exclude>
</whitelist>
</filter>
but as a result, i exclude all in SomeBundle\Entity ...
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true">
<testsuites>
<testsuite name="Test Suite">
<directory>SomeBundle</directory>
<directory>SomeBundle/Entity/**</directory>
<exclude>SomeBundle/Entity</exclude>
</testsuite>
</testsuites>
</phpunit>
I am creating .msi file for a web application using WIX toolset. I am able to create the file and installing too. But this is getting installed in my C: Drive. Is there any option/property so that i can install my application in my customized location. Below is my Product.wsx file code.
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?include "SourceFilesPath.wxi"?>
<Product Id="{2A8ED50E-1A72-4C1C-A0B6-8CE057414C7B}" Name="TestSetUpProject" Language="1033" Version="1.0.0.0"
Manufacturer="Rahul Test" UpgradeCode="fac49d06-fde2-4483-b244-025d65d0ed6b">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"
Platform="x86" Description="Test" Comments="Test" InstallPrivileges="elevated" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."
Schedule="afterInstallInitialize" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Feature Id="ProductFeature" Title="TestSetUpProject" Level="1">
<ComponentGroupRef Id="ComponentsGroup" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="TestSetUpProject" />
</Directory>
</Directory>
</Fragment>
<!--<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
</ComponentGroup>
</Fragment>-->
</Wix>
I tried using all the system properties from this link :
msdn.microsoft.com
Try to give Name to the ProgramFilesFolder:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="XXXX">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="TestSetUpProject" />
</Directory>
</Directory>
For your purposes you need to add Property tag with your custom path value. And then add a Directory tag with the same Id as created Property has.
You could use following code:
<Property Id="CUSTOMPATH" Value="YOUR_CUSTOM_FULL_PATH"></Property>
<Directory Id="TARGETDIR" Name="SourceDir">
...
<Directory Id ="CUSTOMPATH">
...
</Directory>
...
</Directory>
I am trying to add some JSF to my Spring WebFlow project and I made some changes trying to following the details at:
http://static.springsource.org/spring-webflow/docs/2.3.x/reference/html/ch13s07.html
but now my webflow project will not work.
Here is my old flow.xml file that worked:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:flow="http://www.springframework.org/schema/webflow-config"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />
<!-- Executes flows: the entry point into the Spring Web Flow system -->
<flow:flow-executor id="flowExecutor" />
<!-- The registry of executable flow definitions -->
<flow:flow-registry id="flowRegistry"
flow-builder-services="flowBuilderServices"
base-path="/WEB-INF/flows">
<flow:flow-location-pattern value="/**/*-flow.xml" />
</flow:flow-registry>
<flow:flow-builder-services id="flowBuilderServices"
view-factory-creator="mvcViewFactoryCreator"
validator="validator"
/>
<bean id="mvcViewFactoryCreator" class=
"org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="defaultViewSuffix" value=".jsp" />
</bean>
<!--Maps request paths to flows in the flowRegistry-->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry" />
</bean>
<!--
Dispatches requests mapped to flows to FlowHandler implementations
-->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
</beans>
Now here is my new flow.xml file that does not work:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xmlns:faces="http://www.springframework.org/schema/faces"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/webflow-config
http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd
http://www.springframework.org/schema/faces
http://www.springframework.org/schema/faces/spring-faces-2.2.xsd">
<!-- Executes flows: the central entry point into the Spring Web Flow system -->
<webflow:flow-executor id="flowExecutor">
<webflow:flow-execution-listeners>
<webflow:listener ref="facesContextListener"/>
</webflow:flow-execution-listeners>
</webflow:flow-executor>
<!-- The registry of executable flow definitions -->
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF">
<webflow:flow-location-pattern value="**/*-flow.xml" />
</webflow:flow-registry>
<!-- Configures the Spring Web Flow JSF integration -->
<faces:flow-builder-services id="flowBuilderServices" />
<!-- A listener maintain one FacesContext instance per Web Flow request. -->
<bean id="facesContextListener"
class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />
</beans>
and now for my faces-config.xml file:
<?xml version='1.0' encoding='UTF-8'?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
So can someone please tell me why webflow stopped working!!
I think you are trying to load faces-config.xml as a Spring configuration file. The JSF configuration file (faces-config.xml) is where you register a JSF application's resources and it is not a Spring configuration file so do not include it with other Spring config files.
Also /WEB-INF folder is the default place to put faces-config.xml. If you have it in /WEB-INF/spring folder then you need to mention the path in the web.xml something like this:
<context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>
/WEB-INF/faces/faces-config.xml
</param-value>
</context-param>
Unrelated to the concrete issue you also need 'SpringBeanFacesELResolver' in your faces-config.xml to resolve any Spring beans before you inject them in any JSF managed beans.
<faces-config>
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
<faces-config>