SymfonyComponentTranslationTestsLoaderCsvFileLoaderTest

The Simple Calendar Symfony Component Translation Tests Loader CsvFileLoaderTest class.

Defined (1)

The class is defined in the following location(s).

/vendor/symfony/translation/Tests/Loader/CsvFileLoaderTest.php  
  1. class CsvFileLoaderTest extends \PHPUnit_Framework_TestCase 
  2. public function testLoad() 
  3. $loader = new CsvFileLoader(); 
  4. $resource = __DIR__.'/../fixtures/resources.csv'; 
  5. $catalogue = $loader->load($resource, 'en', 'domain1'); 
  6.  
  7. $this->assertEquals(array('foo' => 'bar'), $catalogue->all('domain1')); 
  8. $this->assertEquals('en', $catalogue->getLocale()); 
  9. $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); 
  10.  
  11. public function testLoadDoesNothingIfEmpty() 
  12. $loader = new CsvFileLoader(); 
  13. $resource = __DIR__.'/../fixtures/empty.csv'; 
  14. $catalogue = $loader->load($resource, 'en', 'domain1'); 
  15.  
  16. $this->assertEquals(array(), $catalogue->all('domain1')); 
  17. $this->assertEquals('en', $catalogue->getLocale()); 
  18. $this->assertEquals(array(new FileResource($resource)), $catalogue->getResources()); 
  19.  
  20. /** 
  21. * @expectedException \Symfony\Component\Translation\Exception\NotFoundResourceException 
  22. */ 
  23. public function testLoadNonExistingResource() 
  24. $loader = new CsvFileLoader(); 
  25. $resource = __DIR__.'/../fixtures/not-exists.csv'; 
  26. $loader->load($resource, 'en', 'domain1'); 
  27.  
  28. /** 
  29. * @expectedException \Symfony\Component\Translation\Exception\InvalidResourceException 
  30. */ 
  31. public function testLoadNonLocalResource() 
  32. $loader = new CsvFileLoader(); 
  33. $resource = 'http://example.com/resources.csv'; 
  34. $loader->load($resource, 'en', 'domain1');