Skip to content

Commit

Permalink
Adding a test case to ensure our changes are fine
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanta94 committed Nov 8, 2024
1 parent 2751950 commit f68cd64
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/slr_integration/Admin_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace TEC\Tickets\Seating\Admin;

use tad\Codeception\SnapshotAssertions\SnapshotAssertions;
use TEC\Common\StellarWP\Assets\Assets;
use TEC\Common\Tests\Provider\Controller_Test_Case;
use TEC\Tickets\Seating\Admin;
use TEC\Tickets\Seating\Admin\Tabs\Layout_Edit;
Expand Down Expand Up @@ -30,6 +31,37 @@ public function mock_admin_context(): void {
wp_set_current_user( self::factory()->user->create( [ 'role' => 'administrator' ] ) );
}

public function asset_data_provider() {
$assets = [
'tec-tickets-seating-admin-maps' => '/build/Seating/admin/maps.js',
'tec-tickets-seating-admin-maps-style' => '/build/Seating/admin/maps.css',
'tec-tickets-seating-admin-layouts' => '/build/Seating/admin/layouts.js',
'tec-tickets-seating-admin-layouts-style' => '/build/Seating/admin/layouts.css',
'tec-tickets-seating-admin-map-edit' => '/build/Seating/admin/mapEdit.js',
'tec-tickets-seating-admin-map-edit-style' => '/build/Seating/admin/mapEdit.css',
'tec-tickets-seating-admin-layout-edit' => '/build/Seating/admin/layoutEdit.js',
'tec-tickets-seating-admin-layout-edit-style' => '/build/Seating/admin/layoutEdit.css',
];

foreach ( $assets as $slug => $path ) {
yield $slug => [ $slug, $path ];
}
}

/**
* @test
* @dataProvider asset_data_provider
*/
public function it_should_locate_assets_where_expected( $slug, $path ) {
$this->make_controller()->register();

$this->assertTrue( Assets::init()->exists( $slug ) );

// We use false, because in CI mode the assets are not build so min aren't available. Its enough to check that the non-min is as expected.
$asset_url = Assets::init()->get( $slug )->get_url( false );
$this->assertEquals( plugins_url( $path, EVENT_TICKETS_MAIN_PLUGIN_FILE ), $asset_url );
}

public function tabs_data_provider(): array {
return [
'no tab' => [
Expand Down

0 comments on commit f68cd64

Please sign in to comment.