public function testExchangeArraySetsPropertiesCorrectly()
 {
     $supplier = new Supplier();
     $data = array('supplier_name' => 'some supplier', 'id' => 123);
     $supplier->exchangeArray($data);
     $this->assertSame($data['supplier_name'], $supplier->supplier_name, '"supplier_name" was not set correctly');
     $this->assertSame($data['id'], $supplier->id, '"id" was not set correctly');
 }
 public function testSaveSupplierWillUpdateExistingSupplierIfTheyAlreadyHaveAnId()
 {
     $supplierData = array('id' => 123, 'supplier_name' => 'My Supplier');
     $supplier = new Supplier();
     $supplier->exchangeArray($supplierData);
     $resultSet = new ResultSet();
     $resultSet->setArrayObjectPrototype(new Supplier());
     $resultSet->initialize(array($supplier));
     $mockTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select', 'update'), array(), '', false);
     $mockTableGateway->expects($this->once())->method('select')->with(array('id' => 123))->will($this->returnValue($resultSet));
     $mockTableGateway->expects($this->once())->method('update')->with(array('supplier_name' => 'My Supplier'), array('id' => 123));
     $supplierTable = new SupplierTable($mockTableGateway);
     $supplierTable->saveSupplier($supplier);
 }