Skip to content

Commit

Permalink
Some preparations for version release
Browse files Browse the repository at this point in the history
  • Loading branch information
twose committed Nov 7, 2022
1 parent 731e378 commit 713e1f7
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 19 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"Swow\\": "src/"
},
"files": [
"src/functions.php",
"src/bootstrap.php",
"src/Debug/functions.php"
]
},
Expand Down
26 changes: 26 additions & 0 deletions src/Library.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php
/**
* This file is part of Swow
*
* @link https://github.com/swow/swow
* @contact twosee <[email protected]>
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code
*/

declare(strict_types=1);

namespace Swow;

final class Library
{
public const VERSION = '0.2.0-alpha';
public const VERSION_ID = 200;
public const MAJOR_VERSION = 0;
public const MINOR_VERSION = 2;
public const RELEASE_VERSION = 0;
public const EXTRA_VERSION = 'alpha';

public const REQUIRED_EXTENSION_VERSION = '^0.2.0';
}
27 changes: 27 additions & 0 deletions src/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* This file is part of Swow
*
* @link https://github.com/swow/swow
* @contact twosee <[email protected]>
*
* For the full copyright and license information,
* please view the LICENSE file that was distributed with this source code
*/

declare(strict_types=1);

use Composer\Semver\Semver;
use Swow\Extension;
use Swow\Library;

if (!class_exists(Extension::class)) {
return;
}

if (!Semver::satisfies(Extension::VERSION, Library::REQUIRED_EXTENSION_VERSION)) {
throw new Error(sprintf(
'%s extension version mismatch, required: %s, actual: %s',
Swow::class, Library::REQUIRED_EXTENSION_VERSION, Extension::VERSION
));
}
14 changes: 0 additions & 14 deletions src/functions.php

This file was deleted.

22 changes: 18 additions & 4 deletions tests/SwowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
namespace Swow\Tests;

use PHPUnit\Framework\TestCase;
use Swow;

use function defined;
use function extension_loaded;
use function strlen;

/**
* @internal
Expand All @@ -26,12 +27,25 @@ final class SwowTest extends TestCase
{
public function testSwowExtension(): void
{
$this->assertTrue(extension_loaded('swow'));
$this->assertTrue(extension_loaded(Swow::class));
$this->assertGreaterThan(0, Swow\Extension::VERSION_ID);
}

public function testSwowLibrary(): void
{
$this->assertTrue(defined('SWOW_LIBRARY'));
$this->assertTrue(SWOW_LIBRARY);
$this->assertTrue(Swow::isLibraryLoaded());
$this->assertSame(Swow\Library::VERSION, sprintf(
'%d.%d.%d%s%s',
Swow\Library::MAJOR_VERSION,
Swow\Library::MINOR_VERSION,
Swow\Library::RELEASE_VERSION,
strlen(Swow\Library::EXTRA_VERSION) > 0 ? '-' : '', Swow\Library::EXTRA_VERSION
));
$this->assertSame(Swow\Library::VERSION_ID, (int) sprintf(
'%02d%02d%02d',
Swow\Library::MAJOR_VERSION,
Swow\Library::MINOR_VERSION,
Swow\Library::RELEASE_VERSION
));
}
}

0 comments on commit 713e1f7

Please sign in to comment.