浏览代码

move all test in the test class

nas 2 年前
父节点
当前提交
fc68457ace
共有 2 个文件被更改,包括 68 次插入70 次删除
  1. 16
    70
      test/remote/NRT/Batch.pm
  2. 52
    0
      test/remote/NRT/Test.pm

+ 16
- 70
test/remote/NRT/Batch.pm 查看文件

@@ -28,80 +28,26 @@ sub test_user {
28 28
     $this->{config}{Authentification}{Email},
29 29
     $this->{config}{Authentification}{Username},
30 30
     $this->{config}{Authentification}{Password} );
31
-  $this->test_user_authentification( $user1_index );
32
-  $this->test_user_already_created( $user1_index );
33
-
31
+  $this->{tester}->test_user_authentification(
32
+    $this->{users}[$user1_index]);
33
+  $this->{tester}->test_user_already_created( 
34
+    $this->{users}[$user1_index]);
34 35
   my $user2_index = $this->add_user(
35 36
     $this->{config}{User}{Email},
36 37
     $this->{config}{User}{Username},
37 38
       $this->{config}{User}{Password} );
38
-  $this->test_user_not_exists( $user2_index );
39
-  $this->test_user_create( $user2_index );
40
-  $this->test_user_exists( $user2_index );
41
-  $this->test_user_remove( $user2_index );
42
-  $this->test_user_removed( $user2_index );
43
-  $this->test_user_already_removed( $user2_index );
44
-}
45
-
46
-sub test_user_authentification {
47
-  my ($this, $index) = @_;
48
-  my $auth = $this->{users}[ $index ]->authentification;
49
-  return $this->{tester}->assertEqual( $auth->{email}, $this->{users}[ $index ]->{email} );
50
-}
51
-
52
-sub test_user_exists {
53
-  my ($this, $index) = @_;
54
-  my $user = $this->{users}[ $index ]->fetch;
55
-  return $this->{tester}->assertEqual( $user->{data}{attributes}{email}, $this->{users}[ $index ]->{email} );
56
-}
57
-
58
-sub test_user_not_exists {
59
-  my ($this, $index) = @_;
60
-  my $user = $this->{users}[ $index ]->fetch();
61
-  return $this->{tester}->assertEqual( $user, 0 );
62
-}
63
-
64
-sub test_user_removed {
65
-  my ($this, $index) = @_;
66
-  my $user = $this->{users}[ $index ]->fetch();
67
-  return $this->{tester}->assertEqual( $user, '404 Not Found' );
68
-}
69
-
70
-sub test_user_create {
71
-  my ($this, $index) = @_;
72
-  my $creation = $this->{users}[ $index ]->create();
73
-  return $this->{tester}->assertEqual( $creation->{data}{attributes}{email}, $this->{users}[ $index ]->{email} );
74
-}
75
-
76
-sub test_user_already_removed {
77
-  my ($this, $index) = @_;
78
-  return $this->{tester}->assertEqual($this->remove_user( $index ), '404 Not Found');
79
-}
80
-
81
-sub test_user_remove {
82
-  my ($this, $index) = @_;
83
-  return $this->{tester}->assertEqual($this->remove_user( $index ), '204 No Content');
84
-}
85
-
86
-sub remove_user {
87
-  my ($this, $index) = @_;
88
-  return $this->{users}[ $index ]->remove;
89
-}
90
-
91
-sub test_user_already_created {
92
-  my ($this, $index) = @_;
93
-  my $creation = $this->create_user( $index );
94
-  return $this->{tester}->assertNotEqual( $creation, "422 Unprocessable Entity");
95
-}
96
-
97
-sub create_user {
98
-  my ($this, $index) = @_;
99
-  return $this->{users}[ $index ]->create;  
100
-}
101
-
102
-sub remove_user {
103
-  my ($this, $index) = @_;
104
-  return $this->{users}[ $index ]->remove;  
39
+  $this->{tester}->test_user_not_exists(
40
+    $this->{users}[$user2_index]);
41
+  $this->{tester}->test_user_create(
42
+    $this->{users}[$user2_index]);
43
+  $this->{tester}->test_user_exists(
44
+    $this->{users}[$user2_index]);
45
+  $this->{tester}->test_user_remove(
46
+    $this->{users}[$user2_index]);
47
+  $this->{tester}->test_user_removed(
48
+    $this->{users}[$user2_index]);
49
+  $this->{tester}->test_user_already_removed(
50
+    $this->{users}[$user2_index]);
105 51
 }
106 52
 
107 53
 sub add_user {

+ 52
- 0
test/remote/NRT/Test.pm 查看文件

@@ -126,4 +126,56 @@ sub get_url{
126 126
   return $this->{url} ;
127 127
 }
128 128
 
129
+sub test_rq_empty {
130
+  my $this = shift;
131
+  my $rq = $this->get_code();
132
+  return $this->assertEqual( $rq, "404 Not Found" );
133
+}
134
+
135
+sub test_user_authentification {
136
+  my ($this, $user) = @_;
137
+  my $auth = $user->authentification;
138
+  return $this->assertEqual( $auth->{email}, $user->{email} );
139
+}
140
+
141
+sub test_user_exists {
142
+  my ($this, $user) = @_;
143
+  my $ruser = $user->fetch;
144
+  return $this->assertEqual( $ruser->{data}{attributes}{email}, $user->{email} );
145
+}
146
+
147
+sub test_user_not_exists {
148
+  my ($this, $user) = @_;
149
+  my $user = $user->fetch();
150
+  return $this->assertEqual( $user, 0 );
151
+}
152
+
153
+sub test_user_create {
154
+  my ($this, $user) = @_;
155
+  my $creation = $user->create();
156
+  return $this->assertEqual( $creation->{data}{attributes}{email}, $user->{email} );
157
+}
158
+
159
+sub test_user_already_removed {
160
+  my ($this, $user) = @_;
161
+  return $this->assertEqual($user->remove, '404 Not Found');
162
+}
163
+
164
+sub test_user_removed {
165
+  my ($this, $user) = @_;
166
+  my $user = $user->fetch();
167
+  return $this->assertEqual( $user, '404 Not Found' );
168
+}
169
+
170
+sub test_user_remove {
171
+  my ($this, $user) = @_;
172
+  return $this->assertEqual( $user->remove, '204 No Content');
173
+}
174
+
175
+sub test_user_already_created {
176
+  my ($this, $user) = @_;
177
+  my $creation = $user->create;
178
+  return $this->assertNotEqual( $creation, "422 Unprocessable Entity");
179
+}
180
+
129 181
 return 1;

正在加载...
取消
保存