EnvTest.php 875 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace JmesPath\Tests;
  3. use JmesPath\Env;
  4. use JmesPath\CompilerRuntime;
  5. class EnvTest extends \PHPUnit_Framework_TestCase
  6. {
  7. public function testSearchesInput()
  8. {
  9. $data = array('foo' => 123);
  10. $this->assertEquals(123, Env::search('foo', $data));
  11. $this->assertEquals(123, Env::search('foo', $data));
  12. }
  13. public function testSearchesWithFunction()
  14. {
  15. $data = array('foo' => 123);
  16. $this->assertEquals(123, \JmesPath\search('foo', $data));
  17. }
  18. public function testCleansCompileDir()
  19. {
  20. $dir = sys_get_temp_dir();
  21. $runtime = new CompilerRuntime($dir);
  22. $runtime('@ | @ | @[0][0][0]', []);
  23. $this->assertNotEmpty(glob($dir . '/jmespath_*.php'));
  24. $this->assertGreaterThan(0, Env::cleanCompileDir());
  25. $this->assertEmpty(glob($dir . '/jmespath_*.php'));
  26. }
  27. }