2020-01-01 19:32:07 +01:00
< ? php
2020-02-22 18:14:36 +01:00
/**
* This file is part of Part - DB ( https :// github . com / Part - DB / Part - DB - symfony ) .
*
2022-11-29 22:37:33 +01:00
* Copyright ( C ) 2019 - 2022 Jan Böhmer ( https :// github . com / jbtronics )
2020-02-22 18:14:36 +01:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU Affero General Public License for more details .
*
* You should have received a copy of the GNU Affero General Public License
* along with this program . If not , see < https :// www . gnu . org / licenses />.
*/
2020-01-05 15:55:16 +01:00
declare ( strict_types = 1 );
2020-01-01 19:32:07 +01:00
namespace App\Tests ;
2022-08-14 19:32:53 +02:00
use Generator ;
2020-01-01 19:32:07 +01:00
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase ;
/**
2020-01-04 20:24:09 +01:00
* This test just ensures that different pages are available ( do not throw an exception ) .
*
2020-01-02 23:03:25 +01:00
* @ group DB
* @ group slow
2020-01-01 19:32:07 +01:00
*/
class ApplicationAvailabilityFunctionalTest extends WebTestCase
{
/**
* @ dataProvider urlProvider
*/
2020-01-04 20:24:09 +01:00
public function testPageIsSuccessful ( string $url ) : void
2020-01-01 19:32:07 +01:00
{
//We have localized routes
2020-01-04 20:24:09 +01:00
$url = '/en' . $url ;
2020-01-01 19:32:07 +01:00
//Try to access pages with admin, because he should be able to view every page!
2020-03-29 18:24:10 +02:00
static :: ensureKernelShutdown ();
2020-01-01 19:32:07 +01:00
$client = static :: createClient ([], [
'PHP_AUTH_USER' => 'admin' ,
'PHP_AUTH_PW' => 'test' ,
]);
2020-03-29 18:24:10 +02:00
$client -> catchExceptions ( false );
2020-01-01 19:32:07 +01:00
$client -> request ( 'GET' , $url );
2022-11-27 16:16:22 +01:00
$this -> assertTrue ( $client -> getResponse () -> isSuccessful (), 'Request not successful. Status code is ' . $client -> getResponse () -> getStatusCode () . ' for URL ' . $url );
2020-01-01 19:32:07 +01:00
}
2022-08-14 19:32:53 +02:00
public function urlProvider () : ? Generator
2020-01-01 19:32:07 +01:00
{
//Homepage
2022-11-27 16:35:44 +01:00
yield [ '/' ];
2020-01-01 19:32:07 +01:00
//User related things
yield [ '/user/settings' ];
yield [ '/user/info' ];
//Login/logout
yield [ '/login' ];
//Tree views
yield [ '/tree/tools' ];
yield [ '/tree/category/1' ];
yield [ '/tree/categories' ];
yield [ '/tree/footprint/1' ];
yield [ '/tree/footprints' ];
yield [ '/tree/location/1' ];
yield [ '/tree/locations' ];
yield [ '/tree/manufacturer/1' ];
yield [ '/tree/manufacturers' ];
yield [ '/tree/supplier/1' ];
yield [ '/tree/suppliers' ];
//yield ['/tree/device/1'];
yield [ '/tree/devices' ];
2020-02-09 22:10:29 +01:00
//Part tests
yield [ '/part/1' ];
yield [ '/part/2' ];
yield [ '/part/3' ];
yield [ '/part/1/edit' ];
yield [ '/part/2/edit' ];
yield [ '/part/3/edit' ];
2020-02-02 19:58:55 +01:00
2020-04-09 14:23:26 +02:00
yield [ '/part/3/clone' ];
2023-11-24 23:13:15 +01:00
yield [ '/part/1/merge/2' ];
2020-04-09 14:23:26 +02:00
yield [ '/part/new' ];
yield [ '/part/new?category=1&footprint=1&manufacturer=1&storelocation=1&supplier=1' ];
2023-03-14 00:02:40 +01:00
//Parts import
yield [ '/parts/import' ];
2020-04-09 13:25:50 +02:00
//Statistics
yield [ '/statistics' ];
2022-11-27 16:35:44 +01:00
//Event log
yield [ '/log/' ]; //Slash suffix here is important
2020-01-01 19:32:07 +01:00
//Typeahead
2020-05-22 22:24:16 +02:00
yield [ '/typeahead/builtInResources/search?query=DIP8' ];
2020-01-01 19:32:07 +01:00
yield [ '/typeahead/tags/search/test' ];
2022-11-27 16:35:44 +01:00
yield [ '/typeahead/parameters/part/search/NPN' ];
yield [ '/typeahead/parameters/category/search/NPN' ];
//Select API
yield [ '/select_api/category' ];
yield [ '/select_api/footprint' ];
yield [ '/select_api/manufacturer' ];
yield [ '/select_api/measurement_unit' ];
2020-05-10 13:28:01 +02:00
//Label test
yield [ '/label/dialog' ];
yield [ '/label/dialog?target_id=1&target_type=part' ];
yield [ '/label/1/dialog' ];
yield [ '/label/1/dialog?target_id=1&target_type=part&generate=1' ];
2020-06-03 22:19:59 +02:00
2023-07-02 14:03:29 +02:00
//Scan test
yield [ '/scan' ]; //Interactive scan dialog
2020-06-03 22:19:59 +02:00
//Tools
yield [ '/tools/reel_calc' ];
2022-11-27 16:35:44 +01:00
yield [ '/tools/server_infos' ];
2023-01-09 23:40:54 +01:00
yield [ '/tools/builtin_footprints' ];
2023-01-12 00:14:31 +01:00
yield [ '/tools/ic_logos' ];
2022-11-27 16:35:44 +01:00
//Webauthn Register
yield [ '/webauthn/register' ];
2023-01-08 23:22:53 +01:00
//Projects
yield [ '/project/1/info' ];
yield [ '/project/1/add_parts' ];
yield [ '/project/1/add_parts?parts=1,2' ];
2023-01-22 23:51:59 +01:00
yield [ '/project/1/build?n=1' ];
2023-03-16 23:39:28 +01:00
yield [ '/project/1/import_bom' ];
2023-07-16 23:56:30 +02:00
//Test info provider system
yield [ '/tools/info_providers/providers' ]; //List all providers
yield [ '/tools/info_providers/search' ]; //Search page
2023-11-24 23:13:15 +01:00
yield [ '/tools/info_providers/update/1' ]; //Update search for part from info provider
2023-07-16 23:56:30 +02:00
yield [ '/part/from_info_provider/test/element1/create' ]; //Create part from info provider
2023-11-24 23:13:15 +01:00
yield [ '/part/1/from_info_provider/test/element1/update' ]; //Update part from info provider
2020-01-01 19:32:07 +01:00
}
2020-01-04 20:24:09 +01:00
}