Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions config/doctrine/Customer.orm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
App\Entity\Customer:
type: entity
table: customer
id:
id:
type: integer
generator:
strategy: AUTO
fields:
name:
type: string
lenght: 255
createdAt:
type: datetime
gedmo:
timestampable:
on: create
updatedAt:
type: datetime
gedmo:
timestampable:
on: update
7 changes: 6 additions & 1 deletion config/routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ api_delete_partner:
api_create_partner:
path: /api/partner
controller: App\Controller\PartnerController::create
methods: POST
methods: POST

api_list_customer:
path: /api/customer
controller: App\Controller\CustomerController::list
methods: GET
83 changes: 83 additions & 0 deletions fixtures/Customer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
App\Entity\Customer:
customer_0:
name: FTV
customer_1:
name: M6
customer_2:
name: Unimédias
customer_3:
name: Meetic
customer_4:
name: Enedis
customer_5:
name: Lizeo
customer_6:
name: Euronews
customer_7:
name: Le Livre Scolaire
customer_8:
name: Arte
customer_9:
name: Canal +
customer_10:
name: TF1
customer_11:
name: Ouicar
customer_12:
name: Marcel
customer_13:
name: Yellow La Poste
customer_14:
name: Pichet
customer_15:
name: Carrus
customer_16:
name: Leroy Merlin
customer_17:
name: Decathlon
customer_18:
name: La Redoute
customer_19:
name: Colisweb
customer_20:
name: Accor
customer_21:
name: L'Etudiant
customer_22:
name: Aramis
customer_23:
name: Oui SNCF
customer_24:
name: Voyage SNCF
customer_25:
name: Alltricks
customer_26:
name: Trigone
customer_27:
name: Pages Jaunes
customer_28:
name: Radio France
customer_29:
name: Megalithe.co
customer_30:
name: NRJ
customer_31:
name: Le Monde
customer_32:
name: Dawex
customer_33:
name: Mandarine
customer_34:
name: Kering
customer_35:
name: Volvo
customer_36:
name: Société Générale
customer_37:
name: BNP
customer_38:
name: Sodexo
customer_39:
name: Keplr
customer_40:
name: Booster
30 changes: 30 additions & 0 deletions src/Entity/Customer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php


namespace App\Entity;

class Customer implements EntityInterface
{
use EntityTrait;

/** @var string */
private $name;

/**
* @return string
*/
public function getName(): ?string
{
return $this->name;
}

/**
* @param string $name
* @return Customer
*/
public function setName(string $name): Customer
{
$this->name = $name;
return $this;
}
}
35 changes: 35 additions & 0 deletions src/Migrations/Version20191127101445.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20191127101445 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('CREATE TABLE customer (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'Migration can only be executed safely on \'mysql\'.');

$this->addSql('DROP TABLE customer');
}
}
19 changes: 19 additions & 0 deletions src/Repository/CustomerRepository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php


namespace App\Repository;

use App\Entity\Customer;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Common\Persistence\ManagerRegistry;

class CustomerRepository extends ServiceEntityRepository implements RepositoryInterface
{
use RepositoryTrait;

public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Customer::class);
$this->registry = $registry;
}
}
29 changes: 29 additions & 0 deletions tests/Medium/Repository/CustomerRepositoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php


namespace App\Tests\Medium\Repository;

use App\Entity\Customer;
use App\Repository\CustomerRepository;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

class CustomerRepositoryTest extends KernelTestCase
{
use RepositoryTraitTest;

public function testRepositoryTrait()
{
$entity = new Customer();

$entity
->setName('M6')
;

$actual = self::$kernel->getContainer()
->get(CustomerRepository::class)->save($entity);

$this->assertSame($entity, $actual);

$this->initialState($actual);
}
}
24 changes: 24 additions & 0 deletions tests/Small/Entity/CustomerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php


namespace App\Tests\Small\Entity;

use App\Entity\Customer;
use PHPUnit\Framework\TestCase;

class CustomerTest extends TestCase implements GetterAndSetterInterface
{
use GetterTraitTest, SetterTraitTest;
/** {@inheritDoc} */
public function init()
{
return new Customer();
}
/** {@inheritDoc} */
public function providerProperty(): array
{
return [
['name', 'M6'],
];
}
}