Browse Source

Oubli methode

pull/1/head
JamesRezo 4 years ago
parent
commit
8c5d550a5b
  1. 8
      phpunit.xml
  2. 5
      src/Classic.php
  3. 16
      tests/Mocks/SpipClassic.php
  4. 16
      tests/Mocks/SpipCms.php
  5. 16
      tests/Mocks/SpipExtension.php
  6. 16
      tests/Mocks/SpipPlugin.php
  7. 26
      tests/Mocks/SpipProject.php
  8. 16
      tests/Mocks/SpipTemplate.php
  9. 26
      tests/SpipIntallerTest.php
  10. 18
      tests/test-classic.php
  11. 111
      tests/test.php

8
phpunit.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php">
<testsuites>
<testsuite name="standard">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>

5
src/Classic.php

@ -27,4 +27,9 @@ class Classic
$filesystem->copy($rootDir . 'tmp/__spip_classic__', $rootDir);
$filesystem->remove($rootDir . 'tmp/__spip_classic__');
}
public static function postUpdate(Event $event)
{
static::postInstall($event);
}
}

16
tests/Mocks/SpipClassic.php

@ -0,0 +1,16 @@
<?php
namespace Spip\Test\Composer\Mocks;
use Composer\Package\Package;
class SpipClassic
{
public function getPackage()
{
$package = new Package('spip/classic', '1.0', '1.0.0.0');
$package->setType('spip-classic');
return $package;
}
}

16
tests/Mocks/SpipCms.php

@ -0,0 +1,16 @@
<?php
namespace Spip\Test\Composer\Mocks;
use Composer\Package\Package;
class SpipCms
{
public function getPackage()
{
$package = new Package('SPIP/Cms', '1.0', '1.0.0.0');
$package->setType('spip-cms');
return $package;
}
}

16
tests/Mocks/SpipExtension.php

@ -0,0 +1,16 @@
<?php
namespace Spip\Test\Composer\Mocks;
use Composer\Package\Package;
class SpipExtension
{
public function getPackage()
{
$package = new Package('spip/mots', '1.0', '1.0.0.0');
$package->setType('spip-plugin');
return $package;
}
}

16
tests/Mocks/SpipPlugin.php

@ -0,0 +1,16 @@
<?php
namespace Spip\Test\Composer\Mocks;
use Composer\Package\Package;
class SpipPlugin
{
public function getPackage()
{
$package = new Package('spip/test', '1.0', '1.0.0.0');
$package->setType('spip-plugin');
return $package;
}
}

26
tests/Mocks/SpipProject.php

@ -0,0 +1,26 @@
<?php
namespace Spip\Test\Composer\Mocks;
use Composer\Package\RootPackage;
class SpipProject
{
public function getPackage()
{
$package = new RootPackage('spip/spip', '1.0', '1.0.0.0');
$package->setType('project');
$package->setExtra(array(
'spip' => array(
'template' => 'spip/dist',
'extensions' => array(
'spip/organiseur',
'spip/mots',
'spip/filtre_images'
)
)
));
return $package;
}
}

16
tests/Mocks/SpipTemplate.php

@ -0,0 +1,16 @@
<?php
namespace Spip\Test\Composer\Mocks;
use Composer\Package\Package;
class SpipTemplate
{
public function getPackage()
{
$package = new Package('spip/dist', '1.0', '1.0.0.0');
$package->setType('spip-plugin');
return $package;
}
}

26
tests/SpipIntallerTest.php

@ -0,0 +1,26 @@
<?php
namespace Spip\Test\Composer;
use Composer;
use PHPUnit\Framework\TestCase;
use Spip\Composer\Classic;
use Spip\Composer\SpipInstaller;
use Spip\Test\Composer\Mocks\SpipClassic;
use Spip\Test\Composer\Mocks\SpipProject;
class SpipInstallerTest extends TestCase
{
public function testGetInstallPath()
{
$spip = new SpipClassic();
$package = $spip->getPackage();
$io = new Composer\IO\NullIO();
$composer = Composer\Factory::create($io);
$spipInstaller = new SpipInstaller($io, $composer);
$this->assertSame('./tmp/__spip_classic__', $spipInstaller->getInstallPath($package));
}
}

18
tests/test-classic.php

@ -0,0 +1,18 @@
<?php
require_once __DIR__ . '/../vendor/autoload.php';
use Composer\Factory;
use Composer\Script\Event;
use Spip\Composer\Classic;
use Spip\Composer\SpipInstaller;
use Spip\Test\Composer\Mocks\SpipClassic;
$io = new Composer\IO\NullIO();
$composer = Factory::create($io);
$event = new Event('test', $composer, $io, true);
Classic::postInstall($event);
echo PHP_EOL;
exit(0);

111
tests/test.php

@ -0,0 +1,111 @@
<?php
/*echo PHP_EOL;
echo 'autoload: ';
echo "'" . __DIR__ . '/../vendor/autoload.php" ';
echo file_exists(__DIR__ . '/../vendor/autoload.php') ? 'OK' : 'KO';
echo PHP_EOL;
*/
require_once __DIR__ . '/../vendor/autoload.php';
use Composer\Factory;
use Spip\Composer\Classic;
use Spip\Composer\SpipInstaller;
use Spip\Test\Composer\Mocks\SpipCms;
use Spip\Test\Composer\Mocks\SpipExtension;
use Spip\Test\Composer\Mocks\SpipPlugin;
use Spip\Test\Composer\Mocks\SpipProject;
use Spip\Test\Composer\Mocks\SpipTemplate;
$spipProject = new SpipProject();
$io = new Composer\IO\NullIO();
$composer = Factory::create($io);
$composer->setPackage($spipProject->getPackage());
$extra = $composer->getPackage()->getExtra();
var_dump(["extra du rootPackage" => $extra]);
$mock = new SpipCms();
$package = $mock->getPackage();
var_dump(["un pacakge de type spip-cms" => $package]);
/*$extra = [
'spip' => [
'template' => ['jamesrezo/spip-clear'],
'extensions' => 'test/test'
]
];
$extra = [
'spip' => [
'template' => 'jamesrezo/spip-clear',
'extensions' => ['test/test']
]
];
$extra = [
'spip' => []
];*/
$template = isset($extra['spip']['template']) ? $extra['spip']['template'] : '';
$extensions = isset($extra['spip']['extensions']) ? $extra['spip']['extensions'] : [];
echo PHP_EOL;
echo 'extra: ';
echo PHP_EOL;
echo 'template: "';
echo is_string($template) ? $template : '';
echo '"';
echo PHP_EOL;
echo 'extensions: (';
echo is_array($extensions) ? implode(', ', $extensions) : '';
echo ')';
$spipInstaller = new SpipInstaller($io, $composer);
try {
$path = $spipInstaller->getInstallPath($package);
} catch (Exception $e) {
$path = '';
var_dump($e->getMessage());
}
echo 'path: "' . $path. '"';
echo PHP_EOL;
$mock = new SpipPlugin();
$package = $mock->getPackage();
try {
$path = $spipInstaller->getInstallPath($package);
} catch (Exception $e) {
$path = '';
var_dump($e->getMessage());
}
echo 'path: "' . $path. '"';
echo PHP_EOL;
$mock = new SpipExtension();
$package = $mock->getPackage();
try {
$path = $spipInstaller->getInstallPath($package);
} catch (Exception $e) {
$path = '';
var_dump($e->getMessage());
}
echo 'path: "' . $path. '"';
echo PHP_EOL;
$mock = new SpipTemplate();
$package = $mock->getPackage();
try {
$path = $spipInstaller->getInstallPath($package);
} catch (Exception $e) {
$path = '';
var_dump($e->getMessage());
}
echo 'path: "' . $path. '"';
echo PHP_EOL;
echo PHP_EOL;
exit(0);
Loading…
Cancel
Save