Magentoプラグインを作成し、PHPUnit Testing Integrationでhttp://www.ecomdev.orgからテストしようとします。今、私は2つの異なる設定設定の方法をテストしようとしていますが、何らかの理由で2番目の設定がロードされず、最初のものが再び使用されるため、2番目のフィクスチャが必要なテストは失敗します。Magento&eComDev Test Suiteのフィクスチャー(1つのフィクスチャを破棄して新しいものを使用)
ここで重要な行に減少問題です:
Modul.php(モデル)
<?php
class MyModule_Module_Model_TestModel extends Mage_Payment_Model_Method_Abstract {
protected $sandbox;
public function __construct() {
$this->sandbox = $this->getConfigData('sandbox');
}
public function getSandboxSetting() {
return $this->sandbox;
}
}
?>
具config.yaml
config
default/payment/modul/sandbox: 0
治具configSB.yamlは、
config
default/payment/modul/sandbox: 1
Modul.php(試験)
<?php
class MyModule_Module_Test_Model_TestModel extends EcomDev_PHPUnit_Test_Case {
public function setUp() {
parent::setUp();
$this->object = Mage::getModel('module/testmodel');
}
/**
* @test
* @loadFixture config
*/
public function testCorrectShopSettingsWithoutSandbox() {
$this->assertEquals('0', $this->object->getSandboxSetting());
}
/**
* @test
* @loadFixture configSB
*/
public function testCorrectShopSettingsWithSandbox() {
$this->assertEquals('1', $this->object->getSandboxSetting());
}
protected function tearDown() {
unset($this->object);
parent::tearDown();
}
}
?>
残念ながら第二の試験は、それらが実行される順序に関係なく失敗します。実際には、ecomdevテストスイートはfixtureを破棄しなければなりません(case.phpでtearDown()を見ました)が、configデータはまだそこにあり、上書きすることはできません。回避策がありますか、これはMagento /テストスイートの問題ですか?
なぜ公式MagentoのTAF 'ます。https:// github.com/Magentoの/ taf'? – Zyava
@Zyavaこれはセレンに基づく機能テスト(バックエンドロジックの代わりにhtmlのテストなど)のためです。 EcomDev_PHPUnitテストは、HTMLページの出力ではなく、機能の特定の単位(クラスメソッド)を対象としています。 –
申し訳ありませんが、私はタフのセレンの一部だけが公開されたことを知らなかった。 – Zyava