ExtensionTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Bolt\Extension\YourName\ExtensionName\Tests;
  3. use Bolt\Tests\BoltUnitTest;
  4. use Bolt\Extension\YourName\ExtensionName\ExtensionNameExtension;
  5. /**
  6. * ExtensionName testing class.
  7. *
  8. * @author Your Name <you@example.com>
  9. */
  10. class ExtensionTest extends BoltUnitTest
  11. {
  12. /**
  13. * Ensure that the ExtensionName extension loads correctly.
  14. */
  15. public function testExtensionBasics()
  16. {
  17. $app = $this->getApp(false);
  18. $extension = new ExtensionNameExtension($app);
  19. $name = $extension->getName();
  20. $this->assertSame($name, 'ExtensionName');
  21. $this->assertInstanceOf('\Bolt\Extension\ExtensionInterface', $extension);
  22. }
  23. public function testExtensionComposerJson()
  24. {
  25. $composerJson = json_decode(file_get_contents(dirname(__DIR__) . '/composer.json'), true);
  26. // Check that the 'bolt-class' key correctly matches an existing class
  27. $this->assertArrayHasKey('bolt-class', $composerJson['extra']);
  28. $this->assertTrue(class_exists($composerJson['extra']['bolt-class']));
  29. // Check that the 'bolt-assets' key points to the correct directory
  30. $this->assertArrayHasKey('bolt-assets', $composerJson['extra']);
  31. $this->assertSame('web', $composerJson['extra']['bolt-assets']);
  32. }
  33. }