forked from baserproject/basercms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '5.1.x' of github.com:baserproject/basercms into 5.1.x
- Loading branch information
Showing
22 changed files
with
552 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
plugins/baser-core/tests/TestCase/Utility/BcAbstractDetectorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
/** | ||
* baserCMS : Based Website Development Project <https://basercms.net> | ||
* Copyright (c) NPO baser foundation <https://baserfoundation.org/> | ||
* | ||
* @copyright Copyright (c) NPO baser foundation | ||
* @link https://basercms.net baserCMS Project | ||
* @since 5.0.0 | ||
* @license https://basercms.net/license/index.html MIT License | ||
*/ | ||
|
||
namespace BaserCore\Test\TestCase\Utility; | ||
|
||
use BaserCore\TestSuite\BcTestCase; | ||
use BaserCore\Utility\BcAgent; | ||
use Cake\Core\Configure; | ||
|
||
/** | ||
* Class BcAbstractDetector | ||
* | ||
*/ | ||
class BcAbstractDetectorTest extends BcTestCase | ||
{ | ||
|
||
/** | ||
* set up | ||
*/ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
} | ||
|
||
/** | ||
* tearDown | ||
* | ||
* @return void | ||
*/ | ||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* test find | ||
*/ | ||
public function testFind() | ||
{ | ||
Configure::write("BcApp.smartphone", true); | ||
|
||
//Configureにnameがある場合、 | ||
$rs = BcAgent::find('smartphone'); | ||
$this->assertEquals('smartphone', $rs->name); | ||
$this->assertEquals('device', $rs->type); | ||
|
||
//Configureにnameがない場合、 | ||
$this->assertNull(BcAgent::find('test')); | ||
} | ||
|
||
/** | ||
* test findAll | ||
*/ | ||
public function testFindAll() | ||
{ | ||
Configure::write("BcEnv.isInstalled", false); | ||
|
||
//isInstalled=false | ||
$agents = BcAgent::findAll(); | ||
$this->assertCount(0, $agents); | ||
|
||
//isInstalled=true | ||
Configure::write("BcEnv.isInstalled", true); | ||
$agents = BcAgent::findAll(); | ||
$this->assertCount(2, $agents); | ||
} | ||
|
||
/** | ||
* test findCurrent | ||
* @param string $agent ユーザーエージェント名 | ||
* @param string $expect 期待値 | ||
* | ||
* @dataProvider findCurrentDataProvider | ||
*/ | ||
public function testFindCurrent($agent, $expect) | ||
{ | ||
$_SERVER["HTTP_USER_AGENT"] = $agent; | ||
$result = BcAgent::findCurrent(); | ||
if (is_null($expect)) { | ||
$this->assertNull($result); | ||
} else { | ||
$this->assertEquals($expect, $result->name); | ||
} | ||
} | ||
|
||
public static function findCurrentDataProvider(): array | ||
{ | ||
return [ | ||
['Googlebot-Mobile', 'mobile'], | ||
['DoCoMo', 'mobile'], | ||
['iPhone', 'smartphone'], | ||
['hoge', null], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.