forked from klaussilveira/gitlist
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request klaussilveira#5 from GromNaN/tests
Reorganize tests dir to follow best pratices + add tests on commit import
- Loading branch information
Showing
5 changed files
with
97 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace Gitter\Tests\Model\Commit; | ||
|
||
use Gitter\Model\Commit\Commit; | ||
use Gitter\PrettyFormat; | ||
|
||
class CommitTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testImportData() | ||
{ | ||
$data = array ( | ||
'hash' => '209908f247194b1adc836f2e50f957cb1f11f41c', | ||
'short_hash' => '209908f', | ||
'tree' => '0a1f6638ccfc6d6b34be8a913144304355d23cc3', | ||
'parents' => '6e6951114ccf7b162e2a57b0462b39ca972f476f 1e8fd833f71fd20f8b176c79c705b9f096434126', | ||
'author' => 'The Author', | ||
'author_email' => 'author@example.com', | ||
'date' => '1347372763', | ||
'commiter' => 'The Commiter', | ||
'commiter_email' => 'commiter@example.com', | ||
'commiter_date' => '1347372763', | ||
'message' => 'Test commit', | ||
); | ||
$commit = new Commit(); | ||
$commit->importData($data); | ||
|
||
$this->assertEquals('209908f247194b1adc836f2e50f957cb1f11f41c', $commit->getHash()); | ||
$this->assertEquals('209908f', $commit->getShortHash()); | ||
$this->assertEquals('0a1f6638ccfc6d6b34be8a913144304355d23cc3', $commit->getTreeHash()); | ||
$this->assertEquals(array('6e6951114ccf7b162e2a57b0462b39ca972f476f', '1e8fd833f71fd20f8b176c79c705b9f096434126'), $commit->getParentsHash()); | ||
$this->assertEquals('The Author', $commit->getAuthor()->getName()); | ||
$this->assertEquals('author@example.com', $commit->getAuthor()->getEmail()); | ||
$this->assertEquals(new \DateTime('@1347372763'), $commit->getDate()); | ||
$this->assertEquals('The Commiter', $commit->getCommiter()->getName()); | ||
$this->assertEquals('commiter@example.com', $commit->getCommiter()->getEmail()); | ||
$this->assertEquals(new \DateTime('@1347372763'), $commit->getCommiterDate()); | ||
$this->assertEquals('Test commit', $commit->getMessage()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Gitter\Tests; | ||
|
||
use Gitter\PrettyFormat; | ||
|
||
class PrettyFormatTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @dataProvider dataForTestIsParsingPrettyXMLFormat | ||
*/ | ||
public function testIsParsingPrettyXMLFormat($xml, $expected) | ||
{ | ||
$format = new PrettyFormat(); | ||
|
||
$this->assertEquals($expected, $format->parse($xml)); | ||
} | ||
|
||
public function dataForTestIsParsingPrettyXMLFormat() | ||
{ | ||
return array( | ||
array( | ||
'<item><tag>value</tag><tag2>value2</tag2></item>', | ||
array(array('tag' => 'value', 'tag2' => 'value2')), | ||
), | ||
array( | ||
'<item><empty_tag></empty_tag></item>', | ||
array(array('empty_tag' => '')), | ||
), | ||
array( | ||
'<item><tag>item 1</tag></item><item><tag>item 2</tag></item>', | ||
array(array('tag' => 'item 1'), array('tag' => 'item 2')), | ||
), | ||
array( | ||
'<item><tag><inner_tag>value</inner_tag></tag></item>', | ||
array(array('tag' => array(array('inner_tag' => 'value')))), | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* @expectedException RuntimeException | ||
*/ | ||
public function testIsNotParsingWithoutData() | ||
{ | ||
$format = new PrettyFormat; | ||
$format->parse(''); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.