/**
  * Test active record array deleteFull() where canDelete has been set to false
  *
  * @expectedException        \fangface\db\Exception
  * @expectedExceptionMessage Attempting to delete Item(s) model flagged as not deletable
  */
 function testActiveRecordDeleteFullOnNonCanDeleteArrayFails()
 {
     $client = Client::findOne(1);
     $this->assertInstanceOf(Client::className(), $client);
     $this->setService('client', $client);
     $customerId = $this->createTestCustomerAndOrder($client->clientCode);
     $this->assertTrue($customerId !== false && $customerId > 0);
     $this->checkBaseCounts('full', $client->clientCode);
     $customer = Customer::findOne($customerId);
     $this->assertInstanceOf(Customer::className(), $customer);
     $customer->orders[1]->items->setCanDelete(false);
     $customer->orders[1]->items->deleteFull();
 }
Ejemplo n.º 2
0
 /**
  * Amend customer id at top level of a relation and test that a push()
  * request forces relations that have customerId set are updated even though
  * no other changes have been made
  */
 function testActiveRecordChangeTopLevelIdFeedsDownToRelations()
 {
     $client = Client::findOne(1);
     $this->assertInstanceOf(Client::className(), $client);
     $this->setService('client', $client);
     $customerId = $this->createTestCustomerAndOrder($client->clientCode);
     $this->assertTrue($customerId !== false && $customerId > 0);
     $this->checkBaseCounts('full', $client->clientCode);
     $customer = Customer::findOne($customerId);
     $this->assertInstanceOf(Customer::className(), $customer);
     $customer->id = 95;
     $customerPreChangeWithNewId = $this->updateCustomerIdForComparison($this->cleanDatesForComparison($customer->toArray()), 95);
     $customer->push();
     $customer = Customer::findOne(95);
     $this->assertInstanceOf(Customer::className(), $customer);
     $customerReloaded = $this->cleanDatesForComparison($customer->toArray());
     $this->assertEquals($customerPreChangeWithNewId, $customerReloaded, 'Failed to push new customerId into relations after reload');
 }