今天是个好日子,
在过去的几天里,我一直在研究测试驱动开发,并决定我也需要学习它.虽然我无法弄清楚如何准确地做到这一点.
我的项目依赖于Symfony2.1.6框架和Doctrine,所以我有一些需要填充的数据库表.
书(1,n) - (0,n)类型
现在,如果我想插入一个类型记录,我首先需要编写一个测试来确保所有内容都被插入(或者我错了吗?)
现在的问题是我不知道如何访问我的数据库,因为它是由框架管理的.
我唯一能找到的是使用LiipFunctionalTestBundle https://github.com/liip/LiipFunctionalTestBundle,它每次运行测试时都会创建并恢复临时数据库.我按照说明设置了所有内容.
编辑:我的app/config/config_test.yml现在看起来像这样:
imports:
- { resource: config_dev.yml }
framework:
test: ~
session:
storage_id: session.storage.filesystem
liip_functional_test: ~
web_profiler:
toolbar: false
intercept_redirects: false
swiftmailer:
disable_delivery: true
liip_functional_test:
cache_sqlite_db: true
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_sqlite
path: %kernel.cache_dir%/test.db
Run Code Online (Sandbox Code Playgroud)
所以现在我有一个GenreTest类:
Liip没有文档所以我只是尝试了这样的方法.
use Liip\FunctionalTestBundle\Test\WebTestCase;
class GenreTest extends WebTestCase {
public function testInsert() {
$container = $this->getContainer();
$registry = $container->get('doctrine');
$em = $registry->getEntityManager(null);
$genre = new Genre();
$genre->setName("testGenre");
$em->persist($genre);
$em->flush();
$result = $em->createQuery("SELECT …Run Code Online (Sandbox Code Playgroud) php doctrine functional-testing symfony-2.1 liipfunctionaltestbundle
晚上好!
我知道这很常见,互联网上可能有成千上万的答案,但我找不到一个很好的答案.
我有两个本地分支机构:
- 主
- MK
我对Mk进行了很多更改,提交了这些更改,并切换到MASTER以合并这两个分支.但是有冲突.所以现在我在MASTER分支上,不能再切换到Mk了,但需要用Mk覆盖我的MASTER.
它一直在说
错误:合并将覆盖对以下文件的本地更改
有没有办法做到这一点?
git mergetool --tool=meld #No files need merging
git merge -s theirs Mk #Could not find merge strategy 'theirs'.
git merge -X recursive=theirs Mk # error: Your local changes to the following files
Run Code Online (Sandbox Code Playgroud)
将被合并覆盖
我还没有将我的更改推送到我的在线存储库.
我可以看到提交所有更改但无法访问其代码.
刚刚开始使用git,但从未像以前那样遇到麻烦.我真的很感激我能得到的任何帮助:s
再会!
前几天我偶然发现了一个小“问题”......
我通过 linux-shell 学习了脚本编写。在那里,人们可以通过字符串构造命令并按原样执行它们。
例如:
#!bin/bash
LS_ARGS='-lad'
LS_CMD='ls'
CMD="$LS_CMD $LS_ARGS /home"
$CMD
Run Code Online (Sandbox Code Playgroud)
但现在我不得不切换到Windows powershell:
If ( $BackgroundColor ) {
Write-Host -BackgroundColor $BackgroundColor
}
If ( $ForegroundColor ) {
Write-Host -ForegroundColor $ForegroundColor
}
If ( $ForegroundColor -AND $BackgroundColor ) {
Write-Host -ForegroundColor $ForegroundColor
-BackgroundColor $BackgroundColor
}
If ( $NoNewline ) {
If ( $BackgroundColor ) { ... }
ElseIf ( $ForegroundColor ) { ... }
ElseIf ( $ForegroundColor -AND $BackgroundColor ) { ... }
Else { ... }
}
Run Code Online (Sandbox Code Playgroud)
我想你知道我的意思;)有谁知道一种减少这种情况的方法,例如: …
bash ×1
doctrine ×1
git ×1
git-merge ×1
merge ×1
php ×1
powershell ×1
scripting ×1
symfony-2.1 ×1