CRM-15104 - Rewrote the unit test.
authorJohan Vervloet <johan.vervloet@gmail.com>
Wed, 13 Aug 2014 13:37:51 +0000 (15:37 +0200)
committerJohan Vervloet <johan.vervloet@gmail.com>
Wed, 13 Aug 2014 13:37:51 +0000 (15:37 +0200)
I think Jenkins didn't like my unit test. It showed this
message:

PHP Parse error:  syntax error, unexpected '[' in
/srv/buildkit/build/build-3/sites/all/modules/civicrm/tests/phpunit/api/v3/ParticipantTest.php
on line 492

I rewrote the unit test with less '[' on that line. Hoping that Jenkins
will be happy now :-)

----------------------------------------
* CRM-15104: Line item issues when creating a participant using the API
  https://issues.civicrm.org/jira/browse/CRM-15104

tests/phpunit/api/v3/ParticipantTest.php

index 352201cdef3a3bb0c0de98ca3df9b45d6b88e1e2..91ca2e99f45efc9a210b44036f50246abf8d372d 100644 (file)
@@ -489,12 +489,16 @@ class api_v3_ParticipantTest extends CiviUnitTestCase {
     // Check quantity, label and unit price of lines.
     // TODO: These assertions depend on the order of the line items, which is 
     // technically incorrect.
-    $this->assertEquals(2, array_values($lineItems['values'])[0]['qty']);
-    $this->assertEquals(20, array_values($lineItems['values'])[0]['unit_price']);
-    $this->assertEquals('pricefieldvalue1', array_values($lineItems['values'])[0]['label']);
-    $this->assertEquals(2, array_values($lineItems['values'])[1]['qty']);
-    $this->assertEquals(5, array_values($lineItems['values'])[1]['unit_price']);
-    $this->assertEquals('pricefieldvalue2', array_values($lineItems['values'])[1]['label']);
+
+    $lineItem = array_pop($lineItems['values']);
+    $this->assertEquals(2, $lineItem['qty']);
+    $this->assertEquals(5, $lineItem['unit_price']);
+    $this->assertEquals('pricefieldvalue2', $lineItem['label']);
+
+    $lineItem = array_pop($lineItems['values']);
+    $this->assertEquals(2, $lineItem['qty']);
+    $this->assertEquals(20, $lineItem['unit_price']);
+    $this->assertEquals('pricefieldvalue1', $lineItem['label']);
 
     // Cleanup
     $this->callAPISuccess('participant', 'delete', array('id' => $participant['id']));