Post Deployment Tests

SVRUnit can also be used to test different files and requirements on your server after a deployment.

Just imagine that you need to test that your .env file exists, or that your cache folder has the correct permission.

There's plenty of things you can do here.

Because SVRUnit allows you to install it with Composer, it is recommended to install it directly as dependency. You can of course also use the PHAR file for this.

composer require svrunit/svrunit

Now create a XML configuration file that specifies a single YML test file (or more...)

<svrunit>  
  <testsuites>   
      
      <testsuite name="Post Deployment Tests">         
         <file>./post_deployment_tests.yml</file>      
      </testsuite>   
        
  </testsuites>
</svrunit>

Last but not least, we need the specification of our tests in the YAML file.

file_exists:

  - name: ".env file is deployed"
    file: "/var/www/html/.env"
    expected: true
        
  ....
  ....

That's it!

You can now manually run your tests, or even use your CI/CD pipeline for this.

php vendor/bin/svrunit --configuration=deployment_tests.xml  

Last updated