本文整理汇总了PHP中Bootstrap::setApplication方法的典型用法代码示例。如果您正苦于以下问题:PHP Bootstrap::setApplication方法的具体用法?PHP Bootstrap::setApplication怎么用?PHP Bootstrap::setApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bootstrap
的用法示例。
在下文中一共展示了Bootstrap::setApplication方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLoad
public function testLoad()
{
global $testHelpers;
$app = $testHelpers->getAppWithMockCli();
Bootstrap::setApplication($app);
$extensions = $app['extensions'];
$extensions->init();
}
示例2: runSetup
private function runSetup()
{
global $testHelpers;
$app = $testHelpers->getAppWithMockCli();
Bootstrap::setApplication($app);
require_once WPBOOT_BASEPATH . '/www/wordpress-test/wp-load.php';
$setup = $app['setup'];
$setup->run([], []);
}
示例3: testResolvePostMetaReferences
public function testResolvePostMetaReferences()
{
global $testHelpers;
$app = $testHelpers->getAppWithMockCli();
Bootstrap::setApplication($app);
$r = $app['resolver'];
$i = $app['import'];
$testHelpers->makePublic($i, 'posts');
$i->posts = [(object) ['id' => 10, 'post' => ['ID' => 12, 'post_meta' => ['foobar' => [12, 'x:12']]]]];
\WP_Mock::wpFunction('update_post_meta', ['args' => [10, 'foobar', 10, 12], 'times' => 1]);
\WP_Mock::wpFunction('update_post_meta', ['args' => [10, 'foobar', 'x:10', 'x:12'], 'times' => 1]);
$references = ['foobar'];
$r->resolvePostMetaReferences($references, 'post');
}
示例4: testRemoveLastSizeIndicator
public function testRemoveLastSizeIndicator()
{
global $testHelpers;
$app = $testHelpers->getAppWithMockCli();
Bootstrap::setApplication($app);
$e = $app['extractmedia'];
$testStrings = array('http://foo.com/a.b.d-1x1-150x150.png', 'http://foo.com/a.b.d-1123x19999-150x150.png', 'http://foo.com/a.b.d-1123x19999-1123x19999.png', 'a.b.d-150x150.png');
$expectedStrings = array('http://foo.com/a.b.d-1x1.png', 'http://foo.com/a.b.d-1123x19999.png', 'http://foo.com/a.b.d-1123x19999.png', 'a.b.d.png');
for ($i = 0; $i < count($testStrings); ++$i) {
$test = $testStrings[$i];
$expected = $expectedStrings[$i];
$result = $e->removeLastSizeIndicator($test);
$this->assertEquals($expected, $result);
}
}
示例5: testEnsureDefineInFile
public function testEnsureDefineInFile()
{
global $testHelpers;
$app = $testHelpers->getAppWithMockCli();
Bootstrap::setApplication($app);
$h = $app['helpers'];
$file = WPBOOT_BASEPATH . '/test-config.php';
file_put_contents($file, "<?php\n\n");
$h->ensureDefineInFile($file, 'foobar', 'foovalue');
$lines = file($file);
$patterns = [preg_quote("/Added by WP Bootstrap/"), preg_quote("/if (!defined('foobar'))/"), preg_quote("/define('foobar', 'foovalue');/")];
foreach ($patterns as $pattern) {
$this->assertTrue(count(preg_grep($pattern, $lines)) > 0);
}
$h->ensureDefineInFile($file, 'foobar', 'foovalue2');
$lines = file($file);
$patterns = [preg_quote("/Added by WP Bootstrap/"), preg_quote("/if (!defined('foobar'))/"), preg_quote("/define('foobar', 'foovalue2');/")];
foreach ($patterns as $pattern) {
$this->assertTrue(count(preg_grep($pattern, $lines)) > 0);
}
$h->ensureDefineInFile($file . 'jada', 'foobar', 'foovalue2');
foreach ($patterns as $pattern) {
$this->assertTrue(count(preg_grep($pattern, $lines)) > 0);
}
}