|
@@ 436-465 (lines=30) @@
|
| 433 |
|
} |
| 434 |
|
|
| 435 |
|
|
| 436 |
|
public function testPatchBulk() |
| 437 |
|
{ |
| 438 |
|
$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
| 439 |
|
|
| 440 |
|
$item = $productManagerStub->createItem(); |
| 441 |
|
$item->setLabel( 'test' ); |
| 442 |
|
$item->setId( '-1' ); |
| 443 |
|
|
| 444 |
|
$productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ); |
| 445 |
|
$productManagerStub->expects( $this->exactly( 6 ) )->method( 'getItem' ) // 6x due to decorator |
| 446 |
|
->will( $this->returnValue( $item ) ); |
| 447 |
|
|
| 448 |
|
|
| 449 |
|
$body = '{"data": [{"id": "-1", "type": "product", "attributes": {"product.label": "test"}}, {"id": "-1", "type": "product", "attributes": {"product.label": "test"}}]}'; |
| 450 |
|
$header = array(); |
| 451 |
|
$status = 500; |
| 452 |
|
|
| 453 |
|
$result = json_decode( $this->object->patch( $body, $header, $status ), true ); |
| 454 |
|
|
| 455 |
|
$this->assertEquals( 200, $status ); |
| 456 |
|
$this->assertEquals( 1, count( $header ) ); |
| 457 |
|
$this->assertEquals( 2, $result['meta']['total'] ); |
| 458 |
|
$this->assertArrayHasKey( 'data', $result ); |
| 459 |
|
$this->assertEquals( 2, count( $result['data'] ) ); |
| 460 |
|
$this->assertEquals( '-1', $result['data'][0]['id'] ); |
| 461 |
|
$this->assertEquals( 'product', $result['data'][0]['type'] ); |
| 462 |
|
$this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
| 463 |
|
$this->assertArrayNotHasKey( 'included', $result ); |
| 464 |
|
$this->assertArrayNotHasKey( 'errors', $result ); |
| 465 |
|
} |
| 466 |
|
|
| 467 |
|
|
| 468 |
|
public function testPatchInvalid() |
|
@@ 576-605 (lines=30) @@
|
| 573 |
|
} |
| 574 |
|
|
| 575 |
|
|
| 576 |
|
public function testPostBulk() |
| 577 |
|
{ |
| 578 |
|
$productManagerStub = $this->getProductMock( array( 'getItem', 'saveItem' ) ); |
| 579 |
|
|
| 580 |
|
$item = $productManagerStub->createItem(); |
| 581 |
|
$item->setLabel( 'test' ); |
| 582 |
|
$item->setId( '-1' ); |
| 583 |
|
|
| 584 |
|
$productManagerStub->expects( $this->exactly( 2 ) )->method( 'saveItem' ); |
| 585 |
|
$productManagerStub->expects( $this->exactly( 2 ) )->method( 'getItem' ) |
| 586 |
|
->will( $this->returnValue( $item ) ); |
| 587 |
|
|
| 588 |
|
|
| 589 |
|
$body = '{"data": [{"type": "product", "attributes": {"product.label": "test"}}, {"type": "product", "attributes": {"product.label": "test"}}]}'; |
| 590 |
|
$header = array(); |
| 591 |
|
$status = 500; |
| 592 |
|
|
| 593 |
|
$result = json_decode( $this->object->post( $body, $header, $status ), true ); |
| 594 |
|
|
| 595 |
|
$this->assertEquals( 201, $status ); |
| 596 |
|
$this->assertEquals( 1, count( $header ) ); |
| 597 |
|
$this->assertEquals( 2, $result['meta']['total'] ); |
| 598 |
|
$this->assertArrayHasKey( 'data', $result ); |
| 599 |
|
$this->assertEquals( 2, count( $result['data'] ) ); |
| 600 |
|
$this->assertEquals( '-1', $result['data'][0]['id'] ); |
| 601 |
|
$this->assertEquals( 'product', $result['data'][0]['type'] ); |
| 602 |
|
$this->assertEquals( 'test', $result['data'][0]['attributes']['product.label'] ); |
| 603 |
|
$this->assertArrayNotHasKey( 'included', $result ); |
| 604 |
|
$this->assertArrayNotHasKey( 'errors', $result ); |
| 605 |
|
} |
| 606 |
|
|
| 607 |
|
|
| 608 |
|
public function testPostInvalid() |