mirror of
https://github.com/silverqx/TinyORM.git
synced 2026-05-14 21:38:49 -05:00
renamed all occurences toVector to toList 😎 (5)
Divided to 5 commits for simpler review. Fifth commit: - renamed toVector() methods - updated all comments - also renamed toVectorVariantList() to toListVariantList() and attributesToVector() to attributesToList() These methods must be renamed, they must be toList() because in the future there can be toVector() method that will convert to std::vector<>. Also, all symbols described below which contain the word [Vv]ector will not be renamed to [Ll]ist, the reason for this is that the QList<> is vector and in the future when the QtCore dependency will be dropped 😮 this will be the std::vector<>. 😎 - variable names that are of type QList<> - method names which are operating on the QList<> - comments like: Vector of attached models IDs.
This commit is contained in:
@@ -246,7 +246,7 @@ namespace Orm::Tiny::Concerns
|
||||
/*! Convert the model's attributes to the map. */
|
||||
QVariantMap attributesToMap() const;
|
||||
/*! Convert the model's attributes to the vector. */
|
||||
QList<AttributeItem> attributesToVector() const;
|
||||
QList<AttributeItem> attributesToList() const;
|
||||
|
||||
/* Serialization - Appends */
|
||||
/*! Append accessor attribute to the u_appends set. */
|
||||
@@ -1353,7 +1353,7 @@ namespace Orm::Tiny::Concerns
|
||||
|
||||
template<typename Derived, AllRelationsConcept ...AllRelations>
|
||||
QList<AttributeItem>
|
||||
HasAttributes<Derived, AllRelations...>::attributesToVector() const
|
||||
HasAttributes<Derived, AllRelations...>::attributesToList() const
|
||||
{
|
||||
auto [attributes, attributesHash] = getVectorableAttributes();
|
||||
|
||||
|
||||
@@ -1471,7 +1471,7 @@ namespace Concerns
|
||||
{
|
||||
QVariant relationSerialized;
|
||||
|
||||
/*! Determine whether the toMap() or toVector() was invoked. */
|
||||
/*! Determine whether the toMap() or toList() was invoked. */
|
||||
constexpr auto IsMap = std::is_same_v<C, QVariantMap>;
|
||||
|
||||
// Many type relationship
|
||||
@@ -1514,7 +1514,7 @@ namespace Concerns
|
||||
models.template toMapVariantList<PivotType>());
|
||||
else
|
||||
relationSerialized.setValue(
|
||||
models.template toVectorVariantList<PivotType>());
|
||||
models.template toListVariantList<PivotType>());
|
||||
}
|
||||
|
||||
template<typename Derived, AllRelationsConcept ...AllRelations>
|
||||
@@ -1527,7 +1527,7 @@ namespace Concerns
|
||||
if constexpr (IsMap)
|
||||
relationSerialized.setValue(model->toMap());
|
||||
else
|
||||
relationSerialized.setValue(model->toVector());
|
||||
relationSerialized.setValue(model->toList());
|
||||
}
|
||||
// A NULL foreign key
|
||||
else
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace Orm::Tiny
|
||||
QVariantMap toMap() const;
|
||||
/*! Convert the model instance to the vector of attributes and relations. */
|
||||
template<typename PivotType = void> // PivotType is primarily internal
|
||||
QList<AttributeItem> toVector() const;
|
||||
QList<AttributeItem> toList() const;
|
||||
|
||||
/*! Convert the model instance to QJsonObject. */
|
||||
inline QJsonObject toJsonObject() const;
|
||||
@@ -1423,9 +1423,9 @@ namespace Orm::Tiny
|
||||
template<typename Derived, AllRelationsConcept ...AllRelations>
|
||||
template<typename PivotType>
|
||||
QList<AttributeItem>
|
||||
Model<Derived, AllRelations...>::toVector() const
|
||||
Model<Derived, AllRelations...>::toList() const
|
||||
{
|
||||
auto attributes = this->attributesToVector();
|
||||
auto attributes = this->attributesToList();
|
||||
|
||||
attributes << this->template serializeRelations<QList<AttributeItem>,
|
||||
PivotType>();
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Support::Stores
|
||||
|
||||
/* Here is the last and only one chance where we can obtain the PivotType
|
||||
for the belongs-to-many relation, so we need to pass it down, so that
|
||||
the toMap() or toVector() can obtain the correct pivot model type
|
||||
the toMap() or toList() can obtain the correct pivot model type
|
||||
from the m_relations map's std::variant. */
|
||||
|
||||
// belongs-to-many
|
||||
|
||||
@@ -410,7 +410,7 @@ namespace Types
|
||||
/* EnumeratesValues */
|
||||
/*! Get the vector of models as a attributes vector with serialized models. */
|
||||
template<typename PivotType = void> // PivotType is primarily internal
|
||||
QList<QList<AttributeItem>> toVector() const;
|
||||
QList<QList<AttributeItem>> toList() const;
|
||||
/*! Get the vector of models as a variant map with serialized models. */
|
||||
template<typename PivotType = void> // PivotType is primarily internal
|
||||
QList<QVariantMap> toMap() const;
|
||||
@@ -418,7 +418,7 @@ namespace Types
|
||||
/*! Get the vector of models as the variant (variant map inside) with serialized
|
||||
models (used by toJson()). */
|
||||
template<typename PivotType = void> // PivotType is primarily internal
|
||||
QVariantList toVectorVariantList() const;
|
||||
QVariantList toListVariantList() const;
|
||||
/*! Get the vector of models as the variant (variant map inside) with serialized
|
||||
models (used by toJson()). */
|
||||
template<typename PivotType = void> // PivotType is primarily internal
|
||||
@@ -1770,11 +1770,11 @@ namespace Types
|
||||
template<DerivedCollectionModel Model>
|
||||
template<typename PivotType>
|
||||
QList<QList<AttributeItem>>
|
||||
ModelsCollection<Model>::toVector() const
|
||||
ModelsCollection<Model>::toList() const
|
||||
{
|
||||
return map<QList<AttributeItem>>([](ModelRawType &&model) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
|
||||
{
|
||||
return model.template toVector<PivotType>();
|
||||
return model.template toList<PivotType>();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1792,11 +1792,11 @@ namespace Types
|
||||
template<DerivedCollectionModel Model>
|
||||
template<typename PivotType>
|
||||
QVariantList
|
||||
ModelsCollection<Model>::toVectorVariantList() const
|
||||
ModelsCollection<Model>::toListVariantList() const
|
||||
{
|
||||
return map<QVariant>([](ModelRawType &&model) // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
|
||||
{
|
||||
return QVariant::fromValue(model.template toVector<PivotType>());
|
||||
return QVariant::fromValue(model.template toList<PivotType>());
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ SqlQuery PostgresSchemaBuilder::getAllTables() const
|
||||
{
|
||||
auto searchPathList = searchPath();
|
||||
|
||||
// Move to the vector (toVector() uses copy)
|
||||
// Move to the vector (toList() uses copy)
|
||||
QList<QString> searchPath;
|
||||
searchPath.reserve(searchPathList.size());
|
||||
std::ranges::move(searchPathList, std::back_inserter(searchPath));
|
||||
@@ -102,7 +102,7 @@ SqlQuery PostgresSchemaBuilder::getAllViews() const
|
||||
{
|
||||
auto searchPathList = searchPath();
|
||||
|
||||
// Move to the vector (toVector() uses copy)
|
||||
// Move to the vector (toList() uses copy)
|
||||
QList<QString> searchPath;
|
||||
searchPath.reserve(searchPathList.size());
|
||||
std::ranges::move(searchPathList, std::back_inserter(searchPath));
|
||||
|
||||
@@ -194,7 +194,7 @@ private Q_SLOTS:
|
||||
void load_rvalue_NonExistentRelation_Failed() const;
|
||||
|
||||
/* EnumeratesValues */
|
||||
void toVector() const;
|
||||
void toList() const;
|
||||
void toMap() const;
|
||||
|
||||
void reject() const;
|
||||
@@ -2915,7 +2915,7 @@ void tst_Collection_Models::load_rvalue_NonExistentRelation_Failed() const
|
||||
|
||||
/* EnumeratesValues */
|
||||
|
||||
void tst_Collection_Models::toVector() const
|
||||
void tst_Collection_Models::toList() const
|
||||
{
|
||||
auto images = AlbumImage::findMany({1, 6, 7, 8});
|
||||
QCOMPARE(images.size(), 4);
|
||||
@@ -2923,7 +2923,7 @@ void tst_Collection_Models::toVector() const
|
||||
QVERIFY(Common::verifyIds(images, {1, 6, 7, 8}));
|
||||
|
||||
// Get result
|
||||
QList<QList<AttributeItem>> result = images.toVector();
|
||||
QList<QList<AttributeItem>> result = images.toList();
|
||||
|
||||
// Verify
|
||||
QCOMPARE(result.size(), 4);
|
||||
|
||||
@@ -195,7 +195,7 @@ private Q_SLOTS:
|
||||
void load_rvalue_NonExistentRelation_Failed() const;
|
||||
|
||||
/* EnumeratesValues */
|
||||
void toVector() const;
|
||||
void toList() const;
|
||||
void toMap() const;
|
||||
|
||||
void reject() const;
|
||||
@@ -3387,7 +3387,7 @@ void tst_Collection_Relations::load_rvalue_NonExistentRelation_Failed() const
|
||||
|
||||
/* EnumeratesValues */
|
||||
|
||||
void tst_Collection_Relations::toVector() const
|
||||
void tst_Collection_Relations::toList() const
|
||||
{
|
||||
auto images = AlbumImage::findMany({1, 6, 7, 8});
|
||||
QCOMPARE(images.size(), 4);
|
||||
@@ -3398,7 +3398,7 @@ void tst_Collection_Relations::toVector() const
|
||||
ModelsCollection<AlbumImage *> imagesInit = images.toPointers();
|
||||
|
||||
// Get result
|
||||
QList<QList<AttributeItem>> result = imagesInit.toVector();
|
||||
QList<QList<AttributeItem>> result = imagesInit.toList();
|
||||
|
||||
// Verify
|
||||
QCOMPARE(result.size(), 4);
|
||||
|
||||
@@ -43,27 +43,27 @@ private Q_SLOTS:
|
||||
void append_setAppend_getAppend_hasAppend_clearAppends() const;
|
||||
|
||||
void toMap_WithAppends() const;
|
||||
void toVector_WithAppends() const;
|
||||
void toList_WithAppends() const;
|
||||
|
||||
void toMap_WithAppends_WithVisible() const;
|
||||
void toVector_WithAppends_WithVisible() const;
|
||||
void toList_WithAppends_WithVisible() const;
|
||||
|
||||
void toMap_WithAppends_WithHidden() const;
|
||||
void toVector_WithAppends_WithHidden() const;
|
||||
void toList_WithAppends_WithHidden() const;
|
||||
|
||||
void toMap_WithAppends_WithVisibleAndHidden() const;
|
||||
void toVector_WithAppends_WithVisibleAndHidden() const;
|
||||
void toList_WithAppends_WithVisibleAndHidden() const;
|
||||
|
||||
void toMap_WithAppends_ForExistingAttribute() const;
|
||||
void toVector_WithAppends_ForExistingAttribute() const;
|
||||
void toVector_WithAppends_WithVisible_ForExistingAttribute() const;
|
||||
void toVector_WithAppends_WithHidden_ForExistingAttribute() const;
|
||||
void toList_WithAppends_ForExistingAttribute() const;
|
||||
void toList_WithAppends_WithVisible_ForExistingAttribute() const;
|
||||
void toList_WithAppends_WithHidden_ForExistingAttribute() const;
|
||||
|
||||
void toMap_WithAppends_OverrideSerializeDateTime() const;
|
||||
void toVector_WithAppends_OverrideSerializeDateTime() const;
|
||||
void toList_WithAppends_OverrideSerializeDateTime() const;
|
||||
|
||||
void toMap_WithAppends_OnCustomPivot() const;
|
||||
void toVector_WithAppends_OnCustomPivot() const;
|
||||
void toList_WithAppends_OnCustomPivot() const;
|
||||
|
||||
void toJson_WithAppends_WithVisible() const;
|
||||
void toJson_WithAppends_WithHidden() const;
|
||||
@@ -170,7 +170,7 @@ void tst_Model_Appends::toMap_WithAppends() const
|
||||
torrent->clearAppends();
|
||||
}
|
||||
|
||||
void tst_Model_Appends::toVector_WithAppends() const
|
||||
void tst_Model_Appends::toList_WithAppends() const
|
||||
{
|
||||
auto torrent = Torrent::find(4);
|
||||
QVERIFY(torrent);
|
||||
@@ -179,7 +179,7 @@ void tst_Model_Appends::toVector_WithAppends() const
|
||||
// Prepare
|
||||
torrent->append("name_progress");
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
QCOMPARE(serialized.size(), 11);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -228,7 +228,7 @@ void tst_Model_Appends::toMap_WithAppends_WithVisible() const
|
||||
torrent->clearAppends();
|
||||
}
|
||||
|
||||
void tst_Model_Appends::toVector_WithAppends_WithVisible() const
|
||||
void tst_Model_Appends::toList_WithAppends_WithVisible() const
|
||||
{
|
||||
auto torrent = Torrent::find(4);
|
||||
QVERIFY(torrent);
|
||||
@@ -238,7 +238,7 @@ void tst_Model_Appends::toVector_WithAppends_WithVisible() const
|
||||
torrent->setVisible({ID, "user_id", "added_on", "name_progress"});
|
||||
torrent->append({"name_progress", "name_size"});
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
QCOMPARE(serialized.size(), 4);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -285,7 +285,7 @@ void tst_Model_Appends::toMap_WithAppends_WithHidden() const
|
||||
torrent->clearAppends();
|
||||
}
|
||||
|
||||
void tst_Model_Appends::toVector_WithAppends_WithHidden() const
|
||||
void tst_Model_Appends::toList_WithAppends_WithHidden() const
|
||||
{
|
||||
auto torrent = Torrent::find(4);
|
||||
QVERIFY(torrent);
|
||||
@@ -295,7 +295,7 @@ void tst_Model_Appends::toVector_WithAppends_WithHidden() const
|
||||
torrent->setHidden({HASH_, NOTE, SIZE_, "name_progress"});
|
||||
torrent->append({"name_progress", "name_size"});
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
QCOMPARE(serialized.size(), 8);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -343,7 +343,7 @@ void tst_Model_Appends::toMap_WithAppends_WithVisibleAndHidden() const
|
||||
torrent->clearAppends();
|
||||
}
|
||||
|
||||
void tst_Model_Appends::toVector_WithAppends_WithVisibleAndHidden() const
|
||||
void tst_Model_Appends::toList_WithAppends_WithVisibleAndHidden() const
|
||||
{
|
||||
auto torrent = Torrent::find(4);
|
||||
QVERIFY(torrent);
|
||||
@@ -354,7 +354,7 @@ void tst_Model_Appends::toVector_WithAppends_WithVisibleAndHidden() const
|
||||
torrent->setHidden({"added_on", "name_size"});
|
||||
torrent->append({"name_progress", "name_size"});
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
QCOMPARE(serialized.size(), 3);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -397,7 +397,7 @@ void tst_Model_Appends::toMap_WithAppends_ForExistingAttribute() const
|
||||
torrentFile->clearAppends();
|
||||
}
|
||||
|
||||
void tst_Model_Appends::toVector_WithAppends_ForExistingAttribute() const
|
||||
void tst_Model_Appends::toList_WithAppends_ForExistingAttribute() const
|
||||
{
|
||||
auto torrentFile = TorrentPreviewableFile::find(10);
|
||||
QVERIFY(torrentFile);
|
||||
@@ -406,7 +406,7 @@ void tst_Model_Appends::toVector_WithAppends_ForExistingAttribute() const
|
||||
// Prepare
|
||||
torrentFile->append("filepath");
|
||||
|
||||
QList<AttributeItem> serialized = torrentFile->toVector();
|
||||
QList<AttributeItem> serialized = torrentFile->toList();
|
||||
QCOMPARE(serialized.size(), 9);
|
||||
|
||||
QList<AttributeItem> expectedAttributes {
|
||||
@@ -426,7 +426,7 @@ void tst_Model_Appends::toVector_WithAppends_ForExistingAttribute() const
|
||||
torrentFile->clearAppends();
|
||||
}
|
||||
|
||||
void tst_Model_Appends::toVector_WithAppends_WithVisible_ForExistingAttribute() const
|
||||
void tst_Model_Appends::toList_WithAppends_WithVisible_ForExistingAttribute() const
|
||||
{
|
||||
auto torrentFile = TorrentPreviewableFile::find(10);
|
||||
QVERIFY(torrentFile);
|
||||
@@ -436,7 +436,7 @@ void tst_Model_Appends::toVector_WithAppends_WithVisible_ForExistingAttribute()
|
||||
torrentFile->setVisible({ID, "torrent_id", "filepath", SIZE_});
|
||||
torrentFile->append("filepath");
|
||||
|
||||
QList<AttributeItem> serialized = torrentFile->toVector();
|
||||
QList<AttributeItem> serialized = torrentFile->toList();
|
||||
QCOMPARE(serialized.size(), 4);
|
||||
|
||||
QList<AttributeItem> expectedAttributes {
|
||||
@@ -452,7 +452,7 @@ void tst_Model_Appends::toVector_WithAppends_WithVisible_ForExistingAttribute()
|
||||
torrentFile->clearAppends();
|
||||
}
|
||||
|
||||
void tst_Model_Appends::toVector_WithAppends_WithHidden_ForExistingAttribute() const
|
||||
void tst_Model_Appends::toList_WithAppends_WithHidden_ForExistingAttribute() const
|
||||
{
|
||||
auto torrentFile = TorrentPreviewableFile::find(10);
|
||||
QVERIFY(torrentFile);
|
||||
@@ -462,7 +462,7 @@ void tst_Model_Appends::toVector_WithAppends_WithHidden_ForExistingAttribute() c
|
||||
torrentFile->setHidden({"filepath"});
|
||||
torrentFile->append("filepath");
|
||||
|
||||
QList<AttributeItem> serialized = torrentFile->toVector();
|
||||
QList<AttributeItem> serialized = torrentFile->toList();
|
||||
QCOMPARE(serialized.size(), 8);
|
||||
|
||||
QList<AttributeItem> expectedAttributes {
|
||||
@@ -513,7 +513,7 @@ void tst_Model_Appends::toMap_WithAppends_OverrideSerializeDateTime() const
|
||||
}
|
||||
|
||||
void
|
||||
tst_Model_Appends::toVector_WithAppends_OverrideSerializeDateTime() const
|
||||
tst_Model_Appends::toList_WithAppends_OverrideSerializeDateTime() const
|
||||
{
|
||||
auto datetime = Datetime_SerializeOverride::instance({
|
||||
{"datetime", QDateTime({2023, 05, 13}, {10, 11, 12}, TTimeZone::UTC)},
|
||||
@@ -524,7 +524,7 @@ tst_Model_Appends::toVector_WithAppends_OverrideSerializeDateTime() const
|
||||
// Prepare
|
||||
datetime.append({"datetime_test", "date_test", "time_test"});
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 6);
|
||||
|
||||
/* No casts and u_date are defined for the date and datetime attributes so
|
||||
@@ -597,7 +597,7 @@ void tst_Model_Appends::toMap_WithAppends_OnCustomPivot() const
|
||||
user->clearVisible();
|
||||
}
|
||||
|
||||
void tst_Model_Appends::toVector_WithAppends_OnCustomPivot() const
|
||||
void tst_Model_Appends::toList_WithAppends_OnCustomPivot() const
|
||||
{
|
||||
auto user = User::with("roles_appends")->find(1);
|
||||
QVERIFY(user);
|
||||
@@ -606,7 +606,7 @@ void tst_Model_Appends::toVector_WithAppends_OnCustomPivot() const
|
||||
// Prepare
|
||||
user->setVisible({ID, NAME, "roles_appends"});
|
||||
|
||||
QList<AttributeItem> serialized = user->toVector();
|
||||
QList<AttributeItem> serialized = user->toList();
|
||||
|
||||
QList<AttributeItem> expectedAttributes {
|
||||
{ID, 1},
|
||||
|
||||
+21
-21
@@ -39,23 +39,23 @@ private Q_SLOTS:
|
||||
|
||||
/* Serialization - HidesAttributes */
|
||||
void toMap_WithVisible() const;
|
||||
void toVector_WithVisible() const;
|
||||
void toList_WithVisible() const;
|
||||
|
||||
void toMap_WithHidden() const;
|
||||
void toVector_WithHidden() const;
|
||||
void toList_WithHidden() const;
|
||||
|
||||
void toMap_WithVisibleAndHidden() const;
|
||||
void toVector_WithVisibleAndHidden() const;
|
||||
void toList_WithVisibleAndHidden() const;
|
||||
|
||||
void toMap_WithVisible_WithRelations_HasOne_HasMany_BelongsTo() const;
|
||||
void toVector_WithVisible_WithRelations_HasOne_HasMany_BelongsTo() const;
|
||||
void toList_WithVisible_WithRelations_HasOne_HasMany_BelongsTo() const;
|
||||
void toMap_WithVisibleAndHidden_WithRelations_HasOne_HasMany_BelongsTo() const;
|
||||
void toVector_WithVisibleAndHidden_WithRelations_HasOne_HasMany_BelongsTo() const;
|
||||
void toList_WithVisibleAndHidden_WithRelations_HasOne_HasMany_BelongsTo() const;
|
||||
|
||||
void toMap_WithVisible_WithRelations_BelongsToMany_UserRoles() const;
|
||||
void toVector_WithVisible_WithRelations_BelongsToMany_UserRoles() const;
|
||||
void toList_WithVisible_WithRelations_BelongsToMany_UserRoles() const;
|
||||
void toMap_WithHidden_WithRelations_BelongsToMany_UserRoles() const;
|
||||
void toVector_WithHidden_WithRelations_BelongsToMany_UserRoles() const;
|
||||
void toList_WithHidden_WithRelations_BelongsToMany_UserRoles() const;
|
||||
|
||||
void toJson_WithVisible() const;
|
||||
void toJson_WithHidden() const;
|
||||
@@ -127,7 +127,7 @@ void tst_Model_HidesAttributes::toMap_WithVisible() const
|
||||
torrent->clearVisible();
|
||||
}
|
||||
|
||||
void tst_Model_HidesAttributes::toVector_WithVisible() const
|
||||
void tst_Model_HidesAttributes::toList_WithVisible() const
|
||||
{
|
||||
auto torrent = Torrent::find(4);
|
||||
QVERIFY(torrent);
|
||||
@@ -136,7 +136,7 @@ void tst_Model_HidesAttributes::toVector_WithVisible() const
|
||||
// Prepare
|
||||
torrent->setVisible({ID, "user_id", "added_on"});
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
QCOMPARE(serialized.size(), 3);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -178,7 +178,7 @@ void tst_Model_HidesAttributes::toMap_WithHidden() const
|
||||
torrent->clearHidden();
|
||||
}
|
||||
|
||||
void tst_Model_HidesAttributes::toVector_WithHidden() const
|
||||
void tst_Model_HidesAttributes::toList_WithHidden() const
|
||||
{
|
||||
auto torrent = Torrent::find(4);
|
||||
QVERIFY(torrent);
|
||||
@@ -187,7 +187,7 @@ void tst_Model_HidesAttributes::toVector_WithHidden() const
|
||||
// Prepare
|
||||
torrent->setHidden({HASH_, NOTE, SIZE_});
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
QCOMPARE(serialized.size(), 7);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -230,7 +230,7 @@ void tst_Model_HidesAttributes::toMap_WithVisibleAndHidden() const
|
||||
torrent->clearHidden();
|
||||
}
|
||||
|
||||
void tst_Model_HidesAttributes::toVector_WithVisibleAndHidden() const
|
||||
void tst_Model_HidesAttributes::toList_WithVisibleAndHidden() const
|
||||
{
|
||||
auto torrent = Torrent::find(4);
|
||||
QVERIFY(torrent);
|
||||
@@ -240,7 +240,7 @@ void tst_Model_HidesAttributes::toVector_WithVisibleAndHidden() const
|
||||
torrent->setVisible({ID, "user_id", "added_on"});
|
||||
torrent->setHidden({"added_on"});
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
QCOMPARE(serialized.size(), 2);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -321,7 +321,7 @@ const
|
||||
}
|
||||
|
||||
void tst_Model_HidesAttributes::
|
||||
toVector_WithVisible_WithRelations_HasOne_HasMany_BelongsTo() const
|
||||
toList_WithVisible_WithRelations_HasOne_HasMany_BelongsTo() const
|
||||
{
|
||||
auto torrent = Torrent::with({"torrentPeer", "user", "torrentFiles"})->find(7);
|
||||
QVERIFY(torrent);
|
||||
@@ -330,7 +330,7 @@ void tst_Model_HidesAttributes::
|
||||
// Prepare
|
||||
torrent->setVisible({ID, "user_id", "torrentPeer", "torrentFiles"});
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
|
||||
// Verify
|
||||
/* Here we will have to compare all serialized relation attributes separately
|
||||
@@ -477,7 +477,7 @@ void tst_Model_HidesAttributes::
|
||||
}
|
||||
|
||||
void tst_Model_HidesAttributes::
|
||||
toVector_WithVisibleAndHidden_WithRelations_HasOne_HasMany_BelongsTo() const
|
||||
toList_WithVisibleAndHidden_WithRelations_HasOne_HasMany_BelongsTo() const
|
||||
{
|
||||
auto torrent = Torrent::with({"torrentPeer", "user", "torrentFiles"})->find(7);
|
||||
QVERIFY(torrent);
|
||||
@@ -487,7 +487,7 @@ void tst_Model_HidesAttributes::
|
||||
torrent->setVisible({ID, "user_id", NOTE, "torrentPeer", "torrentFiles"});
|
||||
torrent->setHidden({NOTE, "torrentFiles"});
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
|
||||
// Verify
|
||||
/* Here we will have to compare all serialized relation attributes separately
|
||||
@@ -587,7 +587,7 @@ void tst_Model_HidesAttributes::
|
||||
}
|
||||
|
||||
void tst_Model_HidesAttributes::
|
||||
toVector_WithVisible_WithRelations_BelongsToMany_UserRoles() const
|
||||
toList_WithVisible_WithRelations_BelongsToMany_UserRoles() const
|
||||
{
|
||||
auto user = User::with("roles")->find(1);
|
||||
QVERIFY(user);
|
||||
@@ -596,7 +596,7 @@ void tst_Model_HidesAttributes::
|
||||
// Prepare
|
||||
user->setVisible({ID, NAME, "roles"});
|
||||
|
||||
QList<AttributeItem> serialized = user->toVector();
|
||||
QList<AttributeItem> serialized = user->toList();
|
||||
|
||||
QList<AttributeItem> expectedAttributes {
|
||||
{ID, 1},
|
||||
@@ -664,7 +664,7 @@ tst_Model_HidesAttributes::toMap_WithHidden_WithRelations_BelongsToMany_UserRole
|
||||
}
|
||||
|
||||
void
|
||||
tst_Model_HidesAttributes::toVector_WithHidden_WithRelations_BelongsToMany_UserRoles()
|
||||
tst_Model_HidesAttributes::toList_WithHidden_WithRelations_BelongsToMany_UserRoles()
|
||||
const
|
||||
{
|
||||
auto user = User::with("roles")->find(1);
|
||||
@@ -674,7 +674,7 @@ const
|
||||
// Prepare
|
||||
user->setHidden({NAME, NOTE, "roles"});
|
||||
|
||||
QList<AttributeItem> serialized = user->toVector();
|
||||
QList<AttributeItem> serialized = user->toList();
|
||||
|
||||
QList<AttributeItem> expectedAttributes {
|
||||
{ID, 1},
|
||||
|
||||
@@ -54,75 +54,75 @@ private Q_SLOTS:
|
||||
|
||||
/* Serialization */
|
||||
void toMap() const;
|
||||
void toVector() const;
|
||||
void toList() const;
|
||||
|
||||
void toMap_WithCasts() const;
|
||||
void toVector_WithCasts() const;
|
||||
void toList_WithCasts() const;
|
||||
|
||||
void toMap_UDatesOnly_QDateTime_For_date_column() const;
|
||||
void toVector_UDatesOnly_QDateTime_For_date_column() const;
|
||||
void toList_UDatesOnly_QDateTime_For_date_column() const;
|
||||
|
||||
void toMap_UDatesOnly_QDate_For_date_column() const;
|
||||
void toVector_UDatesOnly_QDate_For_date_column() const;
|
||||
void toList_UDatesOnly_QDate_For_date_column() const;
|
||||
|
||||
void toMap_UDatesOnly_Timestamp() const;
|
||||
void toVector_UDatesOnly_Timestamp() const;
|
||||
void toList_UDatesOnly_Timestamp() const;
|
||||
|
||||
void toMap_WithDateModfiers() const;
|
||||
void toVector_WithDateModfiers() const;
|
||||
void toList_WithDateModfiers() const;
|
||||
|
||||
void toMap_WithDateModfiers_UnixTimestamp() const;
|
||||
void toVector_WithDateModfiers_UnixTimestamp() const;
|
||||
void toList_WithDateModfiers_UnixTimestamp() const;
|
||||
|
||||
void toMap_UDatesOnly_OverrideSerializeDateTime() const;
|
||||
void toVector_UDatesOnly_OverrideSerializeDateTime() const;
|
||||
void toList_UDatesOnly_OverrideSerializeDateTime() const;
|
||||
|
||||
void toMap_CastsOnly_OverrideSerializeDateTime() const;
|
||||
void toVector_CastsOnly_OverrideSerializeDateTime() const;
|
||||
void toList_CastsOnly_OverrideSerializeDateTime() const;
|
||||
|
||||
void toMap_WithUDatesAndCasts_OverrideSerializeDateTime() const;
|
||||
void toVector_WithUDatesAndCasts_OverrideSerializeDateTime() const;
|
||||
void toList_WithUDatesAndCasts_OverrideSerializeDateTime() const;
|
||||
|
||||
void toMap_CastsOnly_WithDateModfiers_OverrideSerializeDateTime() const;
|
||||
void toVector_CastsOnly_WithDateModfiers_OverrideSerializeDateTime() const;
|
||||
void toList_CastsOnly_WithDateModfiers_OverrideSerializeDateTime() const;
|
||||
|
||||
void toMap_UDatesOnly_DateNullVariants() const;
|
||||
void toVector_UDatesOnly_DateNullVariants() const;
|
||||
void toList_UDatesOnly_DateNullVariants() const;
|
||||
|
||||
void toMap_WithCasts_DateNullVariants() const;
|
||||
void toVector_WithCasts_DateNullVariants() const;
|
||||
void toList_WithCasts_DateNullVariants() const;
|
||||
|
||||
void toMap_WithRelations_HasOne_HasMany_BelongsTo() const;
|
||||
void toVector_WithRelations_HasOne_HasMany_BelongsTo() const;
|
||||
void toList_WithRelations_HasOne_HasMany_BelongsTo() const;
|
||||
|
||||
void toMap_WithRelation_BelongsToMany_TorrentTags() const;
|
||||
void toVector_WithRelation_BelongsToMany_TorrentTags() const;
|
||||
void toList_WithRelation_BelongsToMany_TorrentTags() const;
|
||||
|
||||
void toMap_WithRelation_BelongsToMany_TorrentTags_TorrentStates() const;
|
||||
void toVector_WithRelation_BelongsToMany_TorrentTags_TorrentStates() const;
|
||||
void toList_WithRelation_BelongsToMany_TorrentTags_TorrentStates() const;
|
||||
|
||||
void toMap_WithRelation_BelongsToMany_UserRoles() const;
|
||||
void toVector_WithRelation_BelongsToMany_UserRoles() const;
|
||||
void toList_WithRelation_BelongsToMany_UserRoles() const;
|
||||
|
||||
void toMap_u_snakeAttributes_false() const;
|
||||
void toVector_u_snakeAttributes_false() const;
|
||||
void toList_u_snakeAttributes_false() const;
|
||||
|
||||
void toMap_HasMany_EmptyRelation() const;
|
||||
void toVector_HasMany_EmptyRelation() const;
|
||||
void toList_HasMany_EmptyRelation() const;
|
||||
|
||||
void toMap_HasOne_EmptyRelation() const;
|
||||
void toVector_HasOne_EmptyRelation() const;
|
||||
void toList_HasOne_EmptyRelation() const;
|
||||
|
||||
void toMap_BelongsTo_EmptyRelation() const;
|
||||
void toVector_BelongsTo_EmptyRelation() const;
|
||||
void toList_BelongsTo_EmptyRelation() const;
|
||||
|
||||
void toMap_BelongsToMany_EmptyRelation() const;
|
||||
void toVector_BelongsToMany_EmptyRelation() const;
|
||||
void toList_BelongsToMany_EmptyRelation() const;
|
||||
|
||||
void toMap_RelationOnly_HasMany() const;
|
||||
void toVector_RelationOnly_HasMany() const;
|
||||
void toList_RelationOnly_HasMany() const;
|
||||
void toMap_RelationOnly_BelongsToMany() const;
|
||||
void toVector_RelationOnly_BelongsToMany() const;
|
||||
void toList_RelationOnly_BelongsToMany() const;
|
||||
|
||||
void toJson_WithRelations_HasOne_HasMany_BelongsTo() const;
|
||||
void toJson_WithRelation_BelongsToMany_TorrentTags() const;
|
||||
@@ -193,13 +193,13 @@ void tst_Model_Serialization::toMap() const
|
||||
QCOMPARE(serialized, expectedAttributes);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector() const
|
||||
void tst_Model_Serialization::toList() const
|
||||
{
|
||||
auto torrent = Torrent::find(4);
|
||||
QVERIFY(torrent);
|
||||
QVERIFY(torrent->exists);
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
QCOMPARE(serialized.size(), 10);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -245,7 +245,7 @@ void tst_Model_Serialization::toMap_WithCasts() const
|
||||
datetime.resetCasts();
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_WithCasts() const
|
||||
void tst_Model_Serialization::toList_WithCasts() const
|
||||
{
|
||||
auto datetime = Datetime::instance({
|
||||
{"datetime", QDateTime({2023, 05, 13}, {10, 11, 12}, TTimeZone::UTC)},
|
||||
@@ -257,7 +257,7 @@ void tst_Model_Serialization::toVector_WithCasts() const
|
||||
{"date", CastType::QDate},
|
||||
{"timestamp", CastType::Timestamp}});
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 3);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -291,14 +291,14 @@ void tst_Model_Serialization::toMap_UDatesOnly_QDateTime_For_date_column() const
|
||||
}
|
||||
|
||||
void
|
||||
tst_Model_Serialization::toVector_UDatesOnly_QDateTime_For_date_column() const
|
||||
tst_Model_Serialization::toList_UDatesOnly_QDateTime_For_date_column() const
|
||||
{
|
||||
auto datetime = Datetime::instance({
|
||||
{"datetime", QDateTime({2023, 05, 13}, {10, 11, 12}, TTimeZone::UTC)},
|
||||
{"date", QDateTime({2023, 05, 14}, {10, 11, 12}, TTimeZone::UTC)},
|
||||
});
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 2);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -325,13 +325,13 @@ void tst_Model_Serialization::toMap_UDatesOnly_QDate_For_date_column() const
|
||||
QCOMPARE(serialized, expectedAttributes);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_UDatesOnly_QDate_For_date_column() const
|
||||
void tst_Model_Serialization::toList_UDatesOnly_QDate_For_date_column() const
|
||||
{
|
||||
auto datetime = Datetime::instance({
|
||||
{"date", QDate(2023, 05, 14)},
|
||||
});
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 1);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -356,13 +356,13 @@ void tst_Model_Serialization::toMap_UDatesOnly_Timestamp() const
|
||||
QCOMPARE(serialized, expectedAttributes);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_UDatesOnly_Timestamp() const
|
||||
void tst_Model_Serialization::toList_UDatesOnly_Timestamp() const
|
||||
{
|
||||
auto datetime = Datetime::instance(QList<AttributeItem> {
|
||||
{"timestamp", static_cast<qint64>(1662712888)},
|
||||
});
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 1);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -409,7 +409,7 @@ void tst_Model_Serialization::toMap_WithDateModfiers() const
|
||||
Datetime::u_timeFormat = std::move(timeFormatOriginal);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_WithDateModfiers() const
|
||||
void tst_Model_Serialization::toList_WithDateModfiers() const
|
||||
{
|
||||
auto datetime = Datetime::instance({
|
||||
{"datetime", QDateTime({2023, 05, 13}, {10, 11, 12}, TTimeZone::UTC)},
|
||||
@@ -425,7 +425,7 @@ void tst_Model_Serialization::toVector_WithDateModfiers() const
|
||||
{"time_ms", {CastType::CustomQTime, "HH:mm:ss.zzz"}},
|
||||
});
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 4);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -464,7 +464,7 @@ void tst_Model_Serialization::toMap_WithDateModfiers_UnixTimestamp() const
|
||||
datetime.resetCasts();
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_WithDateModfiers_UnixTimestamp() const
|
||||
void tst_Model_Serialization::toList_WithDateModfiers_UnixTimestamp() const
|
||||
{
|
||||
auto datetime = Datetime::instance({
|
||||
{"datetime", QDateTime({2023, 05, 13}, {10, 11, 12}, TTimeZone::UTC)},
|
||||
@@ -474,7 +474,7 @@ void tst_Model_Serialization::toVector_WithDateModfiers_UnixTimestamp() const
|
||||
{"datetime", {CastType::CustomQDateTime, "U"}},
|
||||
});
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 1);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -511,7 +511,7 @@ void tst_Model_Serialization::toMap_UDatesOnly_OverrideSerializeDateTime() const
|
||||
}
|
||||
|
||||
void
|
||||
tst_Model_Serialization::toVector_UDatesOnly_OverrideSerializeDateTime() const
|
||||
tst_Model_Serialization::toList_UDatesOnly_OverrideSerializeDateTime() const
|
||||
{
|
||||
auto datetime = Datetime_SerializeOverride::instance({
|
||||
{"datetime", QDateTime({2023, 05, 13}, {10, 11, 12}, TTimeZone::UTC)},
|
||||
@@ -520,7 +520,7 @@ tst_Model_Serialization::toVector_UDatesOnly_OverrideSerializeDateTime() const
|
||||
|
||||
Datetime_SerializeOverride::u_dates = {"date", "datetime"};
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 2);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -567,7 +567,7 @@ void tst_Model_Serialization::toMap_CastsOnly_OverrideSerializeDateTime() const
|
||||
}
|
||||
|
||||
void
|
||||
tst_Model_Serialization::toVector_CastsOnly_OverrideSerializeDateTime() const
|
||||
tst_Model_Serialization::toList_CastsOnly_OverrideSerializeDateTime() const
|
||||
{
|
||||
// Prepare
|
||||
auto timeFormatOriginal = Datetime_SerializeOverride::u_timeFormat;
|
||||
@@ -587,7 +587,7 @@ tst_Model_Serialization::toVector_CastsOnly_OverrideSerializeDateTime() const
|
||||
{"time_ms", CastType::QTime},
|
||||
});
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 4);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -635,7 +635,7 @@ void tst_Model_Serialization::
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::
|
||||
toVector_WithUDatesAndCasts_OverrideSerializeDateTime() const
|
||||
toList_WithUDatesAndCasts_OverrideSerializeDateTime() const
|
||||
{
|
||||
auto datetime = Datetime_SerializeOverride::instance({
|
||||
{"datetime", QDateTime({2023, 05, 13}, {10, 11, 12}, TTimeZone::UTC)},
|
||||
@@ -649,7 +649,7 @@ void tst_Model_Serialization::
|
||||
{"date", CastType::QDate},
|
||||
});
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 2);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -705,7 +705,7 @@ void tst_Model_Serialization::
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::
|
||||
toVector_CastsOnly_WithDateModfiers_OverrideSerializeDateTime() const
|
||||
toList_CastsOnly_WithDateModfiers_OverrideSerializeDateTime() const
|
||||
{
|
||||
// Prepare
|
||||
auto timeFormatOriginal = Datetime_SerializeOverride::u_timeFormat;
|
||||
@@ -727,7 +727,7 @@ void tst_Model_Serialization::
|
||||
{"time_ms", {CastType::CustomQTime, "HH_mm_ss.zzz"}},
|
||||
});
|
||||
|
||||
QList<AttributeItem> serialized = datetime.toVector();
|
||||
QList<AttributeItem> serialized = datetime.toList();
|
||||
QCOMPARE(serialized.size(), 4);
|
||||
|
||||
// The order must be the same as returned from the MySQL database
|
||||
@@ -765,7 +765,7 @@ void tst_Model_Serialization::toMap_UDatesOnly_DateNullVariants() const
|
||||
Type::u_dates.clear();
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_UDatesOnly_DateNullVariants() const
|
||||
void tst_Model_Serialization::toList_UDatesOnly_DateNullVariants() const
|
||||
{
|
||||
Type::u_dates = {"date", "datetime", "timestamp"};
|
||||
|
||||
@@ -773,7 +773,7 @@ void tst_Model_Serialization::toVector_UDatesOnly_DateNullVariants() const
|
||||
QVERIFY(type);
|
||||
QVERIFY(type->exists);
|
||||
|
||||
QList<AttributeItem> serialized = type->toVector();
|
||||
QList<AttributeItem> serialized = type->toList();
|
||||
QCOMPARE(serialized.size(), 4);
|
||||
|
||||
const auto &serialized0 = serialized.at(0);
|
||||
@@ -838,7 +838,7 @@ void tst_Model_Serialization::toMap_WithCasts_DateNullVariants() const
|
||||
type->resetCasts();
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_WithCasts_DateNullVariants() const
|
||||
void tst_Model_Serialization::toList_WithCasts_DateNullVariants() const
|
||||
{
|
||||
auto type = Type::find(3, {ID, "date", "datetime", "timestamp", "time"});
|
||||
QVERIFY(type);
|
||||
@@ -851,7 +851,7 @@ void tst_Model_Serialization::toVector_WithCasts_DateNullVariants() const
|
||||
{"time", CastType::QTime},
|
||||
});
|
||||
|
||||
QList<AttributeItem> serialized = type->toVector();
|
||||
QList<AttributeItem> serialized = type->toList();
|
||||
QCOMPARE(serialized.size(), 5);
|
||||
|
||||
const auto &serialized0 = serialized.at(0);
|
||||
@@ -958,13 +958,13 @@ tst_Model_Serialization::toMap_WithRelations_HasOne_HasMany_BelongsTo() const
|
||||
}
|
||||
|
||||
void
|
||||
tst_Model_Serialization::toVector_WithRelations_HasOne_HasMany_BelongsTo() const
|
||||
tst_Model_Serialization::toList_WithRelations_HasOne_HasMany_BelongsTo() const
|
||||
{
|
||||
auto torrent = Torrent::with({"torrentPeer", "user", "torrentFiles"})->find(7);
|
||||
QVERIFY(torrent);
|
||||
QVERIFY(torrent->exists);
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
|
||||
// Verify
|
||||
/* Here we will have to compare all serialized relation attributes separately
|
||||
@@ -1170,13 +1170,13 @@ tst_Model_Serialization::toMap_WithRelation_BelongsToMany_TorrentTags() const
|
||||
}
|
||||
|
||||
void
|
||||
tst_Model_Serialization::toVector_WithRelation_BelongsToMany_TorrentTags() const
|
||||
tst_Model_Serialization::toList_WithRelation_BelongsToMany_TorrentTags() const
|
||||
{
|
||||
auto torrent = Torrent::with("tags")->find(7);
|
||||
QVERIFY(torrent);
|
||||
QVERIFY(torrent->exists);
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
|
||||
// Verify
|
||||
/* Here we will have to compare all serialized relation attributes separately
|
||||
@@ -1407,13 +1407,13 @@ void tst_Model_Serialization::
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::
|
||||
toVector_WithRelation_BelongsToMany_TorrentTags_TorrentStates() const
|
||||
toList_WithRelation_BelongsToMany_TorrentTags_TorrentStates() const
|
||||
{
|
||||
auto torrent = Torrent::with({"tags", "torrentStates"})->find(7);
|
||||
QVERIFY(torrent);
|
||||
QVERIFY(torrent->exists);
|
||||
|
||||
QList<AttributeItem> serialized = torrent->toVector();
|
||||
QList<AttributeItem> serialized = torrent->toList();
|
||||
|
||||
// Verify
|
||||
/* Here we will have to compare all serialized relation attributes separately
|
||||
@@ -1613,13 +1613,13 @@ void tst_Model_Serialization::toMap_WithRelation_BelongsToMany_UserRoles() const
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::
|
||||
toVector_WithRelation_BelongsToMany_UserRoles() const
|
||||
toList_WithRelation_BelongsToMany_UserRoles() const
|
||||
{
|
||||
auto user = User::with("roles")->find(1);
|
||||
QVERIFY(user);
|
||||
QVERIFY(user->exists);
|
||||
|
||||
QList<AttributeItem> serialized = user->toVector();
|
||||
QList<AttributeItem> serialized = user->toList();
|
||||
|
||||
QList<AttributeItem> expectedAttributes {
|
||||
{ID, 1},
|
||||
@@ -1690,13 +1690,13 @@ void tst_Model_Serialization::toMap_u_snakeAttributes_false() const
|
||||
QCOMPARE(serialized, expectedAttributes);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_u_snakeAttributes_false() const
|
||||
void tst_Model_Serialization::toList_u_snakeAttributes_false() const
|
||||
{
|
||||
auto album = Album::find(1);
|
||||
QVERIFY(album);
|
||||
QVERIFY(album->exists);
|
||||
|
||||
QList<AttributeItem> serialized = album->toVector();
|
||||
QList<AttributeItem> serialized = album->toList();
|
||||
|
||||
QList<AttributeItem> expectedAttributes {
|
||||
{ID, 1},
|
||||
@@ -1753,13 +1753,13 @@ void tst_Model_Serialization::toMap_HasMany_EmptyRelation() const
|
||||
QCOMPARE(serialized, expectedAttributes);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_HasMany_EmptyRelation() const
|
||||
void tst_Model_Serialization::toList_HasMany_EmptyRelation() const
|
||||
{
|
||||
auto albums = Album::findMany({3, 4});
|
||||
QCOMPARE(albums.size(), 2);
|
||||
QCOMPARE(typeid (albums), typeid (ModelsCollection<Album>));
|
||||
|
||||
QList<QList<AttributeItem>> serialized = albums.toVector();
|
||||
QList<QList<AttributeItem>> serialized = albums.toList();
|
||||
|
||||
QList<QList<AttributeItem>> expectedAttributes {{
|
||||
{ID, 3},
|
||||
@@ -1834,13 +1834,13 @@ void tst_Model_Serialization::toMap_HasOne_EmptyRelation() const
|
||||
QCOMPARE(serialized, expectedAttributes);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_HasOne_EmptyRelation() const
|
||||
void tst_Model_Serialization::toList_HasOne_EmptyRelation() const
|
||||
{
|
||||
auto torrents = Torrent::with("torrentPeer")->findMany({6, 7});
|
||||
QCOMPARE(torrents.size(), 2);
|
||||
QCOMPARE(typeid (torrents), typeid (ModelsCollection<Torrent>));
|
||||
|
||||
QList<QList<AttributeItem>> serialized = torrents.toVector();
|
||||
QList<QList<AttributeItem>> serialized = torrents.toList();
|
||||
|
||||
QList<QList<AttributeItem>> expectedAttributes {{
|
||||
{ID, 6},
|
||||
@@ -1924,13 +1924,13 @@ void tst_Model_Serialization::toMap_BelongsTo_EmptyRelation() const
|
||||
QCOMPARE(serialized, expectedAttributes);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_BelongsTo_EmptyRelation() const
|
||||
void tst_Model_Serialization::toList_BelongsTo_EmptyRelation() const
|
||||
{
|
||||
auto torrentPeers = TorrentPeer::with("torrent")->findMany({5, 6});
|
||||
QCOMPARE(torrentPeers.size(), 2);
|
||||
QCOMPARE(typeid (torrentPeers), typeid (ModelsCollection<TorrentPeer>));
|
||||
|
||||
QList<QList<AttributeItem>> serialized = torrentPeers.toVector();
|
||||
QList<QList<AttributeItem>> serialized = torrentPeers.toList();
|
||||
|
||||
QList<QList<AttributeItem>> expectedAttributes {{
|
||||
{ID, 5},
|
||||
@@ -2008,13 +2008,13 @@ void tst_Model_Serialization::toMap_BelongsToMany_EmptyRelation() const
|
||||
QCOMPARE(serialized, expectedAttributes);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_BelongsToMany_EmptyRelation() const
|
||||
void tst_Model_Serialization::toList_BelongsToMany_EmptyRelation() const
|
||||
{
|
||||
auto users = User::with("roles")->findMany({2, 3});
|
||||
QCOMPARE(users.size(), 2);
|
||||
QCOMPARE(typeid (users), typeid (ModelsCollection<User>));
|
||||
|
||||
QList<QList<AttributeItem>> serialized = users.toVector();
|
||||
QList<QList<AttributeItem>> serialized = users.toList();
|
||||
|
||||
QList<QList<AttributeItem>> expectedAttributes {{
|
||||
{ID, 2},
|
||||
@@ -2095,7 +2095,7 @@ void tst_Model_Serialization::toMap_RelationOnly_HasMany() const
|
||||
QCOMPARE(serialized, expectedAttributes);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_RelationOnly_HasMany() const
|
||||
void tst_Model_Serialization::toList_RelationOnly_HasMany() const
|
||||
{
|
||||
auto torrent = Torrent::with("torrentFiles")->find(7);
|
||||
QVERIFY(torrent);
|
||||
@@ -2105,7 +2105,7 @@ void tst_Model_Serialization::toVector_RelationOnly_HasMany() const
|
||||
torrentFiles = torrent->getRelationValue<TorrentPreviewableFile>("torrentFiles");
|
||||
QCOMPARE(torrentFiles.size(), 3);
|
||||
|
||||
QList<QList<AttributeItem>> serialized = torrentFiles.toVector();
|
||||
QList<QList<AttributeItem>> serialized = torrentFiles.toList();
|
||||
|
||||
QList<QList<AttributeItem>> expectedAttributes {QList<AttributeItem> {
|
||||
{ID, 10},
|
||||
@@ -2185,7 +2185,7 @@ void tst_Model_Serialization::toMap_RelationOnly_BelongsToMany() const
|
||||
QCOMPARE(serialized, expectedAttributes);
|
||||
}
|
||||
|
||||
void tst_Model_Serialization::toVector_RelationOnly_BelongsToMany() const
|
||||
void tst_Model_Serialization::toList_RelationOnly_BelongsToMany() const
|
||||
{
|
||||
auto user = User::with("roles")->find(1);
|
||||
QVERIFY(user);
|
||||
@@ -2194,7 +2194,7 @@ void tst_Model_Serialization::toVector_RelationOnly_BelongsToMany() const
|
||||
ModelsCollection<Role *> roles = user->template getRelationValue<Role>("roles");
|
||||
QCOMPARE(roles.size(), 3);
|
||||
|
||||
QList<QList<AttributeItem>> serialized = roles.toVector<RoleUser>();
|
||||
QList<QList<AttributeItem>> serialized = roles.toList<RoleUser>();
|
||||
|
||||
QList<QList<AttributeItem>> expectedAttributes {QList<AttributeItem> {
|
||||
{ID, 1},
|
||||
|
||||
Reference in New Issue
Block a user