/** * Tests the JAccessRule::mergeIdentities method. * * @return void * * @since 11.1 * @covers JAccessRule::mergeIdentities */ public function testMergeIdentities() { $array = array(-42 => 1, 2 => 1, 3 => 0); // Construct an rule with no identities. $rule = new JAccessRule(''); $rule->mergeIdentities($array); $this->assertEquals(json_encode($array), (string) $rule); // Check that import equals export. // Test testMergeIdentities with object $rule_A = new JAccessRule($array); $rule->mergeIdentities($rule_A); $this->assertEquals(json_encode($array), (string) $rule); $this->assertEquals((string) $rule_A, (string) $rule); // Merge a new set, flipping some bits. $array = array(-42 => 0, 2 => 1, 3 => 1, 4 => 1); // Ident 3 should remain false, 4 should be added. $result = array(-42 => 0, 2 => 1, 3 => 0, 4 => 1); $rule->mergeIdentities($array); $this->assertEquals(json_encode($result), (string) $rule); }