Skip to content

Commit

Permalink
ISSUE-337: fix the rest of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tatevikg1 committed Dec 8, 2024
1 parent 0afd664 commit 7e19d05
Show file tree
Hide file tree
Showing 32 changed files with 403 additions and 340 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,12 @@ jobs:
restore-keys: ${{ runner.os }}-composer-
- name: Install Composer dependencies
run: composer install --no-progress --prefer-dist --optimize-autoloader
continue-on-error: ${{matrix.php-versions == '8.0' }} # Temporal until full support for php8 === [temp-php8]
- name: Validating composer.json
run: composer validate --no-check-all --no-check-lock --strict;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Linting all php files
run: find src/ tests/ public/ -name ''*.php'' -print0 | xargs -0 -n 1 -P 4 php -l; php -l bin/*;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Run units tests with phpunit
run: vendor/bin/phpunit tests/Unit/
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Run integration tests with phpunit
run: |
export PHPLIST_DATABASE_NAME=${{ env.DB_DATABASE }}
Expand All @@ -69,16 +65,11 @@ jobs:
export PHPLIST_DATABASE_PORT=${{ job.services.mysql.ports['3306'] }}
export PHPLIST_DATABASE_HOST=127.0.0.1
vendor/bin/phpunit tests/Integration/
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running the system tests
run: vendor/bin/phpunit tests/System/;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running static analysis
run: vendor/bin/phpstan analyse -c phpstan.neon;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running PHPMD
run: vendor/bin/phpmd src/ text config/PHPMD/rules.xml;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
- name: Running PHP_CodeSniffer
run: vendor/bin/phpcs --standard=config/PhpCodeSniffer/ bin/ src/ tests/ public/;
continue-on-error: ${{matrix.php-versions == '8.0' }} # [temp-php8]
82 changes: 42 additions & 40 deletions .github/workflows/core-docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Core Docs
name: Publish Core Docs
on: [push, pull_request]
jobs:
make-restapi-docs:
Expand All @@ -10,7 +10,7 @@ jobs:
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: 7.4
php-version: 8.1
extensions: mbstring, dom, fileinfo, mysql
- name: Get composer cache directory
id: composer-cache
Expand All @@ -25,11 +25,13 @@ jobs:
restore-keys: ${{ runner.os }}-composer-
- name: Install current dependencies from composer.lock
run: composer install
- name: Install phpDocumentor
- name: Install phpDocumentor
run: |
wget https://phpdoc.org/phpDocumentor.phar
chmod +x phpDocumentor.phar
mv phpDocumentor.phar /usr/local/bin/phpDocumentor
- name: Verify phpDocumentor version
run: phpDocumentor --version
- name: Generate documentation
run: composer run-php-documentor
- name: zip phpdocumentor dir
Expand All @@ -44,40 +46,40 @@ jobs:
runs-on: ubuntu-20.04
needs: make-restapi-docs
steps:
- name: Checkout phplist/core-docs
uses: actions/checkout@v2
with:
repository: phpList/core-docs
fetch-depth: 0
token: ${{ secrets.PUSH_CORE_DOCS }}
- name: Restore REST API Spec
uses: actions/download-artifact@v2
with:
name: doc-files
- name: unzip phpdocumentor
run: |
unzip phpdocumentor.zip
rm phpdocumentor.zip
- name: List Files
run: ls
- name: Sync old files with newly generated ones.
run: rsync -av docs/phpdocumentor/* .
- name: Removed temp dirs
run: rm -rf docs
- name: Check if updates/changes.
run: git status --porcelain > repo-changes.txt
- name: Check changes file
run: cat repo-changes.txt
- name: Verify updates.
id: allow-deploy
run: |
if [ -s repo-changes.txt ]; then echo "Updates made to documentation"; echo '::set-output name=DEPLOY::true'; else echo "No updates made to documentation deployment would be skipped."; echo '::set-output name=DEPLOY::false'; fi
- name: Commit changes and deply
if: ${{ steps.allow-deploy.outputs.DEPLOY == 'true' }}
run: |
rm repo-changes.txt
git config user.name "github-actions"
git config user.email "[email protected]"
git add .
git commit -s -m "phplist/core docs deployment `date`"
git push
- name: Checkout phplist/core-docs
uses: actions/checkout@v2
with:
repository: phpList/core-docs
fetch-depth: 0
token: ${{ secrets.PUSH_CORE_DOCS }}
- name: Restore REST API Spec
uses: actions/download-artifact@v2
with:
name: doc-files
- name: unzip phpdocumentor
run: |
unzip phpdocumentor.zip
rm phpdocumentor.zip
- name: List Files
run: ls
- name: Sync old files with newly generated ones.
run: rsync -av docs/phpdocumentor/* .
- name: Removed temp dirs
run: rm -rf docs
- name: Check if updates/changes.
run: git status --porcelain > repo-changes.txt
- name: Check changes file
run: cat repo-changes.txt
- name: Verify updates.
id: allow-deploy
run: |
if [ -s repo-changes.txt ]; then echo "Updates made to documentation"; echo '::set-output name=DEPLOY::true'; else echo "No updates made to documentation deployment would be skipped."; echo '::set-output name=DEPLOY::false'; fi
- name: Commit changes and deply
if: ${{ steps.allow-deploy.outputs.DEPLOY == 'true' }}
run: |
rm repo-changes.txt
git config user.name "github-actions"
git config user.email "[email protected]"
git add .
git commit -s -m "phplist/core docs deployment `date`"
git push
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"symfony/form": "^6.4",
"symfony/validator": "^6.4",
"doctrine/doctrine-fixtures-bundle": "^3.7",
"doctrine/instantiator": "^2.0"
"doctrine/instantiator": "^2.0",
"masterminds/html5": "^2.9"
},
"require-dev": {
"phpunit/phpunit": "^9.5",
Expand Down Expand Up @@ -101,7 +102,7 @@
},
"extra": {
"branch-alias": {
"dev-ISSUE-337": "v5.0.x-dev"
"dev-master": "5.0.x-dev"
},
"symfony-app-dir": "",
"symfony-bin-dir": "bin",
Expand Down
8 changes: 4 additions & 4 deletions config/config_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ monolog:
channels: ['!event', '!doctrine', '!console']
# To follow logs in real time, execute the following command:
# `bin/console server:log -vv`
server_log:
type: server_log
process_psr_3_messages: false
host: 127.0.0.1:9911
# server_log:
# type: server_log
# process_psr_3_messages: false
# host: 127.0.0.1:9911
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
Expand Down
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
>
<php>
<ini name="error_reporting" value="-1"/>
<ini name="memory_limit" value="5G"/>
<server name="KERNEL_CLASS" value="PhpList\Core\Core\ApplicationKernel"/>
</php>
</phpunit>
1 change: 1 addition & 0 deletions public/app.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

use PhpList\Core\Core\Bootstrap;
Expand Down
1 change: 1 addition & 0 deletions public/app_dev.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

declare(strict_types=1);

use PhpList\Core\Core\Bootstrap;
Expand Down
5 changes: 4 additions & 1 deletion src/Core/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,13 @@ private function isDebugEnabled(): bool
*/
public function ensureDevelopmentOrTestingEnvironment(): static
{
if (isset($_ENV['APP_ENV']) && $_ENV['APP_ENV'] === Environment::TESTING) {
return $this;
}
$usesProxy = isset($_SERVER['HTTP_CLIENT_IP']) || isset($_SERVER['HTTP_X_FORWARDED_FOR']);
$isOnCli = PHP_SAPI === 'cli' || PHP_SAPI === 'cli-server';
$isLocalRequest = isset($_SERVER['REMOTE_ADDR'])
&& in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1'], true);
&& in_array($_SERVER['REMOTE_ADDR'], ['127.0.0.1', '::1', 'localhost'], true);
if ($usesProxy || (!$isOnCli && !$isLocalRequest)) {
header('HTTP/1.0 403 Forbidden');
exit('You are not allowed to access this file.');
Expand Down
25 changes: 18 additions & 7 deletions src/Domain/Model/Identity/Administrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,39 @@ class Administrator implements DomainModel, Identity, CreationDate, Modification
use ModificationDateTrait;

#[ORM\Column(name: "loginname")]
private string $loginName = '';
private string $loginName;

#[ORM\Column(name: "email")]
private string $emailAddress = '';
private string $emailAddress;

#[ORM\Column(name: "created", type: "datetime")]
protected ?DateTime $creationDate = null;

#[ORM\Column(name: "modified", type: "datetime")]
protected ?DateTime $modificationDate = null;
protected ?DateTime $modificationDate;

#[ORM\Column(name: "password")]
private string $passwordHash = '';
private string $passwordHash;

#[ORM\Column(name: "passwordchanged", type: "date", nullable: true)]
private ?DateTime $passwordChangeDate = null;
private ?DateTime $passwordChangeDate;

#[ORM\Column(type: "boolean")]
private bool $disabled = false;
private bool $disabled;

#[ORM\Column(name: "superuser", type: "boolean")]
private bool $superUser = false;
private bool $superUser;

public function __construct()
{
$this->disabled = false;
$this->superUser = false;
$this->passwordChangeDate = null;
$this->loginName = '';
$this->passwordHash = '';
$this->modificationDate = null;
$this->emailAddress = '';
}

public function getLoginName(): string
{
Expand Down
54 changes: 31 additions & 23 deletions src/Domain/Model/Messaging/SubscriberList.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use PhpList\Core\Domain\Model\Subscription\Subscription;
use Symfony\Component\Serializer\Annotation\Ignore;
use Symfony\Component\Serializer\Annotation\SerializedName;
use PhpList\Core\Domain\Model\Identity\Administrator;
Expand All @@ -28,6 +29,8 @@
*/
#[ORM\Entity(repositoryClass: "PhpList\Core\Domain\Repository\Messaging\SubscriberListRepository")]
#[ORM\Table(name: "phplist_list")]
#[ORM\Index(name: "nameidx", columns: ["name"])]
#[ORM\Index(name: "listorderidx", columns: ["listorder"])]
#[ORM\HasLifecycleCallbacks]
class SubscriberList implements DomainModel, Identity, CreationDate, ModificationDate
{
Expand Down Expand Up @@ -66,11 +69,13 @@ class SubscriberList implements DomainModel, Identity, CreationDate, Modificatio

#[ORM\Column(name: "active", type: "boolean")]
#[SerializedName("public")]
private bool $public = false;
#[Groups(['SubscriberList'])]
private bool $public;

#[ORM\Column]
#[SerializedName("category")]
private string $category = '';
#[Groups(['SubscriberList'])]
private string $category;

#[ORM\ManyToOne(targetEntity: "PhpList\Core\Domain\Model\Identity\Administrator")]
#[ORM\JoinColumn(name: "owner")]
Expand All @@ -80,30 +85,19 @@ class SubscriberList implements DomainModel, Identity, CreationDate, Modificatio
#[ORM\OneToMany(
targetEntity: "PhpList\Core\Domain\Model\Subscription\Subscription",
mappedBy: "subscriberList",
cascade: ["remove"]
cascade: ["remove"],
orphanRemoval: true,
)]
#[MaxDepth(1)]
private Collection $subscriptions;

#[ORM\ManyToMany(
targetEntity: "PhpList\Core\Domain\Model\Subscription\Subscriber",
inversedBy: "subscribedLists",
fetch: "EXTRA_LAZY"
)]
#[ORM\JoinTable(
name: "phplist_listuser",
joinColumns: [new ORM\JoinColumn(name: "listid")],
inverseJoinColumns: [new ORM\JoinColumn(name: "userid")]
)]
#[MaxDepth(1)]
private Collection $subscribers;

public function __construct()
{
$this->subscriptions = new ArrayCollection();
$this->subscribers = new ArrayCollection();
$this->listPosition = 0;
$this->subjectPrefix = '';
$this->category = '';
$this->public = false;
}

public function getName(): string
Expand Down Expand Up @@ -181,18 +175,32 @@ public function getSubscriptions(): Collection
return $this->subscriptions;
}

public function setSubscriptions(Collection $subscriptions): void
public function addSubscription(Subscription $subscription): self
{
$this->subscriptions = $subscriptions;
if (!$this->subscriptions->contains($subscription)) {
$this->subscriptions->add($subscription);
$subscription->setSubscriberList($this);
}

return $this;
}

public function getSubscribers(): Collection
public function removeSubscription(Subscription $subscription): self
{
return $this->subscribers;
if ($this->subscriptions->removeElement($subscription)) {
$subscription->setSubscriberList(null);
}

return $this;
}

public function setSubscribers(Collection $subscribers): void
public function getSubscribers(): Collection
{
$this->subscribers = $subscribers;
$result = new ArrayCollection();
foreach ($this->subscriptions as $subscription) {
$result->add($subscription->getSubscriber());
}

return $result;
}
}
Loading

0 comments on commit 7e19d05

Please sign in to comment.