Skip to content

Latest commit

 

History

History
168 lines (134 loc) · 2.87 KB

Incomplete.md

File metadata and controls

168 lines (134 loc) · 2.87 KB

Environment variables

For symfonys database connection

DATABASE_URL=mysql://root:[email protected]:3306/project_entities_test

For DSM database connection

dbUser=root
dbPass=87JCLtVJttrrTp94T2R7z1rFXDfoag2Y
dbName=project_entities_test
dbHost=localhost

The entities path

entitiesPath=/var/www/vhosts/project-admin-dsm-api/vendor/project/project-entities/src/Entities

Setting up auto loading

Auto loading should be wrapped in an array i.e.

{
    //...
    "autoload": {
        "psr-4": {
            "ProjectDsmApi\\": ["src/"]
        }
    },
    //...
}

We need to bring in the tests of the entities model to use the data fakers and other assets:

The reason the whole /tests/ directory is brought in and not just the /tests/Assets/ is because the array of data fakers is in /tests/Entities/AbstractEntityTest.php

{
    "autoload-dev": {
        "psr-4": {
            //...
            "Project\\ProjectEntities\\" : ["vendor/project/project-entities/tests/"]
        }
    },
}

Bringing in dependancies

Require the entities module

{
    "require": {
        //...
        "project/project-entities": "dev-master@dev"
    },
}

Add different faker library

{
    "require-dev": {
        //...
        "fzaninotto/faker": "dev-dsm-patches@dev"
    },
}
{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/edmondscommerce/Faker.git"
        }
    ],
}

Symfony Specific

{
    "require": {
        //...
        "beberlei/DoctrineExtensions": "^1.1",
        "edmondscommerce/dsm-symfony": "^0.2.0@dev"
    },
}

If using symfony > 3 and you are requiring symfony packages to be of the same version you will need to remove the composer restriction for symfony pacakges i.e.

From:

{
  "extra": {
    "symfony": {
      "allow-contrib": false,
      "require": "4.2.*"
    }
  },
}

To:

{
  "extra": {
    "symfony": {
      "allow-contrib": false
    }
  },
}

Add the Repositories to the services yaml for dependancy injection

services:
    # ...
    Project\ProjectEntities\Entity\Repositories\:
        resource: '../vendor/project/project-entities/src/Entity/Repositories/*'

Using the stuff

Use DI to bring in the repo i.e.

<?php
//...
class Example
{
    /**
     * @var exampleRepository
     */
    protected $exampleRepository;

    public function __construct(ExampleRepository $exampleRepository)
    {
        $this->exampleRepository = $exampleRepository;
    }

    public function example(): string 
    {
        $example = $this->exampleRepository->findOneBy([]);
        return $example->getExampleEntityString();
    }
}

Stuff for testing

We brought in 2 traits to use with the tests.

The DI injection Trait and the Dsm Fixtures Trait.