Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Move tests into PSR compliant namespace
Browse files Browse the repository at this point in the history
recrsn authored and imphil committed May 19, 2019

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent 1cdef6a commit 56ad270
Showing 17 changed files with 56 additions and 59 deletions.
3 changes: 2 additions & 1 deletion site/composer.json
Original file line number Diff line number Diff line change
@@ -5,7 +5,8 @@
"description" : "LibreCores Web Site",
"autoload" : {
"psr-4" : {
"App\\" : "src/"
"App\\" : "src/",
"App\\Tests\\": "tests/"
},
"files" : [
"app/AppKernel.php"
2 changes: 1 addition & 1 deletion site/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="tests/bootstrap.php"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Project Test Suite">
4 changes: 2 additions & 2 deletions site/src/Repository/CommitRepository.php
Original file line number Diff line number Diff line change
@@ -429,7 +429,7 @@ private function getCommitHistogramByYear(
->getResult('group');

foreach ($result as $key => $value) {
$result[$key] = (int)$value[0];
$result[$key] = (int) $value[0];
}

return $this->zeroFillMissingYears($result, $start, $end);
@@ -474,7 +474,7 @@ private function getCommitContributorHistogramByYear(
->getResult('group');

foreach ($result as $key => $value) {
$result[$key] = (int)$value[0];
$result[$key] = (int) $value[0];
}

return $this->zeroFillMissingYears($result, $start, $end);
1 change: 0 additions & 1 deletion site/src/Util/Controllers.php
Original file line number Diff line number Diff line change
@@ -3,7 +3,6 @@

namespace App\Util;


class Controllers
{
public static function get(string $class, string $controllerMethod): string
15 changes: 9 additions & 6 deletions site/tests/Command/UpdateReposCommandTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace App\Command;

namespace App\Tests\Command;

use App\Command\UpdateReposCommand;
use App\Entity\GitSourceRepo;
use App\Entity\Project;
use App\Repository\ProjectRepository;
use TestUtils\Mocks\MockProducer;
use App\Tests\TestUtils\Mocks\MockProducer;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
@@ -41,7 +41,9 @@ public function testPublishesAllProjectsWhenInvoked()
$this->assertEquals(0, $exitCode);

$publishedIds = array_map(
function ($x) { return unserialize($x); },
function ($x) {
return unserialize($x);
},
array_column($producer->getPublishedMessages(), 'body')
);
$this->assertEquals([1, 2, 3], $publishedIds);
@@ -75,7 +77,9 @@ public function testDoesNotPublisheProjectsWithoutSourceRepo()
$this->assertEquals(0, $exitCode);

$publishedIds = array_map(
function ($x) { return unserialize($x); },
function ($x) {
return unserialize($x);
},
array_column($producer->getPublishedMessages(), 'body')
);
$this->assertEquals([1, 3], $publishedIds);
@@ -89,5 +93,4 @@ private function createMockProject($id, $sourceRepo = null)

return $mockProject;
}

}
3 changes: 2 additions & 1 deletion site/tests/RepoCrawler/GitRepoCrawlerTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace App\RepoCrawler;
namespace App\Tests\RepoCrawler;

use App\RepoCrawler\GitRepoCrawler;
use App\Entity\Contributor;
use App\Entity\GitSourceRepo;
use App\Entity\LanguageStat;
4 changes: 2 additions & 2 deletions site/tests/Repository/CommitRepositoryTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace App\Repository;

namespace App\Tests\Repository;

use App\Entity\Commit;
use App\Repository\CommitRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use PHPUnit\Framework\TestCase;
4 changes: 2 additions & 2 deletions site/tests/Repository/ContributorRepositoryTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace App\Repository;

namespace App\Tests\Repository;

use App\Entity\Contributor;
use App\Repository\ContributorRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use PHPUnit\Framework\TestCase;
4 changes: 2 additions & 2 deletions site/tests/Repository/OrganizationRepositoryTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace App\Repository;

namespace App\Tests\Repository;

use App\Entity\Organization;
use App\Repository\OrganizationRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use PHPUnit\Framework\TestCase;
4 changes: 2 additions & 2 deletions site/tests/Repository/ProjectRepositoryTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace App\Repository;

namespace App\Tests\Repository;

use App\Entity\Project;
use App\Repository\ProjectRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use PHPUnit\Framework\TestCase;
4 changes: 2 additions & 2 deletions site/tests/Repository/UserRepositoryTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

namespace App\Repository;

namespace App\Tests\Repository;

use App\Entity\User;
use App\Repository\UserRepository;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Mapping\ClassMetadata;
use PHPUnit\Framework\TestCase;
2 changes: 1 addition & 1 deletion site/tests/TestUtils/Generator.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TestUtils;
namespace App\Tests\TestUtils;

class Generator
{
2 changes: 1 addition & 1 deletion site/tests/TestUtils/Mocks/MockProducer.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace TestUtils\Mocks;
namespace App\Tests\TestUtils\Mocks;

use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;

43 changes: 21 additions & 22 deletions site/tests/Util/FileUtilTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

namespace App\Util;
namespace App\Tests\Util;

use App\Util\FileUtil;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use org\bovigo\vfs\vfsStream;
use PHPUnit\Framework\TestCase;

/**
* Tests for FileUtil
@@ -27,80 +26,80 @@ public function testFindFile()
'READYOU.md' => 'READYOU.md',
'READYOU.pod' => 'READYOU.pod',
'READYOU.unknown' => 'READYOU.unknown',
'subdir' => [ 'file1' => 'file1', 'file2' => 'file2'],
'subdir' => ['file1' => 'file1', 'file2' => 'file2'],
'subdir.md' => 'subdir.md',
'ZZZ' => 'ZZZ',
];
$fs = vfsStream::setup('basedir', null, $directory);

$foundFile = FileUtil::findFile(
$fs->url(),
[ 'doesntexist' ],
[ '.md', '.pod', '' ],
['doesntexist'],
['.md', '.pod', ''],
true
);
$this->assertFalse($foundFile);

$foundFile = FileUtil::findFile(
$fs->url(),
[ 'README', 'READYOU' ],
[ '.md', '.pod', '' ],
['README', 'READYOU'],
['.md', '.pod', ''],
true
);
$this->assertEquals(vfsStream::url('basedir/README.md'), $foundFile);

$foundFile = FileUtil::findFile(
$fs->url(),
[ 'READYOU', 'README' ],
[ '.md', '.pod', '' ],
['READYOU', 'README'],
['.md', '.pod', ''],
true
);
$this->assertEquals(vfsStream::url('basedir/READYOU.md'), $foundFile);

$foundFile = FileUtil::findFile(
$fs->url(),
[ 'README', 'READYOU' ],
[ '.pod', '.md', '' ],
['README', 'READYOU'],
['.pod', '.md', ''],
true
);
$this->assertEquals(vfsStream::url('basedir/README.pod'), $foundFile);

$foundFile = FileUtil::findFile(
$fs->url(),
[ 'README', 'READYOU' ],
[ '.asdf', '.pod', '.md', '' ],
['README', 'READYOU'],
['.asdf', '.pod', '.md', ''],
true
);
$this->assertEquals(vfsStream::url('basedir/README.pod'), $foundFile);

$foundFile = FileUtil::findFile(
$fs->url(),
[ 'LOWER', 'READYOU' ],
[ '.md', '.pod', '.md', '' ],
['LOWER', 'READYOU'],
['.md', '.pod', '.md', ''],
true
);
$this->assertEquals(vfsStream::url('basedir/READYOU.md'), $foundFile);

$foundFile = FileUtil::findFile(
$fs->url(),
[ 'LOWER', 'READYOU' ],
[ '.md', '.pod', '' ],
['LOWER', 'READYOU'],
['.md', '.pod', ''],
false
);
$this->assertEquals(vfsStream::url('basedir/lower.md'), $foundFile);

$foundFile = FileUtil::findFile(
$fs->url(),
[ 'subdir' ],
[ '', '.md' ],
['subdir'],
['', '.md'],
true
);
$this->assertEquals(vfsStream::url('basedir/subdir.md'), $foundFile);

$foundFile = FileUtil::findFile(
$fs->url(),
[ 'subdir' ],
[ '' ],
['subdir'],
[''],
true
);
$this->assertFalse($foundFile);
9 changes: 3 additions & 6 deletions site/tests/Util/ProcessCreatorTest.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
<?php

namespace App\Util;
namespace App\Tests\Util;

use App\Util\ProcessCreator;
use App\Util\ExecutorInterface;
use App\Util\ProcessCreator;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;

/**
* Tests for DefaultExecutor
* @author Amitosh Swain Mahapatra <[email protected]>
*
* @see ProcessCreator
* @see ProcessCreator
*/
class ProcessCreatorTest extends TestCase
{
6 changes: 4 additions & 2 deletions site/tests/Validator/Constraints/UserOrgNameValidatorTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

namespace App\Validator\Constraints;
namespace App\Tests\Validator\Constraints;

use App\Repository\OrganizationRepository;
use App\Repository\UserRepository;
use TestUtils\Generator;
use App\Validator\Constraints\UserOrgName;
use App\Validator\Constraints\UserOrgNameValidator;
use App\Tests\TestUtils\Generator;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
5 changes: 0 additions & 5 deletions site/tests/bootstrap.php

This file was deleted.

0 comments on commit 56ad270

Please sign in to comment.