[otrs-cvs] FAQ/scripts/test FAQ.t,1.1.1.1,1.2
cvs-log at otrs.org
cvs-log at otrs.org
Sun Mar 2 22:26:19 GMT 2008
Comments:
Update of /home/cvs/FAQ/scripts/test
In directory lancelot:/tmp/cvs-serv11829/scripts/test
Modified Files:
FAQ.t
Log Message:
Added unit tests.
Author: martin
Index: FAQ.t
===================================================================
RCS file: /home/cvs/FAQ/scripts/test/FAQ.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** FAQ.t 29 Jun 2006 09:29:51 -0000 1.1.1.1
--- FAQ.t 2 Mar 2008 22:26:14 -0000 1.2
***************
*** 1,5 ****
# --
! # FileTemp.t - FileTemp tests
! # Copyright (C) 2001-2005 Martin Edenhofer <martin+code at otrs.org>
# --
# $Id$
--- 1,5 ----
# --
! # FAQ.t - FAQ tests
! # Copyright (C) 2001-2008 OTRS AG, http://otrs.org/
# --
# $Id$
***************
*** 7,55 ****
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
! # did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --
use Kernel::System::FAQ;
! $Self->{FAQObject} = Kernel::System::FAQ->new(%{$Self});
! FAQGet()
! FAQAdd {
! AttachmentAdd {
! AttachmentGet {
! AttachmentDelete()
! AttachmentSearch()
! FAQUpdate()
! FAQCount {
! VoteAdd()
! VoteGet {
! FAQDelete {
! FAQHistoryAdd {
! FAQHistoryGet {
! FAQHistoryDelete {
! HistoryGet {
! CategoryList {
! CategorySearch {
! CategoryGet {
! CategorySubCategoryIDList {
! CategoryAdd {
! CategoryUpdate {
! CategoryDelete {
! CategoryCount {
! StateTypeList {
! StateList {
! StateUpdate {
! StateAdd {
! StateGet {
! StateTypeGet {
! LanguageList()
! LanguageUpdate {
! LanguageAdd {
! LanguageGet {
! FAQSearch {
! FAQPathListGet
! 1;
--- 7,188 ----
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
! # did not receive this file, see http://www.gnu.org/licenses/gpl-2.0.txt.
# --
use Kernel::System::FAQ;
! $Self->{FAQObject} = Kernel::System::FAQ->new(%{$Self}, UserID => 1);
! my $FAQID = $Self->{FAQObject}->FAQAdd(
! Title => 'Some Text',
! CategoryID => 1,
! StateID => 1,
! LanguageID => 1,
! Keywords => 'some keywords',
! Field1 => 'Problem...',
! Field2 => 'Solution...',
! FreeKey1 => 'Software',
! FreeText1 => 'Apache 3.4.2',
! FreeKey2 => 'OS',
! FreeText2 => 'OpenBSD 4.2.2',
! FreeKey3 => 'Key3',
! FreeText3 => 'Value3',
! FreeKey4 => 'Key4',
! FreeText4 => 'Value4',
! );
+ $Self->True(
+ $FAQID || 0,
+ "FAQAdd() - FAQAdd()",
+ );
+ my %FAQ = $Self->{FAQObject}->FAQGet(
+ ItemID => $FAQID,
+ );
! my %FAQTest = (
! Title => 'Some Text',
! CategoryID => 1,
! StateID => 1,
! LanguageID => 1,
! Keywords => 'some keywords',
! Field1 => 'Problem...',
! Field2 => 'Solution...',
! FreeKey1 => 'Software',
! FreeText1 => 'Apache 3.4.2',
! FreeKey2 => 'OS',
! FreeText2 => 'OpenBSD 4.2.2',
! FreeKey3 => 'Key3',
! FreeText3 => 'Value3',
! FreeKey4 => 'Key4',
! FreeText4 => 'Value4',
! );
+ for my $Test ( sort keys %FAQTest ) {
+ $Self->Is(
+ $FAQ{$Test} || 0,
+ $FAQTest{$Test} || '',
+ "FAQGet() - $Test",
+ );
+ }
+
+ my $FAQUpdate = $Self->{FAQObject}->FAQUpdate(
+ ItemID => $FAQID,
+ CategoryID => 1,
+ StateID => 2,
+ LanguageID => 2,
+ Title => 'Some Text2',
+ Keywords => 'some keywords2',
+ Field1 => 'Problem...2',
+ Field2 => 'Solution...2',
+ FreeKey1 => 'Software2',
+ FreeText1 => 'Apache 3.4.22',
+ FreeKey2 => 'OS2',
+ FreeText2 => 'OpenBSD 4.2.22',
+ FreeKey3 => 'Key32',
+ FreeText3 => 'Value32',
+ FreeKey4 => 'Key42',
+ FreeText4 => 'Value42',
+ );
+
+ %FAQ = $Self->{FAQObject}->FAQGet(
+ ItemID => $FAQID,
+ );
+
+ %FAQTest = (
+ Title => 'Some Text2',
+ CategoryID => 1,
+ StateID => 2,
+ LanguageID => 2,
+ Keywords => 'some keywords2',
+ Field1 => 'Problem...2',
+ Field2 => 'Solution...2',
+ FreeKey1 => 'Software2',
+ FreeText1 => 'Apache 3.4.22',
+ FreeKey2 => 'OS2',
+ FreeText2 => 'OpenBSD 4.2.22',
+ FreeKey3 => 'Key32',
+ FreeText3 => 'Value32',
+ FreeKey4 => 'Key42',
+ FreeText4 => 'Value42',
+ );
+
+ for my $Test ( sort keys %FAQTest ) {
+ $Self->Is(
+ $FAQTest{$Test} || '',
+ $FAQ{$Test} || 0,
+ "FAQGet() - $Test",
+ );
+ }
+
+ my $Ok = $Self->{FAQObject}->VoteAdd(
+ CreatedBy => 'Some Text',
+ ItemID => $FAQID,
+ IP => '54.43.30.1',
+ Interface => '2',
+ Rate => 100,
+ );
+
+ $Self->True(
+ $Ok || 0,
+ "VoteAdd()",
+ );
+
+ my $Vote = $Self->{FAQObject}->VoteGet(
+ CreateBy => 'Some Text',
+ ItemID => $FAQID,
+ IP => '54.43.30.1',
+ Interface => '2',
+ );
+
+ $Self->Is(
+ $Vote->{IP} || 0,
+ '54.43.30.1',
+ "VoteGet() - IP",
+ );
+
+ my @FAQIDs = $Self->{FAQObject}->FAQSearch(
+ Number => '*',
+ What => '*s*',
+ Keywords => 'some*',
+ States => ['public', 'internal'],
+ Order => 'Votes',
+ Sort => 'ASC',
+ Limit => 150,
+ );
+
+ my $FAQSearchFound = 0;
+ for my $FAQIDSearch ( @FAQIDs ) {
+ if ( $FAQIDSearch eq $FAQID ) {
+ $FAQSearchFound = 1;
+ last;
+ }
+ }
+ $Self->True(
+ $FAQSearchFound,
+ "FAQSearch()",
+ );
+
+ my @VoteIDs = @{$Self->{FAQObject}->VoteSearch(
+ ItemID => $FAQID,
+ )};
+
+ for my $VoteID ( @VoteIDs ) {
+ my $VoteDelete = $Self->{FAQObject}->VoteDelete(
+ VoteID => 1,
+ );
+ $Self->True(
+ $VoteDelete || 0,
+ "VoteDelete()",
+ );
+ }
+
+ my $FAQDelete = $Self->{FAQObject}->FAQDelete(
+ ItemID => $FAQID,
+ );
+ $Self->True(
+ $FAQDelete || 0,
+ "FAQDelete()",
+ );
+
+ 1;
More information about the cvs-log
mailing list