|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the BibTex Parser. |
| 5 | + * |
| 6 | + * (c) Renan de Lima Barbosa <renandelima@gmail.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace RenanBr\BibTexParser\Test\Parser; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use RenanBr\BibTexParser\Parser; |
| 16 | +use RenanBr\BibTexParser\Test\DummyListener; |
| 17 | + |
| 18 | +/** |
| 19 | + * @covers \RenanBr\BibTexParser\Parser |
| 20 | + */ |
| 21 | +class CitationKeyTest extends TestCase |
| 22 | +{ |
| 23 | + /** |
| 24 | + * @group regression |
| 25 | + * @group bug44 |
| 26 | + * |
| 27 | + * @see https://github.com/renanbr/bibtex-parser/issues/44 |
| 28 | + */ |
| 29 | + public function testDBLPCitationKey() |
| 30 | + { |
| 31 | + $listener = new DummyListener(); |
| 32 | + |
| 33 | + $parser = new Parser(); |
| 34 | + $parser->addListener($listener); |
| 35 | + $parser->parseString('@Article{DBLP:journals/npl/CaamanoSBD16}'); |
| 36 | + |
| 37 | + // 0 -> type |
| 38 | + // 1 -> citation key |
| 39 | + // 2 -> original entry |
| 40 | + $this->assertCount(3, $listener->calls); |
| 41 | + list($text, $type) = $listener->calls[1]; |
| 42 | + |
| 43 | + $this->assertSame('DBLP:journals/npl/CaamanoSBD16', $text); |
| 44 | + $this->assertSame(Parser::CITATION_KEY, $type); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @group regression |
| 49 | + * @group bug44 |
| 50 | + * |
| 51 | + * @see https://github.com/renanbr/bibtex-parser/issues/44 |
| 52 | + */ |
| 53 | + public function testACMCitationKey() |
| 54 | + { |
| 55 | + $listener = new DummyListener(); |
| 56 | + |
| 57 | + $parser = new Parser(); |
| 58 | + $parser->addListener($listener); |
| 59 | + $parser->parseString('@inproceedings{Kyriakakis:2016:EMI:3003733.3003777}'); |
| 60 | + |
| 61 | + // 0 -> type |
| 62 | + // 1 -> citation key |
| 63 | + // 2 -> original entry |
| 64 | + $this->assertCount(3, $listener->calls); |
| 65 | + list($text, $type) = $listener->calls[1]; |
| 66 | + |
| 67 | + $this->assertSame('Kyriakakis:2016:EMI:3003733.3003777', $text); |
| 68 | + $this->assertSame(Parser::CITATION_KEY, $type); |
| 69 | + } |
| 70 | +} |
0 commit comments