markTestIncomplete( 'Need to mock static function Permissions::Perms() ...' ); //$this->assertEquals($expected, Permissions::FilledPerms($permarr)); /* $perms = $this->getMockBuilder(Permissions::class) ->setMethods(['Perms']) ->getMock(); $perms->expects($this->once()) ->method('Perms'); // still calls the static self::Perms() $perms->FilledPerms($permarr); */ } public function FilledPermsProvider() { return [ 'empty' => [ [], ['perm1' => 0, 'perm2' => 0] ], 'valid' => [ [['perm1' => 1]], ['perm1' => 1, 'perm2' => 0] ] ]; } /* public function testFilledPermsNull() { // need to mock global function btlogger(); Permissions::FilledPerms(null); } */ /** * @dataProvider OPermsProvider * * @param array $permarr * @param array $expected */ public function testOPerms($permarr, $expected) { $this->assertEquals($expected, Permissions::OPerms($permarr)); } /** * @return Associative array with test values for OPerms() * * \e array Array to test * * \e array Expect array */ public function OPermsProvider() { return [ 'empty' => [ [], [] ], 'valid' => [ ['perm1' => 1, 'perm2' => 0], [['name' => 'perm1', 'value' => 1], ['name' => 'perm2', 'value' => 0]] ], 'null array' => [ null, [] ] ]; } /** * @dataProvider permsCompareProvider * * @param array $p1 * @param array $p2 * @param boolean $expectedresult */ public function testPermsCompare($p1, $p2, $expectedresult) { $this->assertEquals($expectedresult, Permissions::PermsCompare($p1, $p2)); } /** * @return Associative array with test values for PermsCompare() * * \e array 1st array * * \e array 2nd array * * \e boolean expected result for the test */ public function permsCompareProvider() { return [ 'equal' => [ ['perm1' => 1, 'perm2' => 0], ['perm1' => 1, 'perm2' => 0], true ], 'different values' => [ ['perm1' => 1, 'perm2' => 0], ['perm1' => 0, 'perm2' => 1], false ], 'different order' => [ ['perm1' => 1, 'perm2' => 0], ['perm2' => 0, 'perm1' => 1], true ], 'partial first in second' => [ ['perm1' => 1], ['perm1' => 1, 'perm2' => 0], true ], 'partial second in first' => [ ['perm1' => 1, 'perm2' => 0], ['perm1' => 1], false ] ]; } }