mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
First steps at getting dusk working
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
4c2d47e7c6
commit
d08c1787a1
105
.env.dusk.local
Normal file
105
.env.dusk.local
Normal file
|
@ -0,0 +1,105 @@
|
|||
# --------------------------------------------
|
||||
# REQUIRED: BASIC APP SETTINGS
|
||||
# --------------------------------------------
|
||||
APP_ENV=local
|
||||
APP_DEBUG=false
|
||||
APP_KEY=base64:hTUIUh9CP6dQx+6EjSlfWTgbaMaaRvlpEwk45vp+xmk=
|
||||
APP_URL=http://127.0.0.1:8000
|
||||
APP_TIMEZONE='US/Eastern'
|
||||
APP_LOCALE=en
|
||||
APP_LOCKED=false
|
||||
MAX_RESULTS=200
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: UPLOADED FILE STORAGE SETTINGS
|
||||
# --------------------------------------------
|
||||
PRIVATE_FILESYSTEM_DISK=local
|
||||
PUBLIC_FILESYSTEM_DISK=local_public
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: DATABASE SETTINGS
|
||||
# --------------------------------------------
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=snipeit-local
|
||||
DB_USERNAME=snipeit-local
|
||||
DB_PASSWORD=snipeit-local
|
||||
DB_PREFIX=null
|
||||
DB_DUMP_PATH='/Applications/MAMP/Library/bin'
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: SSL DATABASE SETTINGS
|
||||
# --------------------------------------------
|
||||
DB_SSL=false
|
||||
DB_SSL_KEY_PATH=null
|
||||
DB_SSL_CERT_PATH=null
|
||||
DB_SSL_CA_PATH=null
|
||||
DB_SSL_CIPHER=null
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: OUTGOING MAIL SERVER SETTINGS
|
||||
# --------------------------------------------
|
||||
MAIL_DRIVER="log"
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# REQUIRED: IMAGE LIBRARY
|
||||
# This should be gd or imagick
|
||||
# --------------------------------------------
|
||||
IMAGE_LIB=gd
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: SESSION SETTINGS
|
||||
# --------------------------------------------
|
||||
SESSION_LIFETIME=12000
|
||||
EXPIRE_ON_CLOSE=false
|
||||
ENCRYPT=true
|
||||
COOKIE_NAME=snipeit_v5_local
|
||||
SECURE_COOKIES=true
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: SECURITY HEADER SETTINGS
|
||||
# --------------------------------------------
|
||||
REFERRER_POLICY=same-origin
|
||||
ENABLE_CSP=true
|
||||
CORS_ALLOWED_ORIGINS="*"
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: CACHE SETTINGS
|
||||
# --------------------------------------------
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: LOGIN THROTTLING
|
||||
# --------------------------------------------
|
||||
LOGIN_MAX_ATTEMPTS=50000
|
||||
LOGIN_LOCKOUT_DURATION=1000
|
||||
RESET_PASSWORD_LINK_EXPIRES=15
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: API
|
||||
# --------------------------------------------
|
||||
API_MAX_REQUESTS_PER_HOUR=200
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: SAML SETTINGS
|
||||
# --------------------------------------------
|
||||
DISABLE_NOSAML_LOCAL_LOGIN=true
|
||||
|
||||
|
||||
# --------------------------------------------
|
||||
# OPTIONAL: MISC
|
||||
# --------------------------------------------
|
||||
APP_LOG=single
|
||||
LOG_LEVEL=debug
|
||||
LOG_CHANNEL=stack
|
||||
LOG_SLACK_WEBHOOK_URL=null
|
||||
APP_TRUSTED_PROXIES=192.168.1.1,10.0.0.1
|
||||
ALLOW_IFRAMING=true
|
||||
ENABLE_HSTS=false
|
||||
WARN_DEBUG=false
|
||||
APP_CIPHER=AES-256-CBC
|
||||
|
|
@ -61,8 +61,15 @@ class AppServiceProvider extends ServiceProvider
|
|||
*/
|
||||
public function register()
|
||||
{
|
||||
// Only load rollbar if there is a rollbar key and the app is in production
|
||||
if (($this->app->environment('production')) && (config('logging.channels.rollbar.access_token'))) {
|
||||
$this->app->register(\Rollbar\Laravel\RollbarServiceProvider::class);
|
||||
}
|
||||
}
|
||||
|
||||
// Only load dusk's service provider if the app is in local or develop mode
|
||||
if ($this->app->environment(['local', 'develop'])) {
|
||||
$this->app->register(\Laravel\Dusk\DuskServiceProvider::class);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
275
c3.php
275
c3.php
|
@ -1,275 +0,0 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreFile
|
||||
// @codeCoverageIgnoreStart
|
||||
|
||||
/**
|
||||
* C3 - Codeception Code Coverage
|
||||
*
|
||||
* @author tiger
|
||||
*/
|
||||
|
||||
// $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'] = 1;
|
||||
|
||||
if (isset($_COOKIE['CODECEPTION_CODECOVERAGE'])) {
|
||||
$cookie = json_decode($_COOKIE['CODECEPTION_CODECOVERAGE'], true);
|
||||
|
||||
// fix for improperly encoded JSON in Code Coverage cookie with WebDriver.
|
||||
// @see https://github.com/Codeception/Codeception/issues/874
|
||||
if (!is_array($cookie)) {
|
||||
$cookie = json_decode($cookie, true);
|
||||
}
|
||||
|
||||
if ($cookie) {
|
||||
foreach ($cookie as $key => $value) {
|
||||
$_SERVER["HTTP_X_CODECEPTION_".strtoupper($key)] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE', $_SERVER)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!function_exists('__c3_error')) {
|
||||
function __c3_error($message)
|
||||
{
|
||||
$errorLogFile = defined('C3_CODECOVERAGE_ERROR_LOG_FILE') ?
|
||||
C3_CODECOVERAGE_ERROR_LOG_FILE :
|
||||
C3_CODECOVERAGE_MEDIATE_STORAGE . DIRECTORY_SEPARATOR . 'error.txt';
|
||||
if (is_writable($errorLogFile)) {
|
||||
file_put_contents($errorLogFile, $message);
|
||||
}else{
|
||||
$message = "Could not write error to log file ($errorLogFile), original message: $message";
|
||||
}
|
||||
if (!headers_sent()) {
|
||||
header('X-Codeception-CodeCoverage-Error: ' . str_replace("\n", ' ', $message), true, 500);
|
||||
}
|
||||
setcookie('CODECEPTION_CODECOVERAGE_ERROR', $message);
|
||||
}
|
||||
}
|
||||
|
||||
// phpunit codecoverage shimming
|
||||
if (class_exists('SebastianBergmann\CodeCoverage\CodeCoverage')) {
|
||||
class_alias('SebastianBergmann\CodeCoverage\CodeCoverage', 'PHP_CodeCoverage');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\Text', 'PHP_CodeCoverage_Report_Text');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\PHP', 'PHP_CodeCoverage_Report_PHP');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\Clover', 'PHP_CodeCoverage_Report_Clover');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Report\Html\Facade', 'PHP_CodeCoverage_Report_HTML');
|
||||
class_alias('SebastianBergmann\CodeCoverage\Exception', 'PHP_CodeCoverage_Exception');
|
||||
}
|
||||
|
||||
// Autoload Codeception classes
|
||||
if (!class_exists('\\Codeception\\Codecept')) {
|
||||
if (file_exists(__DIR__ . '/codecept.phar')) {
|
||||
require_once 'phar://'.__DIR__ . '/codecept.phar/autoload.php';
|
||||
} elseif (stream_resolve_include_path(__DIR__ . '/vendor/autoload.php')) {
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
// Required to load some methods only available at codeception/autoload.php
|
||||
if (stream_resolve_include_path(__DIR__ . '/vendor/codeception/codeception/autoload.php')) {
|
||||
require_once __DIR__ . '/vendor/codeception/codeception/autoload.php';
|
||||
}
|
||||
} elseif (stream_resolve_include_path('Codeception/autoload.php')) {
|
||||
require_once 'Codeception/autoload.php';
|
||||
} else {
|
||||
__c3_error('Codeception is not loaded. Please check that either PHAR or Composer or PEAR package can be used');
|
||||
}
|
||||
}
|
||||
|
||||
// Load Codeception Config
|
||||
$config_dist_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.dist.yml';
|
||||
$config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . 'codeception.yml';
|
||||
|
||||
if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'])) {
|
||||
$config_file = realpath(__DIR__) . DIRECTORY_SEPARATOR . $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_CONFIG'];
|
||||
}
|
||||
if (file_exists($config_file)) {
|
||||
// Use codeception.yml for configuration.
|
||||
} elseif (file_exists($config_dist_file)) {
|
||||
// Use codeception.dist.yml for configuration.
|
||||
$config_file = $config_dist_file;
|
||||
} else {
|
||||
__c3_error(sprintf("Codeception config file '%s' not found", $config_file));
|
||||
}
|
||||
try {
|
||||
\Codeception\Configuration::config($config_file);
|
||||
} catch (\Exception $e) {
|
||||
__c3_error($e->getMessage());
|
||||
}
|
||||
|
||||
if (!defined('C3_CODECOVERAGE_MEDIATE_STORAGE')) {
|
||||
|
||||
// workaround for 'zend_mm_heap corrupted' problem
|
||||
gc_disable();
|
||||
|
||||
if ((integer)ini_get('memory_limit') < 384) {
|
||||
ini_set('memory_limit', '384M');
|
||||
}
|
||||
|
||||
define('C3_CODECOVERAGE_MEDIATE_STORAGE', Codeception\Configuration::logDir() . 'c3tmp');
|
||||
define('C3_CODECOVERAGE_PROJECT_ROOT', Codeception\Configuration::projectDir());
|
||||
define('C3_CODECOVERAGE_TESTNAME', $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE']);
|
||||
|
||||
function __c3_build_html_report(PHP_CodeCoverage $codeCoverage, $path)
|
||||
{
|
||||
$writer = new PHP_CodeCoverage_Report_HTML();
|
||||
$writer->process($codeCoverage, $path . 'html');
|
||||
|
||||
if (file_exists($path . '.tar')) {
|
||||
unlink($path . '.tar');
|
||||
}
|
||||
|
||||
$phar = new PharData($path . '.tar');
|
||||
$phar->setSignatureAlgorithm(Phar::SHA1);
|
||||
$files = $phar->buildFromDirectory($path . 'html');
|
||||
array_map('unlink', $files);
|
||||
|
||||
if (in_array('GZ', Phar::getSupportedCompression())) {
|
||||
if (file_exists($path . '.tar.gz')) {
|
||||
unlink($path . '.tar.gz');
|
||||
}
|
||||
|
||||
$phar->compress(\Phar::GZ);
|
||||
|
||||
// close the file so that we can rename it
|
||||
unset($phar);
|
||||
|
||||
unlink($path . '.tar');
|
||||
rename($path . '.tar.gz', $path . '.tar');
|
||||
}
|
||||
|
||||
return $path . '.tar';
|
||||
}
|
||||
|
||||
function __c3_build_clover_report(PHP_CodeCoverage $codeCoverage, $path)
|
||||
{
|
||||
$writer = new PHP_CodeCoverage_Report_Clover();
|
||||
$writer->process($codeCoverage, $path . '.clover.xml');
|
||||
|
||||
return $path . '.clover.xml';
|
||||
}
|
||||
|
||||
function __c3_send_file($filename)
|
||||
{
|
||||
if (!headers_sent()) {
|
||||
readfile($filename);
|
||||
}
|
||||
|
||||
return __c3_exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filename
|
||||
* @return null|PHP_CodeCoverage
|
||||
*/
|
||||
function __c3_factory($filename)
|
||||
{
|
||||
$phpCoverage = is_readable($filename)
|
||||
? unserialize(file_get_contents($filename))
|
||||
: new PHP_CodeCoverage();
|
||||
|
||||
|
||||
if (isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'])) {
|
||||
$suite = $_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_SUITE'];
|
||||
try {
|
||||
$settings = \Codeception\Configuration::suiteSettings($suite, \Codeception\Configuration::config());
|
||||
} catch (Exception $e) {
|
||||
__c3_error($e->getMessage());
|
||||
}
|
||||
} else {
|
||||
$settings = \Codeception\Configuration::config();
|
||||
}
|
||||
|
||||
try {
|
||||
\Codeception\Coverage\Filter::setup($phpCoverage)
|
||||
->whiteList($settings)
|
||||
->blackList($settings);
|
||||
} catch (Exception $e) {
|
||||
__c3_error($e->getMessage());
|
||||
}
|
||||
|
||||
return $phpCoverage;
|
||||
}
|
||||
|
||||
function __c3_exit()
|
||||
{
|
||||
if (!isset($_SERVER['HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG'])) {
|
||||
exit;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function __c3_clear()
|
||||
{
|
||||
\Codeception\Util\FileSystem::doEmptyDir(C3_CODECOVERAGE_MEDIATE_STORAGE);
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_dir(C3_CODECOVERAGE_MEDIATE_STORAGE)) {
|
||||
if (mkdir(C3_CODECOVERAGE_MEDIATE_STORAGE, 0777, true) === false) {
|
||||
__c3_error('Failed to create directory "' . C3_CODECOVERAGE_MEDIATE_STORAGE . '"');
|
||||
}
|
||||
}
|
||||
|
||||
// evaluate base path for c3-related files
|
||||
$path = realpath(C3_CODECOVERAGE_MEDIATE_STORAGE) . DIRECTORY_SEPARATOR . 'codecoverage';
|
||||
|
||||
$requested_c3_report = (strpos($_SERVER['REQUEST_URI'], 'c3/report') !== false);
|
||||
|
||||
$complete_report = $current_report = $path . '.serialized';
|
||||
if ($requested_c3_report) {
|
||||
set_time_limit(0);
|
||||
|
||||
$route = ltrim(strrchr($_SERVER['REQUEST_URI'], '/'), '/');
|
||||
|
||||
if ($route == 'clear') {
|
||||
__c3_clear();
|
||||
return __c3_exit();
|
||||
}
|
||||
|
||||
$codeCoverage = __c3_factory($complete_report);
|
||||
|
||||
switch ($route) {
|
||||
case 'html':
|
||||
try {
|
||||
__c3_send_file(__c3_build_html_report($codeCoverage, $path));
|
||||
} catch (Exception $e) {
|
||||
__c3_error($e->getMessage());
|
||||
}
|
||||
return __c3_exit();
|
||||
case 'clover':
|
||||
try {
|
||||
__c3_send_file(__c3_build_clover_report($codeCoverage, $path));
|
||||
} catch (Exception $e) {
|
||||
__c3_error($e->getMessage());
|
||||
}
|
||||
return __c3_exit();
|
||||
case 'serialized':
|
||||
try {
|
||||
__c3_send_file($complete_report);
|
||||
} catch (Exception $e) {
|
||||
__c3_error($e->getMessage());
|
||||
}
|
||||
return __c3_exit();
|
||||
}
|
||||
|
||||
} else {
|
||||
$codeCoverage = __c3_factory($current_report);
|
||||
$codeCoverage->start(C3_CODECOVERAGE_TESTNAME);
|
||||
if (!array_key_exists('HTTP_X_CODECEPTION_CODECOVERAGE_DEBUG', $_SERVER)) {
|
||||
register_shutdown_function(
|
||||
function () use ($codeCoverage, $current_report) {
|
||||
|
||||
$codeCoverage->stop();
|
||||
if (!file_exists(dirname($current_report))) { // verify directory exists
|
||||
if(!mkdir(dirname($current_report), 0777, true)){
|
||||
__c3_error("Can't write CodeCoverage report into $current_report");
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($current_report, serialize($codeCoverage));
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// @codeCoverageIgnoreEnd
|
|
@ -1,20 +0,0 @@
|
|||
actor: Tester
|
||||
paths:
|
||||
tests: tests
|
||||
log: tests/_output
|
||||
data: tests/_data
|
||||
support: tests/_support
|
||||
envs: tests/_envs
|
||||
bootstrap: _bootstrap.php
|
||||
settings:
|
||||
colors: true
|
||||
memory_limit: 1024M
|
||||
extensions:
|
||||
enabled:
|
||||
- Codeception\Extension\RunFailed
|
||||
coverage:
|
||||
enabled: true
|
||||
include:
|
||||
- app/*
|
||||
exclude:
|
||||
- app/cache/*
|
|
@ -66,12 +66,8 @@
|
|||
"watson/validating": "^6.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"codeception/codeception": "^4.1",
|
||||
"codeception/module-asserts": "^1.2",
|
||||
"codeception/module-laravel5": "^1.1",
|
||||
"codeception/module-rest": "^1.2",
|
||||
"codeception/module-webdriver": "^1.0",
|
||||
"fzaninotto/faker": "master@dev",
|
||||
"laravel/dusk": "^6.19",
|
||||
"overtrue/phplint": "^3.0",
|
||||
"phpunit/php-token-stream": "^3.1",
|
||||
"phpunit/phpunit": "^8.5",
|
||||
|
@ -79,9 +75,6 @@
|
|||
"symfony/css-selector": "^4.4",
|
||||
"symfony/dom-crawler": "^4.4"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mcrypt": "For upgrading from before v5.1 this is used to re-encrypt data"
|
||||
},
|
||||
"extra": {
|
||||
"laravel": {
|
||||
"dont-discover": [
|
||||
|
@ -101,9 +94,13 @@
|
|||
},
|
||||
"autoload-dev": {
|
||||
"classmap": [
|
||||
"tests/TestCase.php",
|
||||
"tests/unit/BaseTest.php"
|
||||
]
|
||||
"tests/DuskTestCase.php",
|
||||
"tests/TestCase.php"
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/",
|
||||
"Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-autoload-dump": [
|
||||
|
@ -120,4 +117,4 @@
|
|||
"discard-changes": true,
|
||||
"process-timeout": 3000
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
1586
composer.lock
generated
1586
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -23,12 +23,8 @@
|
|||
<env name="CACHE_DRIVER" value="array"/>
|
||||
<env name="SESSION_DRIVER" value="array"/>
|
||||
<env name="QUEUE_DRIVER" value="sync"/>
|
||||
|
||||
<env name="DB_CONNECTION" value="sqlite_testing" />
|
||||
|
||||
<server name="SERVER_NAME" value="http://testing.dev"/>
|
||||
<server name="SERVER_NAME" value="http://127.0.0.1:8000"/>
|
||||
<ini name="display_errors" value="true"/>
|
||||
</php>
|
||||
<logging>
|
||||
<log type="coverage-clover" target="build/logs/clover.xml"/>
|
||||
</logging>
|
||||
</phpunit>
|
||||
|
|
|
@ -135,7 +135,7 @@
|
|||
'licenses_available' => 'licenses available',
|
||||
'licenses' => 'Licenses',
|
||||
'list_all' => 'List All',
|
||||
'loading' => 'Loading',
|
||||
'loading' => 'Loading... please wait....',
|
||||
'lock_passwords' => 'This field value will not be saved in a demo installation.',
|
||||
'feature_disabled' => 'This feature has been disabled for the demo installation.',
|
||||
'location' => 'Location',
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
|
||||
@if ($snipeSettings->saml_enabled)
|
||||
<div class="row ">
|
||||
<div class="col-md-12 text-right">
|
||||
<div class="text-right col-md-12">
|
||||
<a href="{{ route('saml.login') }}">{{ trans('auth/general.saml_login') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -73,7 +73,7 @@
|
|||
<div class="box-footer">
|
||||
<button class="btn btn-lg btn-primary btn-block">{{ trans('auth/general.login') }}</button>
|
||||
</div>
|
||||
<div class="col-md-12 col-sm-12 col-xs-12 text-right" style="padding-top: 10px;">
|
||||
<div class="text-right col-md-12 col-sm-12 col-xs-12" style="padding-top: 10px;">
|
||||
@if ($snipeSettings->custom_forgot_pass_url)
|
||||
<a href="{{ $snipeSettings->custom_forgot_pass_url }}" rel="noopener">{{ trans('auth/general.forgot_password') }}</a>
|
||||
@else
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
return newParams;
|
||||
},
|
||||
formatLoadingMessage: function () {
|
||||
return '<h2><i class="fas fa-spinner fa-spin" aria-hidden="true"></i> Loading... please wait.... </h4>';
|
||||
return '<h2><i class="fas fa-spinner fa-spin" aria-hidden="true"></i> {{ trans('general.loading') }} </h4>';
|
||||
},
|
||||
icons: {
|
||||
advancedSearchIcon: 'fas fa-search-plus',
|
||||
|
|
53
tests/Browser/LoginTest.php
Normal file
53
tests/Browser/LoginTest.php
Normal file
|
@ -0,0 +1,53 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Browser;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Laravel\Dusk\Browser;
|
||||
use Tests\DuskTestCase;
|
||||
|
||||
class LoginTest extends DuskTestCase
|
||||
{
|
||||
/**
|
||||
* Test login
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLoginPageLoadsAndUserCanLogin()
|
||||
{
|
||||
$this->browse(function (Browser $browser) {
|
||||
$browser->visitRoute('login')
|
||||
->assertSee(trans('auth/general.login_prompt'));
|
||||
$browser->screenshot('filename');
|
||||
$browser->storeSource('login');
|
||||
});
|
||||
|
||||
$this->browse(function ($browser) {
|
||||
$browser->visitRoute('login')
|
||||
->type('username', 'snipe')
|
||||
->type('password', 'password')
|
||||
->press(trans('auth/general.login'))
|
||||
->assertPathIs('/');
|
||||
$browser->screenshot('dashboard');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test dashboard loads
|
||||
*
|
||||
* @todo Flesh this out further to make sure the individual tables actually load with
|
||||
* content inside them.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDashboardLoadsWithSuperAdmin()
|
||||
{
|
||||
$this->browse(function ($browser) {
|
||||
$browser->assertSee(trans('general.dashboard'));
|
||||
$browser->assertSee(trans('general.loading'));
|
||||
$browser->screenshot('dashboard-2');
|
||||
});
|
||||
|
||||
}
|
||||
}
|
41
tests/Browser/Pages/HomePage.php
Normal file
41
tests/Browser/Pages/HomePage.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Browser;
|
||||
|
||||
class HomePage extends Page
|
||||
{
|
||||
/**
|
||||
* Get the URL for the page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function url()
|
||||
{
|
||||
return '/';
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the browser is on the page.
|
||||
*
|
||||
* @param \Laravel\Dusk\Browser $browser
|
||||
* @return void
|
||||
*/
|
||||
public function assert(Browser $browser)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the element shortcuts for the page.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function elements()
|
||||
{
|
||||
return [
|
||||
'@element' => '#selector',
|
||||
];
|
||||
}
|
||||
}
|
20
tests/Browser/Pages/Page.php
Normal file
20
tests/Browser/Pages/Page.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\Browser\Pages;
|
||||
|
||||
use Laravel\Dusk\Page as BasePage;
|
||||
|
||||
abstract class Page extends BasePage
|
||||
{
|
||||
/**
|
||||
* Get the global element shortcuts for the site.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function siteElements()
|
||||
{
|
||||
return [
|
||||
'@element' => '#selector',
|
||||
];
|
||||
}
|
||||
}
|
2
tests/Browser/console/.gitignore
vendored
Normal file
2
tests/Browser/console/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
2
tests/Browser/screenshots/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
2
tests/Browser/source/.gitignore
vendored
Normal file
2
tests/Browser/source/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
22
tests/CreatesApplication.php
Normal file
22
tests/CreatesApplication.php
Normal file
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
|
||||
trait CreatesApplication
|
||||
{
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
}
|
61
tests/DuskTestCase.php
Normal file
61
tests/DuskTestCase.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Facebook\WebDriver\Chrome\ChromeOptions;
|
||||
use Facebook\WebDriver\Remote\DesiredCapabilities;
|
||||
use Facebook\WebDriver\Remote\RemoteWebDriver;
|
||||
use Laravel\Dusk\TestCase as BaseTestCase;
|
||||
|
||||
abstract class DuskTestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
|
||||
/**
|
||||
* Prepare for Dusk test execution.
|
||||
*
|
||||
* @beforeClass
|
||||
* @return void
|
||||
*/
|
||||
public static function prepare()
|
||||
{
|
||||
if (! static::runningInSail()) {
|
||||
static::startChromeDriver();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the RemoteWebDriver instance.
|
||||
*
|
||||
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
|
||||
*/
|
||||
protected function driver()
|
||||
{
|
||||
$options = (new ChromeOptions)->addArguments(collect([
|
||||
'--window-size=1920,1080',
|
||||
])->unless($this->hasHeadlessDisabled(), function ($items) {
|
||||
return $items->merge([
|
||||
'--disable-gpu',
|
||||
'--headless',
|
||||
]);
|
||||
})->all());
|
||||
|
||||
return RemoteWebDriver::create(
|
||||
$_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515',
|
||||
DesiredCapabilities::chrome()->setCapability(
|
||||
ChromeOptions::CAPABILITY, $options
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether the Dusk command has disabled headless mode.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function hasHeadlessDisabled()
|
||||
{
|
||||
return isset($_SERVER['DUSK_HEADLESS_DISABLED']) ||
|
||||
isset($_ENV['DUSK_HEADLESS_DISABLED']);
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
* Dump should contain at least one category of each type for functional testing.
|
||||
* acceptance: replace some amonpage with checking url after clicking create
|
||||
* acceptance: asset model test
|
|
@ -1,35 +1,10 @@
|
|||
<?php
|
||||
|
||||
class TestCase extends Illuminate\Foundation\Testing\TestCase
|
||||
namespace Tests;
|
||||
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
/**
|
||||
* The base URL to use while testing the application.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $baseUrl = 'http://localhost:8000';
|
||||
|
||||
/**
|
||||
* Creates the application.
|
||||
*
|
||||
* @return \Illuminate\Foundation\Application
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
$app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
//Artisan::call('migrate:reset');
|
||||
parent::tearDown();
|
||||
}
|
||||
use CreatesApplication;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Category;
|
||||
|
@ -6,6 +7,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class AccessoryTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\AssetMaintenance;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class AssetMaintenanceTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
|
@ -6,6 +7,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class AssetModelTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Exceptions\CheckoutNotAllowed;
|
||||
use App\Models\Asset;
|
||||
|
@ -10,6 +11,7 @@ use Carbon\Carbon;
|
|||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class AssetTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
|
||||
class BaseTest extends \Codeception\TestCase\Test
|
||||
class BaseTest extends \Tests\TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Category;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class CategoryTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Company;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class CompanyTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
|
@ -8,6 +9,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class ComponentTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Consumable;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class ConsumableTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\CustomField;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
/*
|
||||
* Test strings for db column names gathered from
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Department;
|
||||
use App\Models\Location;
|
||||
|
@ -6,6 +7,7 @@ use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class DepartmentTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Depreciation;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class DepreciationTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Importer\AccessoryImporter;
|
||||
use App\Importer\AssetImporter;
|
||||
|
@ -17,6 +18,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class ImporterTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Location;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class LocationTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Manufacturer;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class ManufacturerTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Exceptions\CheckoutNotAllowed;
|
||||
use App\Models\Asset;
|
||||
|
@ -12,6 +13,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class NotificationTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Asset;
|
||||
|
@ -9,6 +10,7 @@ use App\Models\User;
|
|||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class PermissionsTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\SnipeModel;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class SnipeModelTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Statuslabel;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class StatuslabelTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\Supplier;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class SupplierTest extends BaseTest
|
||||
{
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\Unit\BaseTest;
|
||||
|
||||
class UserTest extends BaseTest
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue