actions gitea and github + more tests
This commit is contained in:
parent
5dc7aa87cd
commit
639f7bbe27
|
|
@ -0,0 +1,143 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
testsuite:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
php-version: ['8.2', '8.4']
|
||||||
|
db-type: ['mysql']
|
||||||
|
# db-type: ['sqlite', 'mysql', 'pgsql']
|
||||||
|
prefer-lowest: ['']
|
||||||
|
include:
|
||||||
|
- php-version: '8.2'
|
||||||
|
db-type: 'sqlite'
|
||||||
|
prefer-lowest: 'prefer-lowest'
|
||||||
|
|
||||||
|
services:
|
||||||
|
mysql8:
|
||||||
|
image: mysql:8.0
|
||||||
|
env:
|
||||||
|
MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
||||||
|
MYSQL_DATABASE: cakephp
|
||||||
|
# services:
|
||||||
|
# postgres:
|
||||||
|
# image: postgres
|
||||||
|
# ports:
|
||||||
|
# - 5432:5432
|
||||||
|
# env:
|
||||||
|
# POSTGRES_PASSWORD: postgres
|
||||||
|
# mysql8:
|
||||||
|
# image: mysql:8.0
|
||||||
|
# env:
|
||||||
|
# MYSQL_ALLOW_EMPTY_PASSWORD: yes
|
||||||
|
# MYSQL_DATABASE: test_db
|
||||||
|
# ports:
|
||||||
|
# - 3306:3306
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-version }}
|
||||||
|
extensions: mbstring, intl, sqlite, pdo_${{ matrix.db-type }}
|
||||||
|
coverage: pcov
|
||||||
|
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composercache
|
||||||
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ steps.composercache.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
|
||||||
|
|
||||||
|
- name: Composer install
|
||||||
|
run: |
|
||||||
|
composer --version
|
||||||
|
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}
|
||||||
|
then
|
||||||
|
composer update --prefer-lowest --prefer-stable
|
||||||
|
composer require --dev dereuromark/composer-prefer-lowest:dev-master
|
||||||
|
else
|
||||||
|
composer install --no-progress --prefer-dist --optimize-autoloader
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Setup problem matchers for PHPUnit
|
||||||
|
if: matrix.db-type == 'mysql'
|
||||||
|
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Run PHPUnit tests
|
||||||
|
env:
|
||||||
|
TEST_MYSQL_HOST: mysql8
|
||||||
|
TEST_MYSQL_CHARSET: utf8mb4
|
||||||
|
TEST_MYSQL_DBNAME: cakephp
|
||||||
|
TEST_MYSQL_USERNAME: root
|
||||||
|
TEST_MYSQL_PASSWORD:
|
||||||
|
run: |
|
||||||
|
if [[ ${{ matrix.php-version }} == '8.2' ]]; then
|
||||||
|
vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||||
|
else
|
||||||
|
vendor/bin/phpunit
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Validate prefer-lowest
|
||||||
|
if: matrix.prefer-lowest == 'prefer-lowest'
|
||||||
|
run: vendor/bin/validate-prefer-lowest -m
|
||||||
|
|
||||||
|
# - name: Upload coverage reports to Codecov
|
||||||
|
# if: success() && matrix.php-version == '8.2'
|
||||||
|
# uses: codecov/codecov-action@v4
|
||||||
|
# with:
|
||||||
|
# token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
|
validation:
|
||||||
|
name: Coding Standard & Static Analysis
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.1'
|
||||||
|
extensions: mbstring, intl, sqlite
|
||||||
|
coverage: none
|
||||||
|
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composercache
|
||||||
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ steps.composercache.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
|
||||||
|
|
||||||
|
- name: Composer install
|
||||||
|
run: |
|
||||||
|
composer --version
|
||||||
|
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}
|
||||||
|
then
|
||||||
|
composer update --prefer-lowest --prefer-stable
|
||||||
|
composer require --dev dereuromark/composer-prefer-lowest:dev-master
|
||||||
|
else
|
||||||
|
composer install --no-progress --prefer-dist --optimize-autoloader
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Composer phpstan setup
|
||||||
|
run: composer stan-setup
|
||||||
|
|
||||||
|
- name: Run phpstan
|
||||||
|
run: vendor/bin/phpstan analyse --error-format=github
|
||||||
|
|
||||||
|
- name: Run phpcs
|
||||||
|
run: composer cs-check
|
||||||
|
|
@ -0,0 +1,127 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
testsuite:
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
php-version: ['8.1', '8.4']
|
||||||
|
db-type: ['sqlite', 'mysql', 'pgsql']
|
||||||
|
prefer-lowest: ['']
|
||||||
|
include:
|
||||||
|
- php-version: '8.1'
|
||||||
|
db-type: 'sqlite'
|
||||||
|
prefer-lowest: 'prefer-lowest'
|
||||||
|
|
||||||
|
services:
|
||||||
|
postgres:
|
||||||
|
image: postgres
|
||||||
|
ports:
|
||||||
|
- 5432:5432
|
||||||
|
env:
|
||||||
|
POSTGRES_PASSWORD: postgres
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup Service
|
||||||
|
if: matrix.db-type == 'mysql'
|
||||||
|
run: |
|
||||||
|
sudo service mysql start
|
||||||
|
mysql -h 127.0.0.1 -u root -proot -e 'CREATE DATABASE cakephp;'
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-version }}
|
||||||
|
extensions: mbstring, intl, pdo_${{ matrix.db-type }}
|
||||||
|
coverage: pcov
|
||||||
|
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composercache
|
||||||
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ steps.composercache.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
|
||||||
|
|
||||||
|
- name: Composer install
|
||||||
|
run: |
|
||||||
|
composer --version
|
||||||
|
if ${{ matrix.prefer-lowest == 'prefer-lowest' }}
|
||||||
|
then
|
||||||
|
composer update --prefer-lowest --prefer-stable
|
||||||
|
composer require --dev dereuromark/composer-prefer-lowest:dev-master
|
||||||
|
else
|
||||||
|
composer install --no-progress --prefer-dist --optimize-autoloader
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Setup problem matchers for PHPUnit
|
||||||
|
if: matrix.db-type == 'mysql'
|
||||||
|
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"
|
||||||
|
|
||||||
|
- name: Wait for MySQL
|
||||||
|
if: matrix.db-type == 'mysql'
|
||||||
|
run: while ! `mysqladmin ping -h 127.0.0.1 --silent`; do printf 'Waiting for MySQL...\n'; sleep 2; done;
|
||||||
|
|
||||||
|
- name: Run PHPUnit
|
||||||
|
run: |
|
||||||
|
if [[ ${{ matrix.db-type }} == 'sqlite' ]]; then export DB_URL='sqlite:///:memory:'; fi
|
||||||
|
if [[ ${{ matrix.db-type }} == 'mysql' ]]; then export DB_URL='mysql://root:root@127.0.0.1/cakephp?encoding=utf8'; fi
|
||||||
|
if [[ ${{ matrix.db-type }} == 'pgsql' ]]; then export DB_URL='postgres://postgres:postgres@127.0.0.1/postgres'; fi
|
||||||
|
if [[ ${{ matrix.php-version }} == '8.1' ]]; then
|
||||||
|
vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||||
|
else
|
||||||
|
vendor/bin/phpunit
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Validate prefer-lowest
|
||||||
|
if: matrix.prefer-lowest == 'prefer-lowest'
|
||||||
|
run: vendor/bin/validate-prefer-lowest -m
|
||||||
|
|
||||||
|
# - name: Upload coverage reports to Codecov
|
||||||
|
# if: success() && matrix.php-version == '8.1'
|
||||||
|
# uses: codecov/codecov-action@v4
|
||||||
|
# with:
|
||||||
|
# token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|
||||||
|
validation:
|
||||||
|
name: Coding Standard & Static Analysis
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: '8.1'
|
||||||
|
extensions: mbstring, intl
|
||||||
|
coverage: none
|
||||||
|
|
||||||
|
- name: Get composer cache directory
|
||||||
|
id: composercache
|
||||||
|
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Cache dependencies
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: ${{ steps.composercache.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-composer-${{ steps.key-date.outputs.date }}-${{ hashFiles('composer.json') }}-${{ matrix.prefer-lowest }}
|
||||||
|
|
||||||
|
- name: Composer phpstan setup
|
||||||
|
run: composer stan-setup
|
||||||
|
|
||||||
|
- name: Run phpstan
|
||||||
|
run: vendor/bin/phpstan analyse --error-format=github
|
||||||
|
|
||||||
|
- name: Run phpcs
|
||||||
|
run: composer cs-check
|
||||||
|
|
@ -44,7 +44,7 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->Addresses = $this->getTableLocator()->get('CakeAddresses.Addresses');
|
$this->Addresses = $this->getTableLocator()->get('CakeAddresses.Addresses');
|
||||||
$this->enableCsrfToken();
|
// $this->enableCsrfToken();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -69,31 +69,8 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testIndexGetUnauthenticated(): void
|
public function testIndexGet(): void
|
||||||
{
|
{
|
||||||
$url = [
|
|
||||||
'plugin' => 'CakeAddresses',
|
|
||||||
'controller' => 'Addresses',
|
|
||||||
'action' => 'index',
|
|
||||||
];
|
|
||||||
$this->get($url);
|
|
||||||
$this->assertResponseCode(302);
|
|
||||||
$this->assertRedirectContains('login');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test index method
|
|
||||||
*
|
|
||||||
* Tests the index action with a logged in user
|
|
||||||
*
|
|
||||||
* @uses \CakeAddresses\Controller\AddressesController::index()
|
|
||||||
* @throws Exception
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testIndexGetLoggedIn(): void
|
|
||||||
{
|
|
||||||
$this->loginUserByRole();
|
|
||||||
$url = [
|
$url = [
|
||||||
'plugin' => 'CakeAddresses',
|
'plugin' => 'CakeAddresses',
|
||||||
'controller' => 'Addresses',
|
'controller' => 'Addresses',
|
||||||
|
|
@ -113,7 +90,7 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testViewGetUnauthenticated(): void
|
public function testViewGet(): void
|
||||||
{
|
{
|
||||||
$id = 1;
|
$id = 1;
|
||||||
$url = [
|
$url = [
|
||||||
|
|
@ -123,31 +100,6 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
$id,
|
$id,
|
||||||
];
|
];
|
||||||
$this->get($url);
|
$this->get($url);
|
||||||
$this->assertResponseCode(302);
|
|
||||||
$this->assertRedirectContains('login');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test view method
|
|
||||||
*
|
|
||||||
* Tests the view action with a logged in user
|
|
||||||
*
|
|
||||||
* @uses \CakeAddresses\Controller\AddressesController::view()
|
|
||||||
* @throws Exception
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testViewGetLoggedIn(): void
|
|
||||||
{
|
|
||||||
$id = 1;
|
|
||||||
$this->loginUserByRole();
|
|
||||||
$url = [
|
|
||||||
'plugin' => 'CakeAddresses',
|
|
||||||
'controller' => 'Addresses',
|
|
||||||
'action' => 'view',
|
|
||||||
$id,
|
|
||||||
];
|
|
||||||
$this->get($url);
|
|
||||||
$this->assertResponseCode(200);
|
$this->assertResponseCode(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -161,7 +113,7 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddGetUnauthenticated(): void
|
public function testAddGet(): void
|
||||||
{
|
{
|
||||||
$cntBefore = $this->Addresses->find()->count();
|
$cntBefore = $this->Addresses->find()->count();
|
||||||
$url = [
|
$url = [
|
||||||
|
|
@ -170,34 +122,6 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
'action' => 'add',
|
'action' => 'add',
|
||||||
];
|
];
|
||||||
$this->get($url);
|
$this->get($url);
|
||||||
$this->assertResponseCode(302);
|
|
||||||
$this->assertRedirectContains('login');
|
|
||||||
|
|
||||||
$cntAfter = $this->Addresses->find()->count();
|
|
||||||
$this->assertEquals($cntBefore, $cntAfter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test add method
|
|
||||||
*
|
|
||||||
* Tests the add action with a logged in user
|
|
||||||
*
|
|
||||||
* @uses \CakeAddresses\Controller\AddressesController::add()
|
|
||||||
* @throws Exception
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testAddGetLoggedIn(): void
|
|
||||||
{
|
|
||||||
$cntBefore = $this->Addresses->find()->count();
|
|
||||||
|
|
||||||
$this->loginUserByRole();
|
|
||||||
$url = [
|
|
||||||
'plugin' => 'CakeAddresses',
|
|
||||||
'controller' => 'Addresses',
|
|
||||||
'action' => 'add',
|
|
||||||
];
|
|
||||||
$this->get($url);
|
|
||||||
$this->assertResponseCode(200);
|
$this->assertResponseCode(200);
|
||||||
|
|
||||||
$cntAfter = $this->Addresses->find()->count();
|
$cntAfter = $this->Addresses->find()->count();
|
||||||
|
|
@ -214,7 +138,7 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddPostLoggedInSuccess(): void
|
public function testAddPostSuccess(): void
|
||||||
{
|
{
|
||||||
$cntBefore = $this->Addresses->find()->count();
|
$cntBefore = $this->Addresses->find()->count();
|
||||||
|
|
||||||
|
|
@ -256,7 +180,7 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testAddPostLoggedInFailure(): void
|
public function testAddPostFailure(): void
|
||||||
{
|
{
|
||||||
$cntBefore = $this->Addresses->find()->count();
|
$cntBefore = $this->Addresses->find()->count();
|
||||||
|
|
||||||
|
|
@ -297,7 +221,7 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testEditGetUnauthenticated(): void
|
public function testEditGet(): void
|
||||||
{
|
{
|
||||||
$id = 1;
|
$id = 1;
|
||||||
$url = [
|
$url = [
|
||||||
|
|
@ -307,31 +231,6 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
$id,
|
$id,
|
||||||
];
|
];
|
||||||
$this->get($url);
|
$this->get($url);
|
||||||
$this->assertResponseCode(302);
|
|
||||||
$this->assertRedirectContains('login');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test edit method
|
|
||||||
*
|
|
||||||
* Tests the edit action with a logged in user
|
|
||||||
*
|
|
||||||
* @uses \CakeAddresses\Controller\AddressesController::edit()
|
|
||||||
* @throws Exception
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testEditGetLoggedIn(): void
|
|
||||||
{
|
|
||||||
$id = 1;
|
|
||||||
$this->loginUserByRole();
|
|
||||||
$url = [
|
|
||||||
'plugin' => 'CakeAddresses',
|
|
||||||
'controller' => 'Addresses',
|
|
||||||
'action' => 'edit',
|
|
||||||
$id,
|
|
||||||
];
|
|
||||||
$this->get($url);
|
|
||||||
$this->assertResponseCode(200);
|
$this->assertResponseCode(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,7 +244,7 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testEditPutLoggedInSuccess(): void
|
public function testEditPutSuccess(): void
|
||||||
{
|
{
|
||||||
$this->loginUserByRole();
|
$this->loginUserByRole();
|
||||||
$id = 1;
|
$id = 1;
|
||||||
|
|
@ -390,9 +289,8 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testEditPutLoggedInFailure(): void
|
public function testEditPutFailure(): void
|
||||||
{
|
{
|
||||||
$this->loginUserByRole();
|
|
||||||
$id = 1;
|
$id = 1;
|
||||||
$before = $this->Addresses->get($id);
|
$before = $this->Addresses->get($id);
|
||||||
$url = [
|
$url = [
|
||||||
|
|
@ -432,7 +330,7 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testDeleteUnauthenticated(): void
|
public function testDelete(): void
|
||||||
{
|
{
|
||||||
$cntBefore = $this->Addresses->find()->count();
|
$cntBefore = $this->Addresses->find()->count();
|
||||||
|
|
||||||
|
|
@ -444,36 +342,6 @@ class AddressesControllerTest extends BaseControllerTest
|
||||||
];
|
];
|
||||||
$this->delete($url);
|
$this->delete($url);
|
||||||
$this->assertResponseCode(302);
|
$this->assertResponseCode(302);
|
||||||
$this->assertRedirectContains('login');
|
|
||||||
|
|
||||||
$cntAfter = $this->Addresses->find()->count();
|
|
||||||
$this->assertEquals($cntBefore, $cntAfter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test delete method
|
|
||||||
*
|
|
||||||
* Tests the delete action with a logged in user
|
|
||||||
*
|
|
||||||
* @uses \CakeAddresses\Controller\AddressesController::delete()
|
|
||||||
* @throws Exception
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testDeleteLoggedIn(): void
|
|
||||||
{
|
|
||||||
$cntBefore = $this->Addresses->find()->count();
|
|
||||||
|
|
||||||
$this->loginUserByRole();
|
|
||||||
$url = [
|
|
||||||
'plugin' => 'CakeAddresses',
|
|
||||||
'controller' => 'Addresses',
|
|
||||||
'action' => 'delete',
|
|
||||||
1,
|
|
||||||
];
|
|
||||||
$this->delete($url);
|
|
||||||
$this->assertResponseCode(302);
|
|
||||||
$this->assertRedirectContains('addresses');
|
|
||||||
|
|
||||||
$cntAfter = $this->Addresses->find()->count();
|
$cntAfter = $this->Addresses->find()->count();
|
||||||
$this->assertEquals($cntBefore - 1, $cntAfter);
|
$this->assertEquals($cntBefore - 1, $cntAfter);
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,7 @@ class CitiesControllerTest extends BaseControllerTest
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$this->Cities = $this->getTableLocator()->get('Cities');
|
$this->Cities = $this->getTableLocator()->get('CakeAddresses.Cities');
|
||||||
$this->enableCsrfToken();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -57,28 +56,6 @@ class CitiesControllerTest extends BaseControllerTest
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test select method
|
|
||||||
*
|
|
||||||
* Tests the select action with an unauthenticated user (not logged in)
|
|
||||||
*
|
|
||||||
* @uses \CakeAddresses\Controller\CitiesController::select()
|
|
||||||
* @throws Exception
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function testSelectGetUnauthenticated(): void
|
|
||||||
{
|
|
||||||
$url = [
|
|
||||||
'plugin' => 'CakeAddresses',
|
|
||||||
'controller' => 'Cities',
|
|
||||||
'action' => 'select',
|
|
||||||
];
|
|
||||||
$this->get($url);
|
|
||||||
$this->assertResponseCode(302);
|
|
||||||
$this->assertRedirectContains('login');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test select method
|
* Test select method
|
||||||
*
|
*
|
||||||
|
|
@ -89,9 +66,8 @@ class CitiesControllerTest extends BaseControllerTest
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSelectGetLoggedIn(): void
|
public function testSelect(): void
|
||||||
{
|
{
|
||||||
$this->loginUserByRole();
|
|
||||||
$url = [
|
$url = [
|
||||||
'plugin' => 'CakeAddresses',
|
'plugin' => 'CakeAddresses',
|
||||||
'controller' => 'Cities',
|
'controller' => 'Cities',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue