Skip to content
Extraits de code Groupes Projets
Valider 2c9b91d8 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Fixing bugs in screenshot testing lib.

parent 5c5c108d
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Subproject commit a58fcba24ef69c6a5c48bcfcb2fd5afd2c7d3c78 Subproject commit e9593ef8b7bb9c91a86b31fb2a08f917837fe57d
...@@ -115,11 +115,6 @@ Application.prototype.loadTestModules = function () { ...@@ -115,11 +115,6 @@ Application.prototype.loadTestModules = function () {
suite._beforeAll.unshift(suite._beforeAll.pop()); suite._beforeAll.unshift(suite._beforeAll.pop());
suite.afterAll(function (done) { suite.afterAll(function (done) {
if (!fixture) {
done();
return;
}
testEnvironment.teardownFixture(fixture, done); testEnvironment.teardownFixture(fixture, done);
}); });
}); });
......
...@@ -15,6 +15,10 @@ var TestingEnvironment = function () { ...@@ -15,6 +15,10 @@ var TestingEnvironment = function () {
}; };
TestingEnvironment.prototype.reload = function () { TestingEnvironment.prototype.reload = function () {
for (var key in this) {
delete this[key];
}
if (fs.exists(testingEnvironmentOverridePath)) { if (fs.exists(testingEnvironmentOverridePath)) {
var data = JSON.parse(fs.read(testingEnvironmentOverridePath)); var data = JSON.parse(fs.read(testingEnvironmentOverridePath));
for (var key in data) { for (var key in data) {
...@@ -29,8 +33,6 @@ TestingEnvironment.prototype.save = function () { ...@@ -29,8 +33,6 @@ TestingEnvironment.prototype.save = function () {
copy[key] = this[key]; copy[key] = this[key];
} }
delete copy.backup;
fs.write(testingEnvironmentOverridePath, JSON.stringify(copy)); fs.write(testingEnvironmentOverridePath, JSON.stringify(copy));
}; };
...@@ -90,8 +92,6 @@ TestingEnvironment.prototype._call = function (params, done) { ...@@ -90,8 +92,6 @@ TestingEnvironment.prototype._call = function (params, done) {
}; };
TestingEnvironment.prototype.setupFixture = function (fixtureClass, done) { TestingEnvironment.prototype.setupFixture = function (fixtureClass, done) {
this.backup = JSON.stringify(this);
console.log(" Setting up fixture " + fixtureClass + "..."); console.log(" Setting up fixture " + fixtureClass + "...");
var setupFile = path.join("./support", "setupDatabase.php"), var setupFile = path.join("./support", "setupDatabase.php"),
...@@ -125,7 +125,11 @@ TestingEnvironment.prototype.setupFixture = function (fixtureClass, done) { ...@@ -125,7 +125,11 @@ TestingEnvironment.prototype.setupFixture = function (fixtureClass, done) {
}; };
TestingEnvironment.prototype.teardownFixture = function (fixtureClass, done) { TestingEnvironment.prototype.teardownFixture = function (fixtureClass, done) {
if (options['persist-fixture-data']) { if (options['persist-fixture-data']
|| !fixtureClass
) {
this.deleteAndSave();
done(); done();
return; return;
} }
...@@ -146,11 +150,7 @@ TestingEnvironment.prototype.teardownFixture = function (fixtureClass, done) { ...@@ -146,11 +150,7 @@ TestingEnvironment.prototype.teardownFixture = function (fixtureClass, done) {
var self = this; var self = this;
child.on("exit", function (code) { child.on("exit", function (code) {
for (var key in self.backup) { self.deleteAndSave();
self[key] = self.backup[key];
}
self.backup = {};
if (code) { if (code) {
done(new Error("Failed to teardown fixture " + fixtureClass + " (error code = " + code + ")")); done(new Error("Failed to teardown fixture " + fixtureClass + " (error code = " + code + ")"));
...@@ -160,4 +160,9 @@ TestingEnvironment.prototype.teardownFixture = function (fixtureClass, done) { ...@@ -160,4 +160,9 @@ TestingEnvironment.prototype.teardownFixture = function (fixtureClass, done) {
}); });
}; };
TestingEnvironment.prototype.deleteAndSave = function () {
fs.write(testingEnvironmentOverridePath, "{}");
this.reload();
};
exports.TestingEnvironment = new TestingEnvironment(); exports.TestingEnvironment = new TestingEnvironment();
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter