Download the PHP package viraj/cakephp-testdummy without Composer

On this page you can find all versions of the php package viraj/cakephp-testdummy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cakephp-testdummy

Cakephp Testdummy

Testdummy provides an easy way of creating random test data. While writing tests you would require random/fake data to run your tests.

Testdummy helps you to create a random set of fake data which you can configure exactly according to your needs in the test.

Step 1: Installation

Install this package using Composer:

Step 2: Create a factories file

Within the config/Factories directory, create a TableFactory.php file with the following contents:

Within a config/Factories directory, you may create any number of PHP files that will automatically be loaded by our package.

Step 3: Write a factory

Before using factories, you must define them in the above file. An example factory definition would look like this:

In TableFactory.php you will have access to $faker variable which is an instance of the Generator class in the Faker package. Using Faker, you can create random data of various types and even get values which are local to your country. Please read the documentation of Faker to understand their API.

Step 4: Using Factories

To use factories, your tests need to extend the \TestDummy\BaseTestCase. This class extends the IntegrationTestCase present in CakePHP core, so you get access to all the core features and assertions.

If you are using the Integrated package, you don't need to extend the BaseTestCase Just extend the appropriate class in the Integrated package, and factories will be loaded automatically

Now, you can use your defined factories in the tests:

Step 5: Database Migrations

Fixtures create tables before every test and drop them after every tests. When using fixtures, you would need to define fixture files, plus import or configure the names of fixtures to be used in every test.

Alternatively, you can use the DatabaseMigrations trait which will basically migrate your database before every test and delete all the tables after every test. Here is an example of how to do this:

Overriding attributes

You can even override specific attributes in your tests while using factories:

The above code will generate a post record in the database with the above title and fake data for other fields.

Collection of Factories

If you want to create a collection of 100 posts, you can do so by using the following syntax:

The above code will create 100 post records and return a Cake\Collection\Collection instance containing 100 posts


All versions of cakephp-testdummy with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.0
fakerphp/faker Version ~1.4
symfony/finder Version ^3.3
cakephp/cakephp Version ^4.0
cakephp/chronos Version ^2.0
cakephp/migrations Version ^3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package viraj/cakephp-testdummy contains the following files

Loading the files please wait ....