/** * Determine the superfluous authors from the passed arrays. * * @param array $mentionedAuthors The author list containing the current state. * * @param array $wantedAuthors The author list containing the desired state. * * @param string $path The path to relate to. * * @return array */ private function determineSuperfluous($mentionedAuthors, $wantedAuthors, $path) { $superfluous = array(); foreach (array_diff_key($mentionedAuthors, $wantedAuthors) as $key => $author) { if (!$this->config->isCopyLeftAuthor($author, $path)) { $superfluous[$key] = $author; } } return $superfluous; }
/** * Test the author mapping. * * @return void */ public function testCopyLeftAuthors() { $config = new Config(); $config->addCopyLeft('Copy Left <*****@*****.**>', 'File.php'); $config->addCopyLeft('Copy Left <*****@*****.**>', array('File2.php', '/lib/**')); $config->addCopyLeft('Copy Left2 <*****@*****.**>', 'some/dir/File4.php'); $this->assertTrue($config->isCopyLeftAuthor('Copy Left <*****@*****.**>', '/some/dir/File.php')); $this->assertTrue($config->isCopyLeftAuthor('Copy Left <*****@*****.**>', '/some/dir/File2.php')); $this->assertTrue($config->isCopyLeftAuthor('Copy Left <*****@*****.**>', '/lib/dir/File.php')); $this->assertFalse($config->isCopyLeftAuthor('Copy Left <*****@*****.**>', '/some/dir/File3.php')); $this->assertFalse($config->isCopyLeftAuthor('Unknown <*****@*****.**>', '/some/dir/File3.php')); $this->assertTrue($config->isCopyLeftAuthor('Copy Left2 <*****@*****.**>', '/lib/some/dir/File4.php')); $this->assertTrue($config->isCopyLeftAuthor('Copy Left2 <*****@*****.**>', '/some/dir/File4.php')); }