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 :)
Related
I want to deploy my webapp with two different ports having two different deployment descriptors.
Is there a way to do so? I know how can I deploy a webapp on multiple ports. Wonder if we can provide separate deployment descriptor for an app being deployed on each connector.
<Service name="serviceA">
<Connector port="8080" maxHttpHeaderSize="8192" maxThreads="10"
enableLookups="false" acceptCount="100"
connectionTimeout="10000" disableUploadTimeout="true"
useBodyEncodingForURI="true"/>
<Engine name="serviceA" defaultHost="localhost" jvmRoute="host1">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase" />
<Host name="localhost" appBase="webapps" unpackWARs="true"
autoDeploy="false" xmlValidation="false"
xmlNamespaceAware="false" xmlBase="PATH_TO_CUSTOM_web.xml">
<Context docBase="browser" path="/browser" reloadable="false"/>
</Host>
</Engine>
</Service>
<Service name="serviceB">
<Connector port="8081" maxHttpHeaderSize="8192" maxThreads="10"
enableLookups="false" acceptCount="100"
connectionTimeout="10000" disableUploadTimeout="true"
useBodyEncodingForURI="true"/>
<Engine name="serviceB" defaultHost="localhost" jvmRoute="host1">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase" />
<Host name="localhost" appBase="webapps" unpackWARs="true"
autoDeploy="false" xmlValidation="false"
xmlNamespaceAware="false" xmlBase="PATH_TO_CUSTOM_web.xml">
<Context docBase="browser" path="/browser" reloadable="false"/>
</Host>
</Engine>
</Service>
Something like xmlBase="PATH_TO_CUSTOM_web.xml"
One can specify absolute path to the deployment descriptor instead of the default value.
altDDName
Ref: https://tomcat.apache.org/tomcat-8.5-doc/config/context.html
I have a simple apigee proxy, but I can see in the trace an issue where the Host header going to the target contains the host of the proxy itself.
i.e. the target gets
Host: xx.apigeename.com
rather than:
Host: my.awsservername.com
The target is on a different domain to the proxy, so it means that the target server is improperly handling the request (404 in this case).
Why is it that Apigee might be sending the exact same host header and not transforming it?
I have tried to explicitly set it, by setting the TargetEndpoint:
<TargetEndpoint name="xyzzy">
<Description/>
<FaultRules/>
<PreFlow name="PreFlow">
<Request>
<Headers>
<Header name="Host">{target.host}</Header>
</Headers>
</Request>
<Response>
</Response>
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<Flows/>
<HTTPTargetConnection>
<Properties/>
<URL>https://{targetBackend}/xyzzy</URL>
<SSLInfo>
<Enabled>true</Enabled>
<Protocols>
<Protocol>TLSv1.2</Protocol>
</Protocols>
</SSLInfo>
</HTTPTargetConnection>
</TargetEndpoint>
The documentation Apigee has on this seems very vague.
It's getting super frustrating. We have other proxies that are working fine without doing anything special.
This seems odd. Apigee should not do that by default. Are you sure that other flows are setup correctly? Anyhow.. you can try to create a AssignMessage policy that adds the correct host.
Take a look at this: https://docs.apigee.com/api-platform/reference/policies/assign-message-policy#Samples
./policies/hostPolicy.xml:
<AssignMessage name="hostPolicy" continueOnError="false">
<AssignTo createNew="false" type="request"></AssignTo>
<Set>
<Headers>
<Header name="Host">{target.host}</Header>
</Headers>
</Set>
</AssignMessage>
./targets/xyzzy.xml
<PreFlow name="PreFlow">
<Request>
<Step>
<Name>hostPolicy</Name>
</Step>
</Request>
</PreFlow>
NB: I haven't tested this. Read the vague apigee docs on policies
For Apigee X, the AssignMessage -> Set option does not work. But two other options are effective:
Javascript: context.setVariable('target.header.host',"my.host.name")
AssignMessage Policy:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage continueOnError="false" enabled="true" name="AM-targethost">
<DisplayName>AM-targethost</DisplayName>
<Properties/>
<AssignVariable>
<Name>target.header.host</Name>
<Value>my.host.name</Value>
<Ref/>
</AssignVariable>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
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>
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>