|
@@ 94-119 (lines=26) @@
|
| 91 |
|
/** |
| 92 |
|
* @test |
| 93 |
|
*/ |
| 94 |
|
public function postSingle() |
| 95 |
|
{ |
| 96 |
|
$data = array('name' => 'Random Joe', 'dateOfBirth' => '1970-01-01'); |
| 97 |
|
|
| 98 |
|
$product = new Product(); |
| 99 |
|
$product->setName($data['name']); |
| 100 |
|
$product->setDateOfBirth($data['dateOfBirth']); |
| 101 |
|
|
| 102 |
|
$entityManager = $this->getMockBuilder('Managlea\Component\EntityManager\DoctrineEntityManager') |
| 103 |
|
->disableOriginalConstructor() |
| 104 |
|
->getMock(); |
| 105 |
|
$entityManager->method('create') |
| 106 |
|
->willReturn($product); |
| 107 |
|
|
| 108 |
|
$entityManagerFactory = $this->getMockBuilder('Managlea\Component\EntityManagerFactory') |
| 109 |
|
->disableOriginalConstructor() |
| 110 |
|
->getMock(); |
| 111 |
|
$entityManagerFactory->method('create') |
| 112 |
|
->willReturn($entityManager); |
| 113 |
|
$resourceMapper = new ResourceMapper; |
| 114 |
|
|
| 115 |
|
$resourceHandler = ResourceHandler::initialize($entityManagerFactory, $resourceMapper); |
| 116 |
|
|
| 117 |
|
$resource = $resourceHandler->postSingle('product', $data); |
| 118 |
|
$this->assertEquals($data['name'], $resource->getName()); |
| 119 |
|
} |
| 120 |
|
|
| 121 |
|
/** |
| 122 |
|
* @test |
|
@@ 124-149 (lines=26) @@
|
| 121 |
|
/** |
| 122 |
|
* @test |
| 123 |
|
*/ |
| 124 |
|
public function putSingle() |
| 125 |
|
{ |
| 126 |
|
$data = array('name' => 'Random Joe', 'dateOfBirth' => '1970-01-02'); |
| 127 |
|
|
| 128 |
|
$product = new Product(); |
| 129 |
|
$product->setName($data['name']); |
| 130 |
|
$product->setDateOfBirth($data['dateOfBirth']); |
| 131 |
|
|
| 132 |
|
$entityManager = $this->getMockBuilder('Managlea\Component\EntityManager\DoctrineEntityManager') |
| 133 |
|
->disableOriginalConstructor() |
| 134 |
|
->getMock(); |
| 135 |
|
$entityManager->method('update') |
| 136 |
|
->willReturn($product); |
| 137 |
|
|
| 138 |
|
$entityManagerFactory = $this->getMockBuilder('Managlea\Component\EntityManagerFactory') |
| 139 |
|
->disableOriginalConstructor() |
| 140 |
|
->getMock(); |
| 141 |
|
$entityManagerFactory->method('create') |
| 142 |
|
->willReturn($entityManager); |
| 143 |
|
$resourceMapper = new ResourceMapper; |
| 144 |
|
|
| 145 |
|
$resourceHandler = ResourceHandler::initialize($entityManagerFactory, $resourceMapper); |
| 146 |
|
|
| 147 |
|
$resource = $resourceHandler->putSingle('product', 1, $data); |
| 148 |
|
$this->assertEquals($data['name'], $resource->getName()); |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
/** |
| 152 |
|
* @test |